* [PATCH bpf] bpf: reject override_return programs on uprobe_multi links
@ 2026-11-19 16:41 Sechang Lim
2026-11-24 3:38 ` Alexei Starovoitov
0 siblings, 1 reply; 2+ messages in thread
From: Sechang Lim @ 2026-11-19 16:41 UTC (permalink / raw)
To: bpf
Cc: ast, daniel, andrii, eddyz87, memxor, song, jolsa, rostedt,
mhiramat, linux-trace-kernel, linux-kernel
bpf_override_return() changes pt_regs->ip to the kernel's
just_return_func for kprobe error injection. Perf uprobes reject
programs using this helper, but uprobe_multi links accept them even
though their pt_regs belong to a user task. When the probe runs, the
task returns to user mode with a kernel address as its instruction
pointer, faults, and exposes that address in its signal frame.
Reject programs marked kprobe_override when creating an uprobe_multi
link. This covers both entry and return probes and matches the perf
uprobe restriction.
Fixes: 89ae89f53d20 ("bpf: Add multi uprobe link")
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
---
kernel/trace/bpf_trace.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index d22e78e7f28d..45ff81dbca96 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -3297,6 +3297,9 @@ int bpf_uprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
if (!is_uprobe_multi(prog))
return -EINVAL;
+ if (prog->kprobe_override)
+ return -EINVAL;
+
flags = attr->link_create.uprobe_multi.flags;
if (flags & ~(BPF_F_UPROBE_MULTI_RETURN | BPF_F_UPROBE_MULTI_PATH_FD))
return -EINVAL;
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH bpf] bpf: reject override_return programs on uprobe_multi links
2026-11-19 16:41 [PATCH bpf] bpf: reject override_return programs on uprobe_multi links Sechang Lim
@ 2026-11-24 3:38 ` Alexei Starovoitov
0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2026-11-24 3:38 UTC (permalink / raw)
To: Sechang Lim, bpf
Cc: daniel, andrii, eddyz87, memxor, song, jolsa, rostedt, mhiramat,
linux-trace-kernel, linux-kernel
On Thu, Nov 19, 2026 at 08:41 AM Sechang Lim <rhkrqnwk98@gmail.com> wrote:
> bpf_override_return() changes pt_regs->ip to the kernel's
> just_return_func for kprobe error injection. Perf uprobes reject
> programs using this helper, but uprobe_multi links accept them even
> though their pt_regs belong to a user task. When the probe runs, the
> task returns to user mode with a kernel address as its instruction
> pointer, faults, and exposes that address in its signal frame.
That's not a bug. The prog needs CAP_BPF + CAP_PERFMON.
pw-bot: cr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-24 3:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 16:41 [PATCH bpf] bpf: reject override_return programs on uprobe_multi links Sechang Lim
2026-11-24 3:38 ` Alexei Starovoitov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox