Skip to contentSkip to conversation

selftests/bpf: Add test for sleepable lsm_cgroup rejection

PATCH Applied David Windsor 3 participants 3 messages Jun 11 – Jun 15

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: Add test for sleepable lsm_cgroup rejection

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").

---
 tools/testing/selftests/bpf/progs/verifier_lsm.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/testing/selftests/bpf/progs/verifier_lsm.c +9 -0
index 38e8e9176862..2f8103bfa14e 100644
@@ -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";

base-commit: 30dee2c176e7954f63d1fa3e52d172f30beb9bfb

Signature · 1 line
2.53.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · David Windsor

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").

Quoted 24 lines
---
 tools/testing/selftests/bpf/progs/verifier_lsm.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/testing/selftests/bpf/progs/verifier_lsm.c +9 -0
index 38e8e9176862..2f8103bfa14e 100644
@@ -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";

base-commit: 30dee2c176e7954f63d1fa3e52d172f30beb9bfb

#2 lore raw
In reply to David Windsor
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Quoted 10 lines · On Thu, 11 Jun 2026 10:35:49 -0400 you wrote:

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").

---
 tools/testing/selftests/bpf/progs/verifier_lsm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

[...]

Here is the summary with links:
- selftests/bpf: Add test for sleepable lsm_cgroup rejection

    https://git.kernel.org/bpf/bpf-next/c/05ae621d4e3c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html