mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf v2 0/2] bpf: Fix packet pointer invalidation for skb dynptr writes
@ 2026-06-15 12:28 Yiyang Chen
  2026-06-15 12:28 ` [PATCH bpf v2 1/2] " Yiyang Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Yiyang Chen @ 2026-06-15 12:28 UTC (permalink / raw)
  To: bpf
  Cc: Yiyang Chen, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, John Fastabend, Shuah Khan, linux-kselftest,
	linux-kernel

skb-backed dynptr writer kfuncs can mutate skb packet data.
The verifier does not currently treat those kfuncs as packet-changing.
A direct packet pointer checked before the call can stay usable after the
write.

bpf_dynptr_write() already clears packet pointers through the helper path.
Teach kfunc argument checking to do the same for skb and skb-meta dynptr
destinations.
Keep source-only dynptr arguments unchanged.

Validation:

  Without this series:
    linux-stable-v7.0.12 accepts the three stale packet pointer cases;
    linux-mainline-v7.1-rc7 accepts the three stale packet pointer cases;
    the source-only bpf_dynptr_copy() control loads on both kernels.

  With this series applied:
    patched bpf-next rejects the three stale packet pointer cases with
    "invalid mem access 'scalar'";
    the source-only bpf_dynptr_copy() control still loads.

  Build and style checks:
    git diff --check: OK
    checkpatch.pl --strict --no-tree: OK
    make O=$BUILD kernel/bpf/verifier.o: OK
    make O=$BUILD -j$(nproc) bzImage: OK
    dynptr_fail.bpf.o build against patched vmlinux BTF: OK

Signed-off-by: Yiyang Chen <chenyy23@mails.tsinghua.edu.cn>
---

Changes in v2:
  - Resend as a properly threaded series. No code changes.

Yiyang Chen (2):
  bpf: Fix packet pointer invalidation for skb dynptr writes
  selftests/bpf: Add skb dynptr writer packet invalidation tests

 include/linux/bpf_verifier.h                  |  1 +
 kernel/bpf/verifier.c                         | 62 ++++++++++++-
 .../testing/selftests/bpf/progs/dynptr_fail.c | 89 +++++++++++++++++++
 3 files changed, 151 insertions(+), 1 deletion(-)


base-commit: e4287bf34f97a88c7d9322f5bde828724c073a6b
-- 
2.34.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-06-15 18:39 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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: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 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: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 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®