Skip to content

Commit 32e6e96

Browse files
liu-song-6Ingo Molnar
authored andcommitted
perf/core: Need CAP_SYS_ADMIN to create k/uprobe with perf_event_open()
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 <[email protected]> Signed-off-by: Song Liu <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Fixes: 33ea4b2 ("perf/core: Implement the 'perf_uprobe' PMU") Fixes: e12f03d ("perf/core: Implement the 'perf_kprobe' PMU") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 50268a3 commit 32e6e96

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/events/core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8400,6 +8400,10 @@ static int perf_kprobe_event_init(struct perf_event *event)
84008400

84018401
if (event->attr.type != perf_kprobe.type)
84028402
return -ENOENT;
8403+
8404+
if (!capable(CAP_SYS_ADMIN))
8405+
return -EACCES;
8406+
84038407
/*
84048408
* no branch sampling for probe events
84058409
*/
@@ -8437,6 +8441,10 @@ static int perf_uprobe_event_init(struct perf_event *event)
84378441

84388442
if (event->attr.type != perf_uprobe.type)
84398443
return -ENOENT;
8444+
8445+
if (!capable(CAP_SYS_ADMIN))
8446+
return -EACCES;
8447+
84408448
/*
84418449
* no branch sampling for probe events
84428450
*/

0 commit comments

Comments
 (0)