]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/bpf: add test case for BPF LSM hook bpf_lsm_mmap_file
authorMatt Bobrowski <mattbobrowski@google.com>
Tue, 16 Dec 2025 13:30:00 +0000 (13:30 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 21 Dec 2025 18:56:33 +0000 (10:56 -0800)
commitd2749ae85aec685e52e0474f445f6a8552363eb0
treebc0b2d7d12c2dcd83e1e3edaa9a75310834eb3e2
parent94e948b7e684c0465bb3faca8fafee5caf421b84
selftests/bpf: add test case for BPF LSM hook bpf_lsm_mmap_file

Add a trivial test case asserting that the BPF verifier enforces
PTR_MAYBE_NULL semantics on the struct file pointer argument of BPF
LSM hook bpf_lsm_mmap_file().

Dereferencing the struct file pointer passed into bpf_lsm_mmap_file()
without explicitly performing a NULL check first should not be
permitted by the BPF verifier as it can lead to NULL pointer
dereferences and a kernel crash.

Signed-off-by: Matt Bobrowski <mattbobrowski@google.com>
Acked-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20251216133000.3690723-2-mattbobrowski@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/verifier_lsm.c