Thread (9 messages) flat view 9 messages, 6 authors, 2025-03-06

Re: [PATCHv3 perf/core] uprobes: Harden uretprobe syscall trampoline check

From: Andy Lutomirski <luto@kernel.org>
Date: 2025-02-13 01:37:24
Also in: bpf, linux-api, lkml, stable

On Wed, Feb 12, 2025 at 2:04 PM Jiri Olsa [off-list ref] wrote:
Jann reported [1] possible issue when trampoline_check_ip returns
address near the bottom of the address space that is allowed to
call into the syscall if uretprobes are not set up.

Though the mmap minimum address restrictions will typically prevent
creating mappings there, let's make sure uretprobe syscall checks
for that.
It would be a layering violation, but we could perhaps do better here:
-       if (regs->ip != trampoline_check_ip())
+       /* Make sure the ip matches the only allowed sys_uretprobe caller. */
+       if (unlikely(regs->ip != trampoline_check_ip(tramp)))
                goto sigill;
Instead of SIGILL, perhaps this should do the seccomp action?  So the
logic in seccomp would be (sketchily, with some real mode1 mess):

if (is_a_real_uretprobe())
    skip seccomp;

where is_a_real_uretprobe() is only true if the nr and arch match
uretprobe *and* the address is right.

--Andy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help