selftests/bpf: Add test for sleepable lsm_cgroup rejection

Confirm the verifier rejects loading a sleepable BPF_LSM_CGROUP program,
as introduced in commit 5b038319be ("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>
This commit is contained in:
David Windsor
2026-06-11 10:35:49 -04:00
committed by Alexei Starovoitov
parent c79536c814
commit 05ae621d4e

View 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";