diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-04-09 04:53:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-09 05:50:52 -0400 |
commit | 1ccd15497869f3ed83b5225d410df53a96e52757 (patch) | |
tree | 67c475136503f53c2b2d9d9ada1c281aef0a162b /kernel/perf_counter.c | |
parent | 9ee318a7825929bc3734110b83ae8e20e53d9de3 (diff) |
perf_counter: sysctl for system wide perf counters
Impact: add sysctl for paranoid/relaxed perfcounters policy
Allow the use of system wide perf counters to everybody, but provide
a sysctl to disable it for the paranoid security minded.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <20090409085524.514046352@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_counter.c')
-rw-r--r-- | kernel/perf_counter.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 76376ecb23b5..7efb7ebaaae0 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -42,6 +42,8 @@ static atomic_t nr_mmap_tracking __read_mostly; | |||
42 | static atomic_t nr_munmap_tracking __read_mostly; | 42 | static atomic_t nr_munmap_tracking __read_mostly; |
43 | static atomic_t nr_comm_tracking __read_mostly; | 43 | static atomic_t nr_comm_tracking __read_mostly; |
44 | 44 | ||
45 | int sysctl_perf_counter_priv __read_mostly; /* do we need to be privileged */ | ||
46 | |||
45 | /* | 47 | /* |
46 | * Mutex for (sysadmin-configurable) counter reservations: | 48 | * Mutex for (sysadmin-configurable) counter reservations: |
47 | */ | 49 | */ |
@@ -1132,7 +1134,7 @@ static struct perf_counter_context *find_get_context(pid_t pid, int cpu) | |||
1132 | */ | 1134 | */ |
1133 | if (cpu != -1) { | 1135 | if (cpu != -1) { |
1134 | /* Must be root to operate on a CPU counter: */ | 1136 | /* Must be root to operate on a CPU counter: */ |
1135 | if (!capable(CAP_SYS_ADMIN)) | 1137 | if (sysctl_perf_counter_priv && !capable(CAP_SYS_ADMIN)) |
1136 | return ERR_PTR(-EACCES); | 1138 | return ERR_PTR(-EACCES); |
1137 | 1139 | ||
1138 | if (cpu < 0 || cpu > num_possible_cpus()) | 1140 | if (cpu < 0 || cpu > num_possible_cpus()) |