diff options
author | Song Liu <songliubraving@fb.com> | 2018-04-11 14:02:37 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-04-12 03:55:50 -0400 |
commit | 32e6e967fb36bf77ed99221ae3ce1909f045d8f9 (patch) | |
tree | dc3142bceb925e06540b65bea06477e5219f9968 /kernel | |
parent | 50268a3d266ecfdd6c5873d62b2758d9732fc598 (diff) |
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 <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: 33ea4b24277b ("perf/core: Implement the 'perf_uprobe' PMU")
Fixes: e12f03d7031a ("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>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/events/core.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index d7af82827373..2d5fe26551f8 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -8400,6 +8400,10 @@ static int perf_kprobe_event_init(struct perf_event *event) | |||
8400 | 8400 | ||
8401 | if (event->attr.type != perf_kprobe.type) | 8401 | if (event->attr.type != perf_kprobe.type) |
8402 | return -ENOENT; | 8402 | return -ENOENT; |
8403 | |||
8404 | if (!capable(CAP_SYS_ADMIN)) | ||
8405 | return -EACCES; | ||
8406 | |||
8403 | /* | 8407 | /* |
8404 | * no branch sampling for probe events | 8408 | * no branch sampling for probe events |
8405 | */ | 8409 | */ |
@@ -8437,6 +8441,10 @@ static int perf_uprobe_event_init(struct perf_event *event) | |||
8437 | 8441 | ||
8438 | if (event->attr.type != perf_uprobe.type) | 8442 | if (event->attr.type != perf_uprobe.type) |
8439 | return -ENOENT; | 8443 | return -ENOENT; |
8444 | |||
8445 | if (!capable(CAP_SYS_ADMIN)) | ||
8446 | return -EACCES; | ||
8447 | |||
8440 | /* | 8448 | /* |
8441 | * no branch sampling for probe events | 8449 | * no branch sampling for probe events |
8442 | */ | 8450 | */ |