From: sashiko-bot@kernel.org
To: "Yiyang Chen" <chenyy23@mails.tsinghua.edu.cn>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v5 1/2] bpf: Fix packet pointer invalidation for skb dynptr writes
Date: Mon, 15 Jun 2026 22:10:04 +0000 [thread overview]
Message-ID: <20260615221005.A070B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <fe46367f8e2c2ae81e626e71d200dbfc3e7d644f.1781539814.git.chenyy23@mails.tsinghua.edu.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Use-After-Free due to lost packet-ness for ARG_PTR_TO_MEM in global subprograms
--
commit 92dda8a7f4645930c007cf11da0767480bfbc820
Author: Yiyang Chen <chenyy23@mails.tsinghua.edu.cn>
bpf: Fix packet pointer invalidation for skb dynptr writes
This commit fixes a missing packet pointer invalidation bug for skb dynptrs.
It adds conservative static CFG predicates to track when global subprograms
might modify packet data through dynptrs, ensuring proper caller-side
invalidation.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
[ ... ]
> @@ -18763,6 +18875,7 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
> } else if (arg->arg_type == (ARG_PTR_TO_DYNPTR | MEM_RDONLY)) {
> /* assume unspecial LOCAL dynptr type */
> __mark_dynptr_reg(reg, BPF_DYNPTR_TYPE_LOCAL, true, ++env->id_gen);
> + reg->dynptr.may_be_pkt_data = true;
> } else if (base_type(arg->arg_type) == ARG_PTR_TO_MEM) {
> reg->type = PTR_TO_MEM;
> reg->type |= arg->arg_type &
[Severity: Critical]
This is a pre-existing issue, but does this generic memory pointer need
similar packet-ness tracking to prevent a use-after-free regression?
When a global subprogram expects a pointer to a sized type, it is
categorized as ARG_PTR_TO_MEM. The caller might pass a direct packet
pointer or a packet-backed dynptr slice, which is allowed if bounds checks
are satisfied.
Because the register state is zero-initialized and not explicitly updated
here, the dynptr_may_be_pkt_data flag remains false. If the subprogram
then calls a packet-reallocating helper like bpf_xdp_adjust_head(), the
clear_all_pkt_pointers() routine might fail to invalidate this register
since reg_is_dynptr_slice_pkt() would return false.
Can the subprogram then continue to access the reallocated and freed packet
memory?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1781539813.git.chenyy23@mails.tsinghua.edu.cn?part=1
next prev parent reply other threads:[~2026-06-15 22:10 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 12:28 [PATCH bpf v2 0/2] bpf: Fix packet pointer invalidation for skb dynptr writes Yiyang Chen
2026-06-15 12:28 ` [PATCH bpf v2 1/2] " Yiyang Chen
2026-06-15 12:53 ` sashiko-bot
2026-06-15 12:28 ` [PATCH bpf v2 2/2] selftests/bpf: Add skb dynptr writer packet invalidation tests Yiyang Chen
2026-06-15 14:14 ` [PATCH bpf v3 0/2] bpf: Fix packet pointer invalidation for skb dynptr writes Yiyang Chen
2026-06-15 14:14 ` [PATCH bpf v3 1/2] " Yiyang Chen
2026-06-15 14:35 ` sashiko-bot
2026-06-15 15:52 ` Alexei Starovoitov
2026-06-15 16:46 ` Yiyang Chen
2026-06-15 17:30 ` Alexei Starovoitov
2026-06-15 17:59 ` Yiyang Chen
2026-06-15 14:14 ` [PATCH bpf v3 2/2] selftests/bpf: Add skb dynptr writer packet invalidation tests Yiyang Chen
2026-06-15 15:15 ` [PATCH bpf v4 0/2] bpf: Fix packet pointer invalidation for skb dynptr writes Yiyang Chen
2026-06-15 15:15 ` [PATCH bpf v4 1/2] " Yiyang Chen
2026-06-15 15:39 ` sashiko-bot
2026-06-15 15:15 ` [PATCH bpf v4 2/2] selftests/bpf: Add skb dynptr writer packet invalidation tests Yiyang Chen
2026-06-15 16:26 ` bot+bpf-ci
2026-06-15 17:49 ` [PATCH bpf v5 0/2] bpf: Fix packet pointer invalidation for skb dynptr writes Yiyang Chen
2026-06-15 17:49 ` [PATCH bpf v5 1/2] " Yiyang Chen
2026-06-15 17:52 ` Alexei Starovoitov
2026-06-15 22:10 ` sashiko-bot [this message]
2026-06-15 17:49 ` [PATCH bpf v5 2/2] selftests/bpf: Add skb dynptr writer packet invalidation tests Yiyang Chen
2026-06-15 18:39 ` bot+bpf-ci
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=20260615221005.A070B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenyy23@mails.tsinghua.edu.cn \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox