bpf: reject override_return programs on uprobe_multi links
Subsystems (4)
PATCH 1/1 bpf: reject override_return programs on uprobe_multi links
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.
--- kernel/trace/bpf_trace.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/trace/bpf_trace.c +3 -0
@@ -3297,6 +3297,9 @@ int bpf_uprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *prif (!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 ;
Signature · 1 line
2.56.1
Quoted 6 lines · Sechang Lim
bpf_override_return()changespt_regs->ipto the kernel'sjust_return_funcfor kprobe error injection. Perf uprobes reject programs using this helper, butuprobe_multilinks accept them even though theirpt_regsbelong 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