* [PATCH 7.1.y v2] selftests/bpf: Add tests for sleepable tracepoint programs
@ 2026-08-07 12:32 Ricardo B. Marlière (SUSE)
2026-08-07 13:07 ` sashiko-bot
2026-08-07 13:50 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Ricardo B. Marlière (SUSE) @ 2026-08-07 12:32 UTC (permalink / raw)
To: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
Daniel Borkmann, Martin KaFai Lau, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, sashal, gregkh
Cc: bpf, linux-kselftest, linux-kernel, stable, Mykyta Yatsenko
From: Mykyta Yatsenko <yatsenko@meta.com>
[ 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 <yatsenko@meta.com>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/bpf/20260422-sleepable_tracepoints-v13-6-99005dff21ef@meta.com
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
Changes in v2:
- Dropped hunks which miss dependencies
- Added a small note about it in the commit
- Link to v1: https://patch.msgid.link/20260805-selftests-bpf-sleepable-v1-1-e29fa5af4119@marliere.net
---
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) <ricardo@marliere.net>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 7.1.y v2] selftests/bpf: Add tests for sleepable tracepoint programs
2026-08-07 12:32 [PATCH 7.1.y v2] selftests/bpf: Add tests for sleepable tracepoint programs Ricardo B. Marlière (SUSE)
@ 2026-08-07 13:07 ` sashiko-bot
2026-08-07 13:50 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-08-07 13:07 UTC (permalink / raw)
To: Ricardo B. Marlière (SUSE); +Cc: bpf
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Test codifies a critical kernel crash bug due to incomplete backport of sleepable tracepoint support
--
--- Patch [1]: [PATCH 7.1.y v2] selftests/bpf: Add tests for sleepable tracepoint programs ---
commit d01560ee1bdaeec333977b1890fc06598668aa9f
Author: Mykyta Yatsenko <yatsenko@meta.com>
selftests/bpf: Add tests for sleepable tracepoint programs
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.
Link: https://lore.kernel.org/bpf/20260422-sleepable_tracepoints-v13-6-99005dff21ef@meta.com
> diff --git a/tools/testing/selftests/bpf/verifier/sleepable.c b/tools/testing/selftests/bpf/verifier/sleepable.c
> index c2b7f5ebf168c..6dabc55229455 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,
> +},
[Severity: Critical]
This is a pre-existing issue, but does this test codify a kernel crash bug
in the baseline tree?
The commit message notes that kernel-side sleepable tracepoint runtime support
was not backported here. Because of an earlier backport, the verifier
currently accepts sleepable raw tracepoints if tracepoint_is_faultable() is
true (like sys_enter), which makes this verifier test pass.
However, without the runtime support, the execution happens unconditionally
under atomic contexts. For example, in __bpf_trace_run():
kernel/trace/bpf_trace.c:__bpf_trace_run() {
...
rcu_read_lock_dont_migrate();
...
}
Or via the tracepoint wrapper:
include/trace/bpf_probe.h:__BPF_DECLARE_TRACE_SYSCALL() {
...
preempt_disable_notrace();
...
}
If a sleepable program is attached to this tracepoint and actually sleeps, it
will trigger a scheduling while atomic panic.
Should this test be removed or adjusted until the runtime support is fully
backported to prevent asserting this unsafe verifier state?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260807-selftests-bpf-sleepable-v2-1-f7e6566f36a1@marliere.net?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 7.1.y v2] selftests/bpf: Add tests for sleepable tracepoint programs
2026-08-07 12:32 [PATCH 7.1.y v2] selftests/bpf: Add tests for sleepable tracepoint programs Ricardo B. Marlière (SUSE)
2026-08-07 13:07 ` sashiko-bot
@ 2026-08-07 13:50 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-08-07 13:50 UTC (permalink / raw)
To: Ricardo B. Marlière (SUSE)
Cc: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
Daniel Borkmann, Martin KaFai Lau, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, sashal, bpf,
linux-kselftest, linux-kernel, stable, Mykyta Yatsenko
On Fri, Aug 07, 2026 at 09:32:43AM -0300, Ricardo B. Marlière (SUSE) wrote:
> From: Mykyta Yatsenko <yatsenko@meta.com>
>
> [ 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 <yatsenko@meta.com>
> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> Link: https://lore.kernel.org/bpf/20260422-sleepable_tracepoints-v13-6-99005dff21ef@meta.com
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
You did not sign off on this :(
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-07 13:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 12:32 [PATCH 7.1.y v2] selftests/bpf: Add tests for sleepable tracepoint programs Ricardo B. Marlière (SUSE)
2026-08-07 13:07 ` sashiko-bot
2026-08-07 13:50 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox