]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/bpf: Test kfuncs that set and remove xattr from BPF programs
authorSong Liu <song@kernel.org>
Thu, 30 Jan 2025 21:35:49 +0000 (13:35 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 14 Feb 2025 03:35:32 +0000 (19:35 -0800)
commit60c2e1fa9168644db157665a44982861aa67dbef
tree0eee579fa9aabf4327140d49854d538b0cf1487d
parent56467292794b800164df20c076c409ac548e56ec
selftests/bpf: Test kfuncs that set and remove xattr from BPF programs

Two sets of tests are added to exercise the not _locked and _locked
version of the kfuncs. For both tests, user space accesses xattr
security.bpf.foo on a testfile. The BPF program is triggered by user
space access (on LSM hook inode_[set|get]_xattr) and sets or removes
xattr security.bpf.bar. Then user space then validates that xattr
security.bpf.bar is set or removed as expected.

Note that, in both tests, the BPF programs use the not _locked kfuncs.
The verifier picks the proper kfuncs based on the calling context.

Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20250130213549.3353349-6-song@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/bpf_kfuncs.h
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
tools/testing/selftests/bpf/progs/test_set_remove_xattr.c [new file with mode: 0644]