Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2561956rdb; Fri, 8 Dec 2023 11:41:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdNHwtuvN/6RApVBKHpw/vVKGGKI3jv9SahNIFmAv5DN3e2XLvtAm6ZBQWjwiR51ut4/MX X-Received: by 2002:a05:6a00:2d13:b0:6ce:270f:2eba with SMTP id fa19-20020a056a002d1300b006ce270f2ebamr684994pfb.34.1702064489993; Fri, 08 Dec 2023 11:41:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702064489; cv=none; d=google.com; s=arc-20160816; b=zZT+eOc3zGqHLp/UsKa4kVlGQgcUFh7TCkNSgSbLFomVS466YvwUvVO+xxOdWCmkiZ HUFJVl2hwTlAHMCdwlzv7mcPLXnhaEyhG6w0C+wR/jFYfE1H+fVMBaEqs83DW2rX2m04 6PzP4c0e38mELLP6ppdfl3v7o4FbqNg09GtJgRt+SMTSTO2hIhlAXKA2j/IZRgaSQTj/ aZ75jRFw489144t/jxIT9oG7GpYdjkmEcvWDKsvIi5OcDenbJGsqESlUn500gvLp2XGe LCm9VgD28MAXpwbfg66uaS5p59280ZEPrQoXX+5cnBlqlGlShSTj6QG+QwKk0iVLZSeY ZXEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=lGqhfgnTbLSQhTQ1bMee6eK6lcK7c6hE95qruhtgvEk=; fh=fQgCWRvTCP/t++nK1ImfffmCDgAeoMpK4D1rM2RjSwU=; b=t9EWxNJXvqfLRl6K7mfDpchlrt9TCqBJszUe+lRsTizhWomPqsUCLVVR1OT640h0ao UOdLtEcr9Pky36swaMKUJQTisr3uvjwQ21KJHAomFsEEHzrulvZFL1vFcOPqn8/S7xAq VL6jiE/KpH2jAnH10q4ucWQ1RJL4kea+nmG2eWRP05CdM8SKsCbC22AeqdTECZdxEbUI c01XDafNaL3Zhn39SpBOtfDLiLsOOF1JTTNKdCNFrBV0iPvOEMSBX/FLK1Bx3YUhttBT IHpkMHixo5Sl31mT3uJi5CGrO+9ujNvn2fW6Vbo+pkGocBBSBByJrvP151zjvTpiTajC gFxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VHC0k+mM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s15-20020a65690f000000b005c66a7d710esi1927164pgq.456.2023.12.08.11.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 11:41:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VHC0k+mM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C888E84A84F6; Fri, 8 Dec 2023 11:41:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234074AbjLHTkh (ORCPT + 99 others); Fri, 8 Dec 2023 14:40:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234071AbjLHTkd (ORCPT ); Fri, 8 Dec 2023 14:40:33 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DD5E199F; Fri, 8 Dec 2023 11:40:39 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-32f8441dfb5so2226369f8f.0; Fri, 08 Dec 2023 11:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702064438; x=1702669238; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lGqhfgnTbLSQhTQ1bMee6eK6lcK7c6hE95qruhtgvEk=; b=VHC0k+mMONG1sn2lHi5PinhxgLT6ZlhKXS2rTAWvS9SpRi8uFvV7GBrsxTuRgYQnT2 A3Of7SnVGOKgHlovRIP/zry3ZoAeqRuDeZJ79WqQeRol+BMjtJDSJ+I4mokRcbwJAig9 pQZyj46RCdbQ9edaCL+ffQELcz/Z0pLYl2mEVMH/HRuFwS0yBX2AytHap/RNiw5eQKSs Wlt0GqIOz2BcFhZiHXc+SshWBB459LuR6gqghQ5O0jM8fuLW02M5g/t201V82hJ8K94R 1hnXaCmckIA07XlON021roKBQE2mH4J93iTIUUR7TXIlUM652fB4eRySiG49crimotyX cXeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702064438; x=1702669238; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lGqhfgnTbLSQhTQ1bMee6eK6lcK7c6hE95qruhtgvEk=; b=ASM7MJfpyKRPlX/sc3Hu0jZNxSOjHOcCiq61fj5YR2PDrIUJwSY5d3W+R7YxJ2qEBQ d2zk8wCgx3+PxUgdDpk/YYwc3KXaugznW3zc6IAyciNE5hou9gaLGvf5r09Y3YxMm5kb 7fU/ewsNgh2uu4sdJO6DBIGSG8N4L0Il8RUsVwA/j1TFptyKvkpCIqCb0BuaNpR4n+a9 1t9JUiEW84fq4VPl6BLRdvSccqJHvqEnP80p5In/r7MabqKoH4VPIJwdTj0I2YfaF3kF V6imkHKKyMzLFODSO9dKa5XNR2PF7cr06D52xnfGLCXHrUjuxLNAGs2EXnmlkm6ToWOr f4xg== X-Gm-Message-State: AOJu0YycaT6A0uUQL2NIhhzVYG/UU69pu81FB/9a2fqATqy2+aP4sJ8j 6GVmoXyB+t4ik47hjENzDOh5bOFjrwEtKq7bXH7ejDPv8Ms= X-Received: by 2002:a05:6000:543:b0:333:381d:6a26 with SMTP id b3-20020a056000054300b00333381d6a26mr334324wrf.135.1702064438187; Fri, 08 Dec 2023 11:40:38 -0800 (PST) MIME-Version: 1.0 References: <20231204181614.GA7299@noisy.programming.kicks-ass.net> <20231204183354.GC7299@noisy.programming.kicks-ass.net> <20231206163814.GB36423@noisy.programming.kicks-ass.net> <20231206183713.GA35897@noisy.programming.kicks-ass.net> <20231207093105.GA28727@noisy.programming.kicks-ass.net> <20231208102940.GB28727@noisy.programming.kicks-ass.net> <20231208134041.GD28727@noisy.programming.kicks-ass.net> <20231208172152.GD36716@noisy.programming.kicks-ass.net> In-Reply-To: <20231208172152.GD36716@noisy.programming.kicks-ass.net> From: Alexei Starovoitov Date: Fri, 8 Dec 2023 11:40:27 -0800 Message-ID: Subject: Re: [PATCH v2 2/2] x86/cfi,bpf: Fix BPF JIT call To: Peter Zijlstra Cc: Jiri Olsa , Song Liu , Song Liu , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , "H. Peter Anvin" , "David S. Miller" , David Ahern , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Arnd Bergmann , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , linux-riscv , LKML , Network Development , bpf , linux-arch , clang-built-linux , Josh Poimboeuf , Joao Moreira , Mark Rutland Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 08 Dec 2023 11:41:21 -0800 (PST) On Fri, Dec 8, 2023 at 9:22=E2=80=AFAM Peter Zijlstra wrote: > > On Fri, Dec 08, 2023 at 02:40:41PM +0100, Peter Zijlstra wrote: > > On Fri, Dec 08, 2023 at 11:29:40AM +0100, Peter Zijlstra wrote: > > > The only problem I now have is the one XXX, I'm not entirely sure wha= t > > > signature to use there. > > > > > @@ -119,6 +119,7 @@ int bpf_struct_ops_test_run(struct bpf_p > > > op_idx =3D prog->expected_attach_type; > > > err =3D bpf_struct_ops_prepare_trampoline(tlinks, link, > > > &st_ops->func_models[op_i= dx], > > > + /* XXX */ NULL, > > > image, image + PAGE_SIZE)= ; > > > if (err < 0) > > > goto out; > > > > Duh, that should ofcourse be something of dummy_ops_test_ret_fn type. > > Let me go fix that. > > Next one.. bpf_obj_free_fields: field->kptr.dtor(xchg_field); > > The one that trips is bpf_cgroup_release(). > > objtool doesn't think the address of that function 'escapes' and > 'helpfully' seals that function, and then BPF thinks it does escape and > manages the above indirect call and *boom*. > > How can I tell which functions escape according to BPF such that I might > teach objtool this? I'm not following. Are you asking to annotate __bpf_kfunc void bpf_cgroup_release(struct cgroup *cgrp) somehow so that objtool knows that it will be called indirectly? typedef void (*btf_dtor_kfunc_t)(void *); btf_dtor_kfunc_t dtor; but the bpf_cgroup_release takes 'struct cgroup*'. From kcfi pov void * =3D=3D struct cgroup * ? Do we need to change it to 'void *cgrp' ? What is "sealing" by objtool?