]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Cover negative buffer pointer offsets
authorSun Jian <sun.jian.kdev@gmail.com>
Tue, 14 Jul 2026 09:38:46 +0000 (02:38 -0700)
committerEduard Zingerman <eddyz87@gmail.com>
Wed, 15 Jul 2026 09:33:18 +0000 (02:33 -0700)
commit6f59deb32efa4673fc3b1fef9f3a0da48e9d8494
treef6673d2ceae4a0fb17bdfcb26a5de8b0a32bdcd2
parentfd4cfa8c8f9a17cdec0539334d28754bc1d8a5d9
selftests/bpf: Cover negative buffer pointer offsets

Add verifier coverage for constant negative offsets on PTR_TO_TP_BUFFER
and PTR_TO_BUF pointers. Both programs adjust the buffer pointer by -8
and access it at offset zero, so the negative effective start must be
rejected at load time.

Switch the raw tracepoint writable attach checks from nbd_send_request
to bpf_testmod_test_writable_bare_tp, avoiding a dependency on the NBD
tracepoint. Keep the existing past-end case and add a case with a
negative var_off compensated by a positive instruction offset. The
effective start remains non-negative, so the program loads, but its
access end exceeds the writable context size and
bpf_raw_tracepoint_open() must return -EINVAL.

Cc: stable@vger.kernel.org # 5.2.0
Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Link: https://patch.msgid.link/20260714093846.18159-3-sun.jian.kdev@gmail.com
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
tools/testing/selftests/bpf/prog_tests/raw_tp_writable_reject_bad_access.c [new file with mode: 0644]
tools/testing/selftests/bpf/prog_tests/raw_tp_writable_reject_nbd_invalid.c [deleted file]
tools/testing/selftests/bpf/prog_tests/verifier.c
tools/testing/selftests/bpf/progs/verifier_ptr_to_buf.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/verifier_raw_tp_writable.c