From: Mykyta Yatsenko Add an attach-time check in bpf_raw_tp_link_attach() to ensure that sleepable BPF programs can only attach to faultable tracepoints. Faultable tracepoints (e.g., sys_enter, sys_exit) are guaranteed to run in a context where sleeping is safe, using rcu_tasks_trace for protection. Non-faultable tracepoints may run in NMI or other non-sleepable contexts. This complements the verifier-side change that allows BPF_TRACE_RAW_TP programs to be loaded as sleepable. Signed-off-by: Mykyta Yatsenko --- kernel/bpf/syscall.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index dd89bf809772501c109789b39dd5f58f688354e2..af6c93d332fb70a8a14d7768048000b0b7f34650 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -4261,6 +4261,11 @@ static int bpf_raw_tp_link_attach(struct bpf_prog *prog, if (!btp) return -ENOENT; + if (prog->sleepable && !tracepoint_is_faultable(btp->tp)) { + err = -EINVAL; + goto out_put_btp; + } + link = kzalloc(sizeof(*link), GFP_USER); if (!link) { err = -ENOMEM; -- 2.53.0