From: Mykyta Yatsenko <[email protected]>
[ Upstream commit 8a20655749c625dcc4debdfdeeaa0cf8bb85c203 ]
Cover all three sleepable tracepoint types (tp_btf.s, raw_tp.s, tp.s)
and sys_exit (via bpf_task_pt_regs) with functional tests using
bpf_copy_from_user() on getcwd. Verify alias and bare SEC variants,
bpf_prog_test_run_raw_tp() with BPF_F_TEST_RUN_ON_CPU rejection,
attach-time rejection on non-faultable tracepoints, and load-time
rejection for sleepable tp_btf on non-faultable tracepoints.
[ rbm: Removed hunks from (new) files:
tools/testing/selftests/bpf/prog_tests/sleepable_tracepoints.c
tools/testing/selftests/bpf/progs/test_sleepable_tracepoints.c
tools/testing/selftests/bpf/progs/test_sleepable_tracepoints_fail.c
These rely on libbpf's ".s" tracepoint section handlers
(0cd420a6f40c7) and on kernel-side sleepable tracepoint runtime
support (439ebd5b5708, 12628ffaf98b, 57918341dd19), none of which
are backported here; kept only the verifier/sleepable.c hunk, which
is correct and needed on its own. ]
Signed-off-by: Mykyta Yatsenko <[email protected]>
Acked-by: Kumar Kartikeya Dwivedi <[email protected]>
Link:
https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]>
---
Changes in v2:
- Dropped hunks which miss dependencies
- Added a small note about it in the commit
- Link to v1:
https://patch.msgid.link/[email protected]
---
tools/testing/selftests/bpf/verifier/sleepable.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/verifier/sleepable.c
b/tools/testing/selftests/bpf/verifier/sleepable.c
index c2b7f5ebf168..6dabc5522945 100644
--- a/tools/testing/selftests/bpf/verifier/sleepable.c
+++ b/tools/testing/selftests/bpf/verifier/sleepable.c
@@ -76,7 +76,20 @@
.runs = -1,
},
{
- "sleepable raw tracepoint reject",
+ "sleepable raw tracepoint accept",
+ .insns = {
+ BPF_MOV64_IMM(BPF_REG_0, 0),
+ BPF_EXIT_INSN(),
+ },
+ .prog_type = BPF_PROG_TYPE_TRACING,
+ .expected_attach_type = BPF_TRACE_RAW_TP,
+ .kfunc = "sys_enter",
+ .result = ACCEPT,
+ .flags = BPF_F_SLEEPABLE,
+ .runs = -1,
+},
+{
+ "sleepable raw tracepoint reject non-faultable",
.insns = {
BPF_MOV64_IMM(BPF_REG_0, 0),
BPF_EXIT_INSN(),
@@ -85,7 +98,7 @@
.expected_attach_type = BPF_TRACE_RAW_TP,
.kfunc = "sched_switch",
.result = REJECT,
- .errstr = "Only fentry/fexit/fsession/fmod_ret, lsm, iter, uprobe, and
struct_ops programs can be sleepable",
+ .errstr = "Sleepable program cannot attach to non-faultable tracepoint",
.flags = BPF_F_SLEEPABLE,
.runs = -1,
},
---
base-commit: 74b69060ba6e44e20c2e4dc1847eca21db6e4a7c
change-id: 20260803-selftests-bpf-sleepable-eebf2d962201
Best regards,
--
Ricardo B. Marlière (SUSE) <[email protected]>