From e9e34a57aa83744667d6da43139d87c0a3b1d3a8 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 2 Sep 2009 21:46:00 +0200 Subject: [PATCH] --- yaml --- r: 158299 b: refs/heads/master c: 0fbdea19e9394a5cb5f2f5081b028c50b558910a h: refs/heads/master i: 158297: 59472d49b39867f6d63fad1e8171af074b37281f 158295: 53c61b32edc122eb641ae9fad89d6a41ed0737f8 v: v3 --- [refs] | 2 +- trunk/kernel/perf_counter.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 74dc6a35af4e..ebc2dfb1ffdf 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f76bd108e5031202bb40849306f98c4afebe4ef6 +refs/heads/master: 0fbdea19e9394a5cb5f2f5081b028c50b558910a diff --git a/trunk/kernel/perf_counter.c b/trunk/kernel/perf_counter.c index d988dfb4bbab..0aa609f69103 100644 --- a/trunk/kernel/perf_counter.c +++ b/trunk/kernel/perf_counter.c @@ -46,12 +46,18 @@ static atomic_t nr_task_counters __read_mostly; /* * perf counter paranoia level: - * 0 - not paranoid - * 1 - disallow cpu counters to unpriv - * 2 - disallow kernel profiling to unpriv + * -1 - not paranoid at all + * 0 - disallow raw tracepoint access for unpriv + * 1 - disallow cpu counters for unpriv + * 2 - disallow kernel profiling for unpriv */ int sysctl_perf_counter_paranoid __read_mostly = 1; +static inline bool perf_paranoid_tracepoint_raw(void) +{ + return sysctl_perf_counter_paranoid > -1; +} + static inline bool perf_paranoid_cpu(void) { return sysctl_perf_counter_paranoid > 0; @@ -3971,6 +3977,7 @@ static const struct pmu *tp_perf_counter_init(struct perf_counter *counter) * have these. */ if ((counter->attr.sample_type & PERF_SAMPLE_RAW) && + perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN)) return ERR_PTR(-EPERM);