[PATCH bpf v3 0/2] bpf: Reject negative const offsets for buffer pointers
From: Sun Jian
Date: Wed Jul 08 2026 - 00:08:08 EST
Reject negative effective offsets for PTR_TO_TP_BUFFER and PTR_TO_BUF
buffer accesses, and add raw tracepoint writable coverage for both
load-time rejection and the attach-time max_tp_access path.
---
Changes in v3:
- Check constant var_off against +/-BPF_MAX_VAR_OFF before computing
the effective access range, matching the existing verifier pointer
offset convention.
- Keep explicit rejection of negative instruction offsets and keep
bounded negative constant var_off valid when the effective offset is
non-negative.
Changes in v2:
- Split the kernel fix and selftests into separate patches.
- Add an attach-time raw tracepoint writable test that exercises
max_tp_access against nbd_send_request's writable size.
- Adjust selftest formatting to use the 100 character line width.
Tested:
- ./test_progs -t verifier_raw_tp_writable
- ./test_progs -t raw_tp_writable_reject_nbd_invalid -v
- ./test_progs -t raw_tp_writable_test_run
v2: https://lore.kernel.org/bpf/20260707060804.93561-1-sun.jian.kdev@xxxxxxxxx/
v1: https://lore.kernel.org/bpf/20260703035137.109608-1-sun.jian.kdev@xxxxxxxxx/
Sun Jian (2):
bpf: Reject negative const offsets for buffer pointers
selftests/bpf: Cover negative raw_tp writable buffer offsets
kernel/bpf/verifier.c | 48 +++++++++++++--
.../raw_tp_writable_reject_nbd_invalid.c | 58 +++++++++++--------
.../bpf/progs/verifier_raw_tp_writable.c | 16 +++++
3 files changed, 93 insertions(+), 29 deletions(-)
base-commit: 12091470c6b4c1c14b2de12dcbae2ada6cb6d20b
--
2.43.0