aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/events
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2013-05-21 06:53:37 -0400
committerIngo Molnar <mingo@kernel.org>2013-05-28 03:13:54 -0400
commit2b923c8f5de6722393e614b096d5040b6d4eaf98 (patch)
tree32d26494f93859f3a03a8aa6edc2cc3b97476191 /kernel/events
parent13acac307528c9cd7dd9fa9c577419401527b464 (diff)
perf/x86: Check branch sampling priv level in generic code
This patch moves commit 7cc23cd to the generic code: perf/x86/intel/lbr: Demand proper privileges for PERF_SAMPLE_BRANCH_KERNEL The check is now implemented in generic code instead of x86 specific code. That way we do not have to repeat the test in each arch supporting branch sampling. Signed-off-by: Stephane Eranian <eranian@google.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Link: http://lkml.kernel.org/r/20130521105337.GA2879@quad Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r--kernel/events/core.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 53d1b300116a..a0780b3a3d50 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6481,11 +6481,6 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
6481 if (!(mask & ~PERF_SAMPLE_BRANCH_PLM_ALL)) 6481 if (!(mask & ~PERF_SAMPLE_BRANCH_PLM_ALL))
6482 return -EINVAL; 6482 return -EINVAL;
6483 6483
6484 /* kernel level capture: check permissions */
6485 if ((mask & PERF_SAMPLE_BRANCH_PERM_PLM)
6486 && perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
6487 return -EACCES;
6488
6489 /* propagate priv level, when not set for branch */ 6484 /* propagate priv level, when not set for branch */
6490 if (!(mask & PERF_SAMPLE_BRANCH_PLM_ALL)) { 6485 if (!(mask & PERF_SAMPLE_BRANCH_PLM_ALL)) {
6491 6486
@@ -6503,6 +6498,10 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
6503 */ 6498 */
6504 attr->branch_sample_type = mask; 6499 attr->branch_sample_type = mask;
6505 } 6500 }
6501 /* kernel level capture: check permissions */
6502 if ((mask & PERF_SAMPLE_BRANCH_KERNEL)
6503 && perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
6504 return -EACCES;
6506 } 6505 }
6507 6506
6508 if (attr->sample_type & PERF_SAMPLE_REGS_USER) { 6507 if (attr->sample_type & PERF_SAMPLE_REGS_USER) {