diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/perf_counter.c | 4 | ||||
-rw-r--r-- | kernel/sysctl.c | 11 |
2 files changed, 14 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()) |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 4286b62b34a0..8ba457838d95 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/reboot.h> | 49 | #include <linux/reboot.h> |
50 | #include <linux/ftrace.h> | 50 | #include <linux/ftrace.h> |
51 | #include <linux/slow-work.h> | 51 | #include <linux/slow-work.h> |
52 | #include <linux/perf_counter.h> | ||
52 | 53 | ||
53 | #include <asm/uaccess.h> | 54 | #include <asm/uaccess.h> |
54 | #include <asm/processor.h> | 55 | #include <asm/processor.h> |
@@ -920,6 +921,16 @@ static struct ctl_table kern_table[] = { | |||
920 | .child = slow_work_sysctls, | 921 | .child = slow_work_sysctls, |
921 | }, | 922 | }, |
922 | #endif | 923 | #endif |
924 | #ifdef CONFIG_PERF_COUNTERS | ||
925 | { | ||
926 | .ctl_name = CTL_UNNUMBERED, | ||
927 | .procname = "perf_counter_privileged", | ||
928 | .data = &sysctl_perf_counter_priv, | ||
929 | .maxlen = sizeof(sysctl_perf_counter_priv), | ||
930 | .mode = 0644, | ||
931 | .proc_handler = &proc_dointvec, | ||
932 | }, | ||
933 | #endif | ||
923 | /* | 934 | /* |
924 | * NOTE: do not add new entries to this table unless you have read | 935 | * NOTE: do not add new entries to this table unless you have read |
925 | * Documentation/sysctl/ctl_unnumbered.txt | 936 | * Documentation/sysctl/ctl_unnumbered.txt |