BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xu Yunxiang" <xyx2021@mail.ustc.edu.cn>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 6.12.y v2 2/2] bpf: Invalidate dynptr clones in every call frame on release
Date: Sat, 29 Aug 2026 04:01:10 +0000	[thread overview]
Message-ID: <20260829040110.D6A991F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260829033725.2365697-3-xyx2021@mail.ustc.edu.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] User-triggerable WARN_ON_ONCE in verifier via cross-frame dynptr release in callbacks, leading to local DoS.
--

commit 47e1f4599f52a8453ee0613fbb7c12af9d40d361
Author: Amery Hung <ameryhung@gmail.com>

bpf: Invalidate dynptr clones in every call frame on release

This patch modifies dynptr release handling to invalidate clones across all
call frames instead of only the submitting pointer's frame. It fixes an
issue where a caller's dynptr slot would not be cleared if a clone was
released in a subprogram.

Link: https://lore.kernel.org/r/20260529014936.2811085-6-ameryhung@gmail.com

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 5d0874a09a8db..9f314360551f8 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
[ ... ]
> @@ -841,22 +841,31 @@ static int unmark_stack_slots_dynptr(struct bpf_verifier_env *env, struct bpf_re
>  	WARN_ON_ONCE(release_reference(env, ref_obj_id));

[Severity: High]
This is a pre-existing issue, but can an unprivileged user trigger this
warning intentionally by releasing a caller's reference from within a
callback?

If a program acquires a refcounted dynptr in a caller frame, passes a
pointer to it into a synchronous callback (such as via a bpf_loop context),
and calls a release helper like bpf_ringbuf_submit_dynptr() from inside
the callback, the initial helper validation succeeds since the dynptr is
valid on the caller's stack. This subsequently invokes
unmark_stack_slots_dynptr().

However, release_reference() calls release_reference_state(), which explicitly
checks if it is inside a callback trying to release a caller's reference.
Since callbacks cannot release caller references, it correctly fails and
returns -EINVAL.

This predictable -EINVAL return unconditionally triggers the WARN_ON_ONCE.
If panic_on_warn is enabled, could this allow a local user to intentionally
crash the kernel during program verification?

>  	invalidate_slices_of_dynptr(env, state->stack[spi].spilled_ptr.id);
>  
> -	/* Invalidate any dynptr clones */
> -	for (i = 1; i < state->allocated_stack / BPF_REG_SIZE; i++) {
> -		if (state->stack[i].spilled_ptr.ref_obj_id != ref_obj_id)
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260829033725.2365697-1-xyx2021@mail.ustc.edu.cn?part=2

  reply	other threads:[~2026-08-29  4:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29  3:37 [PATCH 6.12.y v2 0/2] bpf: fix dynptr lifetime invalidation on release Xu Yunxiang
2026-08-29  3:37 ` [PATCH 6.12.y v2 1/2] bpf: Invalidate dynptr slices by dynptr_id " Xu Yunxiang
2026-08-29  3:56   ` sashiko-bot
2026-08-29  3:37 ` [PATCH 6.12.y v2 2/2] bpf: Invalidate dynptr clones in every call frame " Xu Yunxiang
2026-08-29  4:01   ` sashiko-bot [this message]
2026-08-29 10:26 ` [PATCH 6.12.y v3 0/3] bpf: fix dynptr release handling Xu Yunxiang
2026-08-29 10:26   ` [PATCH 6.12.y v3 1/3] bpf: Invalidate dynptr slices by dynptr_id on release Xu Yunxiang
2026-08-29 10:26   ` [PATCH 6.12.y v3 2/3] bpf: Propagate referenced dynptr release errors Xu Yunxiang
2026-08-29 10:48     ` sashiko-bot
2026-08-29 10:26   ` [PATCH 6.12.y v3 3/3] bpf: Invalidate dynptr clones in every call frame on release Xu Yunxiang

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=20260829040110.D6A991F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xyx2021@mail.ustc.edu.cn \
    /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