Skip to content

Commit

Permalink
perf/core: Need CAP_SYS_ADMIN to create k/uprobe with perf_event_open()
Browse files Browse the repository at this point in the history
Non-root user cannot create kprobe or uprobe through the text-based
interface (kprobe_events, uprobe_events),so they should not be able
to create probes via perf_event_open() either.

Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Song Liu <songliubraving@fb.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 33ea4b2 ("perf/core: Implement the 'perf_uprobe' PMU")
Fixes: e12f03d ("perf/core: Implement the 'perf_kprobe' PMU")
Link: http://lkml.kernel.org/r/C0B2EFB5-C403-4BDB-9046-C14B3EE66999@fb.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
liu-song-6 authored and Ingo Molnar committed Apr 12, 2018
1 parent 50268a3 commit 32e6e96
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -8400,6 +8400,10 @@ static int perf_kprobe_event_init(struct perf_event *event)

if (event->attr.type != perf_kprobe.type)
return -ENOENT;

if (!capable(CAP_SYS_ADMIN))
return -EACCES;

/*
* no branch sampling for probe events
*/
Expand Down Expand Up @@ -8437,6 +8441,10 @@ static int perf_uprobe_event_init(struct perf_event *event)

if (event->attr.type != perf_uprobe.type)
return -ENOENT;

if (!capable(CAP_SYS_ADMIN))
return -EACCES;

/*
* no branch sampling for probe events
*/
Expand Down

0 comments on commit 32e6e96

Please sign in to comment.