]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Use bpf_dynptr_slice() to read file dynptr in leak test
authorAmery Hung <ameryhung@gmail.com>
Fri, 5 Jun 2026 20:20:56 +0000 (13:20 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 5 Jun 2026 21:18:20 +0000 (14:18 -0700)
commitd83d4f63cb8f92aa6254dfc001eac0e41f5b2c35
treed239e1b512469d86914ff0913f6e1361d153d052
parentac7f6c9da6b6b46bba34a45c51603c81e7d42eb2
selftests/bpf: Use bpf_dynptr_slice() to read file dynptr in leak test

use_file_dynptr_slice_after_put_file() reads the dynptr via
bpf_dynptr_data(), which always returns NULL for a read-only file
dynptr, making the example confusing. Switch to bpf_dynptr_slice(), the
correct read API for file dynptrs, and read (rather than write) the slice
since it is read-only. The test still fails as expected.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Amery Hung <ameryhung@gmail.com>
Link: https://lore.kernel.org/r/20260605202056.1780352-6-ameryhung@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/file_reader_fail.c