]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: add test for nullable PTR_TO_BUF access
authorQi Tang <tpluszz77@gmail.com>
Tue, 7 Apr 2026 14:54:21 +0000 (22:54 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 7 Apr 2026 22:53:45 +0000 (15:53 -0700)
commita4985a1755ec9e5aa5cfb89468ba4b51546b5eeb
tree93b6e994639f1877730fe7e46b2bc4a0030477ac
parent57b23c0f612dcfa1aae99c9422d6d36ced1670d4
selftests/bpf: add test for nullable PTR_TO_BUF access

Add iter_buf_null_fail with two tests and a test runner:
  - iter_buf_null_deref: verifier must reject direct dereference of
    ctx->key (PTR_TO_BUF | PTR_MAYBE_NULL) without a null check
  - iter_buf_null_check_ok: verifier must accept dereference after
    an explicit null check

Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Reviewed-by: Amery Hung <ameryhung@gmail.com>
Signed-off-by: Qi Tang <tpluszz77@gmail.com>
Link: https://lore.kernel.org/r/20260407145421.4315-1-tpluszz77@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/iter_buf_null_fail.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/iter_buf_null_fail.c [new file with mode: 0644]