Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2592147rdb; Fri, 8 Dec 2023 12:41:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1cpHZ5Myn9Fs2loLO0RCAIPM0h7+h/GVPLYZXYAI0rDJMSw8PnMk27MxT7W+Jk0bxjXXZ X-Received: by 2002:a17:90a:898c:b0:28a:325d:1ed3 with SMTP id v12-20020a17090a898c00b0028a325d1ed3mr630980pjn.2.1702068082721; Fri, 08 Dec 2023 12:41:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702068082; cv=none; d=google.com; s=arc-20160816; b=RC2VKtqkYdnIaz4Hbqbsgu9Q9EpjvN+MErva6WXauG5ziq1T8uqL8+WaW9tdlISkoM Lirs2nYMqtXtLkaKPEVmQkqNFjPvLe7PsQS/NrJSBIuV3QbcBGDDSIQnwx7bzOse/fuT 6wnpnEsDdTsvmkuFs8YiS7fXaXDf5CZDZOSu0X142ShdcMD+KN1gJKLwTJlh0Q/xVcVW Iqh/LDeTIR/7WKL+AcW1RCu3wYOzBCLtP59R12eXTlCCuM2sE7kakoyuXpBnVUOfJ8up GkVAfCWJcnRDytRhswACAAvZnNboa4+tscLuUUqBy17MU+fAGvxDhcjzvNHkJGVB6Meb DWRg== 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=Mj7pq+OIwUID+JMsGrWjS7UT9Bcii1A8UE8TU13OktE=; fh=fQgCWRvTCP/t++nK1ImfffmCDgAeoMpK4D1rM2RjSwU=; b=J8Q5mBaBVIX92i28TYDKGRX/CzZTkkvl1Mmoh6vjJ1L7KcNzaQXqq+187GrRxASjkE 16KWgW/PQa83rjGmqoWPSjiaANyuuGywI1/4/lchraJkTnQbYYGiikpPedv9uEGB/zC7 MQy/VQObc9ldSPGsp8dy18iRaoNePgEeu+zg1SBjYxPGJKEDHNQfXurMuLigZ7ij3Cwq W1PALbUeeRWc3hiVPBItBGGmwlj1yjD6MJlslZUUBiIzwPpfJZ3xobVrJnMk1oCFNAQj /fsljkBLv1EmA7jqeoIhzIZF6MI33JFIEXR1/AvYdcM5BnzZ20exG64C8vJ4AT4mLzzX qj8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=G3MZ0atA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w9-20020a17090aad4900b00285f918f395si2079647pjv.190.2023.12.08.12.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 12:41:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=G3MZ0atA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 84FD88106783; Fri, 8 Dec 2023 12:41:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231309AbjLHUlM (ORCPT + 99 others); Fri, 8 Dec 2023 15:41:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjLHUlK (ORCPT ); Fri, 8 Dec 2023 15:41:10 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4BAA171E; Fri, 8 Dec 2023 12:41:16 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40c0a0d068bso25063265e9.3; Fri, 08 Dec 2023 12:41:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702068075; x=1702672875; 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=Mj7pq+OIwUID+JMsGrWjS7UT9Bcii1A8UE8TU13OktE=; b=G3MZ0atAgyPACTlO2h7s/lMC/oRfCFYkG7eYNPHZso8JoPnWQajw0hBD0IMwaw2k+e 9oEUqW7bfQoZ9A+l/ZCrSnsweIma9Tc8w6L3JKjXpRsPc6TKWWxyR0wZ8+bZa5Ok1t6Q agD9I28vIANLCIoPCqAE+0LdgDXekeKg86moQWI2v+kl9C7cKvyaIdptKdI2prnEABas GK1zoen9SwdDyfr2M80/lwFlEcx6HgOyBaOMqffzIQwN6jSffBZaZMrnIrPFGVAHrZ3M zAVDeICaUJz663LD3pOv3GN0VX+wXf7i55v1BI5JFdcxprDOxPJ6piluZAO+k1ktyUgf ZytA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702068075; x=1702672875; 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=Mj7pq+OIwUID+JMsGrWjS7UT9Bcii1A8UE8TU13OktE=; b=pGiuaErv8MDscLZQpGI5Wmt4Vz2tKoQkhiHIj/M11IG7P0p4o/4HiHilhocEV8rfP8 BEz0vHSJMygaJY2pmwLXPnlBEQDntcF4Fk5PTlErJdPY5OCeRO2OJCvA4hrRHpqIZwvm ib0gto0unqQeI4S9doV18QizNjth+nzlTWubGfHvkCBsWuf/Xhjrz/aTbvbF5QUE2EJa oF9B9uwrK756SzPL1AQJo2zJqyuTcMNabvESUpUccPWtzD7pdss9/E1J2KbN3CEeu9m1 IuC8CoD72haV0JXBO6FjWJiraUBW0u/Jh7Y1fWsluZomYxMnReMN2D9l0hyuM7m1jYRw 6mCA== X-Gm-Message-State: AOJu0YxcknAraaNMAEvgBx2yDhu86S2pvZ74f/v9GzYK8fwalkASBi83 qBH4ZQzVZyD24TXSNpa40WV4BfQazH1i2WGKqGM= X-Received: by 2002:adf:f00f:0:b0:333:2f14:7642 with SMTP id j15-20020adff00f000000b003332f147642mr344840wro.61.1702068075072; Fri, 08 Dec 2023 12:41:15 -0800 (PST) MIME-Version: 1.0 References: <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> <20231208203535.GG36716@noisy.programming.kicks-ass.net> In-Reply-To: <20231208203535.GG36716@noisy.programming.kicks-ass.net> From: Alexei Starovoitov Date: Fri, 8 Dec 2023 12:41:03 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 08 Dec 2023 12:41:21 -0800 (PST) On Fri, Dec 8, 2023 at 12:35=E2=80=AFPM Peter Zijlstra wrote: > > On Fri, Dec 08, 2023 at 11:40:27AM -0800, Alexei Starovoitov wrote: > > > 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' ? > > Yes, doing that naively like the below, gets me lovely things like: > > validate_case:FAIL:expect_msg unexpected error: -22 > VERIFIER LOG: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > EXPECTED MSG: 'Possibly NULL pointer passed to trusted arg0' > #48/7 cgrp_kfunc/cgrp_kfunc_acquire_untrusted:FAIL > run_subtest:PASS:obj_open_mem 0 nsec > libbpf: extern (func ksym) 'bpf_cgroup_release': func_proto [148] incompa= tible with vmlinux [125610] > libbpf: failed to load object 'cgrp_kfunc_failure' > > > But let me try rebuilding everything.. > > > --- > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c > index b3be5742d6f1..078b207af7f0 100644 > --- a/kernel/bpf/helpers.c > +++ b/kernel/bpf/helpers.c > @@ -2145,10 +2145,11 @@ __bpf_kfunc struct task_struct *bpf_task_acquire(= struct task_struct *p) > * bpf_task_release - Release the reference acquired on a task. > * @p: The task on which a reference is being released. > */ > -__bpf_kfunc void bpf_task_release(struct task_struct *p) > +__bpf_kfunc void bpf_task_release(void *p) Yeah. That won't work. We need a wrapper. Since bpf prog is also calling it directly. In progs/task_kfunc_common.h void bpf_task_release(struct task_struct *p) __ksym; than later both libbpf and the verifier check that what bpf prog is calling actually matches the proto of what is in the kernel. Effectively we're doing strong prototype check at load time. btw instead of EXPORT_SYMBOL_GPL(bpf_task_release) can __ADDRESSABLE be used ? Since it's not an export symbol.