All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 5/5] selftests/bpf: Cover __uninit kfunc output argument slots
Date: Wed, 16 Sep 2026 16:28:03 +0000	[thread overview]
Message-ID: <20260916162803.99F3E1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916160821.3157543-6-memxor@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] bpf: ineffective test output_passed_on_stack for __uninit tracking
--

commit 70a455597d07423eca32cc332d11faa394e65772
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>

selftests/bpf: Cover __uninit kfunc output argument slots

This commit adds regression tests for the verifier's tracking of __uninit
kfunc output argument slots. It covers cases involving multiple outputs,
outputs following by-value parameters, and output pointers passed on the
stack.

> diff --git a/tools/testing/selftests/bpf/progs/verifier_kfunc_uninit_multi.c b/tools/testing/selftests/bpf/progs/verifier_kfunc_uninit_multi.c
> new file mode 100644
> index 0000000000000..b944346b35e34
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/verifier_kfunc_uninit_multi.c

[ ... ]

> +#if defined(__BPF_FEATURE_STACK_ARGUMENT)
> +SEC("tc")
> +__arch_x86_64 __arch_arm64 __arch_riscv64
> +__success __retval(15)
> +__flag(BPF_F_TEST_STATE_FREQ)
> +__caps_unpriv(CAP_BPF | CAP_NET_ADMIN)
> +__prepare_priv
> +__success_unpriv
> +__naked void output_passed_on_stack(void)
> +{
> +	asm volatile (
> +		"*(u64 *)(r10 - 8) = 0;"
> +		"goto +0;"

[Severity: Medium]
Does pre-initializing the output stack slot here prevent the test from
actually catching __uninit tracking regressions?

If the verifier fails to recognize the __uninit annotation, it treats the
argument as a normal pointer. Because the slot is initialized and kept alive
across the goto +0 checkpoint, the memory is tracked as STACK_ZERO. This
satisfies the BPF_READ requirement in unprivileged mode, allowing the
BPF_WRITE check to clobber the slot to STACK_MISC and verify successfully.

Should this test omit the initialization (similar to how it is done in
output_after_by_value_argument) so that a broken verifier evaluates a
BPF_READ on STACK_INVALID, forcing an expected verification failure in
unprivileged mode?

> +		"r1 = 1;"
> +		"r2 = 2;"
> +		"r3 = 3;"
> +		"r4 = 4;"
> +		"r5 = 5;"
> +		"r6 = r10;"
> +		"r6 += -8;"
> +		"*(u64 *)(r11 - 8) = r6;"
> +		"call %[bpf_kfunc_test_uninit_stack];"
> +		"r0 = *(u32 *)(r10 - 8);"
> +		"exit;"
> +		: : __imm(bpf_kfunc_test_uninit_stack) : __clobber_all);
> +}
> +#endif

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916160821.3157543-1-memxor@gmail.com?part=5

      reply	other threads:[~2026-09-16 16:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 16:08 [PATCH bpf-next v2 0/5] Fix generic __uninit kfunc output buffers Kumar Kartikeya Dwivedi
2026-09-16 16:08 ` [PATCH bpf-next v2 1/5] selftests/bpf: Allow privileged preparation for capability tests Kumar Kartikeya Dwivedi
2026-09-16 16:08 ` [PATCH bpf-next v2 2/5] bpf: Fix generic __uninit kfunc output buffers Kumar Kartikeya Dwivedi
2026-09-16 16:38   ` Amery Hung
2026-09-16 16:08 ` [PATCH bpf-next v2 3/5] selftests/bpf: Cover generic __uninit output initialization Kumar Kartikeya Dwivedi
2026-09-16 16:08 ` [PATCH bpf-next v2 4/5] bpf: Support multiple __uninit kfunc output arguments Kumar Kartikeya Dwivedi
2026-09-16 17:39   ` bot+bpf-ci
2026-09-16 16:08 ` [PATCH bpf-next v2 5/5] selftests/bpf: Cover __uninit kfunc output argument slots Kumar Kartikeya Dwivedi
2026-09-16 16:28   ` sashiko-bot [this message]

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=20260916162803.99F3E1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=memxor@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.