]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/bpf: Add test for sleepable lsm_cgroup rejection
authorDavid Windsor <dwindsor@gmail.com>
Thu, 11 Jun 2026 14:35:49 +0000 (10:35 -0400)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 15 Jun 2026 02:39:41 +0000 (19:39 -0700)
Confirm the verifier rejects loading a sleepable BPF_LSM_CGROUP program,
as introduced in commit 5b038319be44 ("bpf: Reject sleepable
BPF_LSM_CGROUP programs at load time").

Signed-off-by: David Windsor <dwindsor@gmail.com>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Link: https://lore.kernel.org/r/20260611143549.703914-1-dwindsor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/verifier_lsm.c

index 38e8e91768620deb7517442d5eac77dba507a9e8..2f8103bfa14e5af4838e50d4d03bc076b93b0a8b 100644 (file)
@@ -188,4 +188,13 @@ int BPF_PROG(null_check, struct file *file)
        return 0;
 }
 
+SEC("lsm_cgroup/file_open")
+__description("sleepable lsm_cgroup program is rejected")
+__failure __msg("Program of this type cannot be sleepable")
+__flag(BPF_F_SLEEPABLE)
+int BPF_PROG(sleepable_lsm_cgroup)
+{
+       return 0;
+}
+
 char _license[] SEC("license") = "GPL";