bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Puranjay Mohan <puranjay@kernel.org>
To: bpf@vger.kernel.org
Cc: Puranjay Mohan <puranjay@kernel.org>,
	Puranjay Mohan <puranjay12@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	kernel-team@meta.com
Subject: [PATCH bpf-next v3 08/10] selftests: bpf: fix test_kfunc_dynptr_param
Date: Fri,  2 Jan 2026 10:00:34 -0800	[thread overview]
Message-ID: <20260102180038.2708325-9-puranjay@kernel.org> (raw)
In-Reply-To: <20260102180038.2708325-1-puranjay@kernel.org>

As verifier now assumes that all kfuncs only takes trusted pointer
arguments, passing 0 (NULL) to a kfunc that doesn't mark the argument as
__nullable or __opt will be rejected with a failure message of: Possibly
NULL pointer passed to trusted arg<n>

Pass a non-null value to the kfunc to test the expected failure mode.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
---
 tools/testing/selftests/bpf/progs/test_kfunc_dynptr_param.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/test_kfunc_dynptr_param.c b/tools/testing/selftests/bpf/progs/test_kfunc_dynptr_param.c
index 061befb004c2..d249113ed657 100644
--- a/tools/testing/selftests/bpf/progs/test_kfunc_dynptr_param.c
+++ b/tools/testing/selftests/bpf/progs/test_kfunc_dynptr_param.c
@@ -48,10 +48,9 @@ SEC("?lsm.s/bpf")
 __failure __msg("arg#0 expected pointer to stack or const struct bpf_dynptr")
 int BPF_PROG(not_ptr_to_stack, int cmd, union bpf_attr *attr, unsigned int size, bool kernel)
 {
-	unsigned long val = 0;
+	static struct bpf_dynptr val;
 
-	return bpf_verify_pkcs7_signature((struct bpf_dynptr *)val,
-					  (struct bpf_dynptr *)val, NULL);
+	return bpf_verify_pkcs7_signature(&val, &val, NULL);
 }
 
 SEC("lsm.s/bpf")
-- 
2.47.3


  parent reply	other threads:[~2026-01-02 18:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-02 18:00 [PATCH bpf-next v3 00/10] bpf: Make KF_TRUSTED_ARGS default Puranjay Mohan
2026-01-02 18:00 ` [PATCH bpf-next v3 01/10] bpf: Make KF_TRUSTED_ARGS the default for all kfuncs Puranjay Mohan
2026-01-02 18:00 ` [PATCH bpf-next v3 02/10] bpf: Remove redundant KF_TRUSTED_ARGS flag from " Puranjay Mohan
2026-01-02 18:00 ` [PATCH bpf-next v3 03/10] bpf: net: netfilter: drop dead NULL checks Puranjay Mohan
2026-01-02 18:00 ` [PATCH bpf-next v3 04/10] bpf: xfrm: drop dead NULL check in bpf_xdp_get_xfrm_state() Puranjay Mohan
2026-01-02 18:00 ` [PATCH bpf-next v3 05/10] HID: bpf: drop dead NULL checks in kfuncs Puranjay Mohan
2026-01-02 18:00 ` [PATCH bpf-next v3 06/10] selftests: bpf: Update kfunc_param_nullable test for new error message Puranjay Mohan
2026-01-02 18:00 ` [PATCH bpf-next v3 07/10] selftests: bpf: Update failure message for rbtree_fail Puranjay Mohan
2026-01-02 18:00 ` Puranjay Mohan [this message]
2026-01-02 18:00 ` [PATCH bpf-next v3 09/10] selftests: bpf: fix cgroup_hierarchical_stats Puranjay Mohan
2026-01-02 18:00 ` [PATCH bpf-next v3 10/10] selftests: bpf: Fix test_bpf_nf for trusted args becoming default Puranjay Mohan
2026-01-02 20:20 ` [PATCH bpf-next v3 00/10] bpf: Make KF_TRUSTED_ARGS default patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260102180038.2708325-9-puranjay@kernel.org \
    --to=puranjay@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.com \
    --cc=puranjay12@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).