]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf: Revert to requiring CAP_SYS_ADMIN for uprobes
authorPeter Zijlstra <peterz@infradead.org>
Wed, 2 Jul 2025 16:21:44 +0000 (18:21 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 3 Jul 2025 08:33:55 +0000 (10:33 +0200)
Jann reports that uprobes can be used destructively when used in the
middle of an instruction. The kernel only verifies there is a valid
instruction at the requested offset, but due to variable instruction
length cannot determine if this is an instruction as seen by the
intended execution stream.

Additionally, Mark Rutland notes that on architectures that mix data
in the text segment (like arm64), a similar things can be done if the
data word is 'mistaken' for an instruction.

As such, require CAP_SYS_ADMIN for uprobes.

Fixes: c9e0924e5c2b ("perf/core: open access to probes for CAP_PERFMON privileged process")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/CAG48ez1n4520sq0XrWYDHKiKxE_+WCfAK+qt9qkY4ZiBGmL-5g@mail.gmail.com
kernel/events/core.c

index bf2118c2212663040b39857c0f6d9ccfe258d295..0db36b2b2448a862acb2ba71aaa04525d7d801ba 100644 (file)
@@ -11116,7 +11116,7 @@ static int perf_uprobe_event_init(struct perf_event *event)
        if (event->attr.type != perf_uprobe.type)
                return -ENOENT;
 
-       if (!perfmon_capable())
+       if (!capable(CAP_SYS_ADMIN))
                return -EACCES;
 
        /*