diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2016-05-29 14:22:32 -0700 |
---|---|---|
committer | Ziyan <jaraidaniel@gmail.com> | 2016-10-29 01:34:03 +0200 |
commit | 87040c3c6003be08c1e10914ae58c2e814359b05 (patch) | |
tree | 141cd69932d05dc135ea7058df26247dac21ed23 /kernel | |
parent | 7aa76215eb3fae8b93f1d0df80fdc9cb203bbb78 (diff) | |
download | kernel_samsung_tuna-87040c3c6003be08c1e10914ae58c2e814359b05.zip kernel_samsung_tuna-87040c3c6003be08c1e10914ae58c2e814359b05.tar.gz kernel_samsung_tuna-87040c3c6003be08c1e10914ae58c2e814359b05.tar.bz2 |
FROMLIST: security,perf: Allow further restriction of perf_event_open
When kernel.perf_event_open is set to 3 (or greater), disallow all
access to performance events by users without CAP_SYS_ADMIN.
Add a Kconfig symbol CONFIG_SECURITY_PERF_EVENTS_RESTRICT that
makes this value the default.
This is based on a similar feature in grsecurity
(CONFIG_GRKERNSEC_PERF_HARDEN). This version doesn't include making
the variable read-only. It also allows enabling further restriction
at run-time regardless of whether the default is changed.
https://lkml.org/lkml/2016/1/11/587
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Bug: 29054680
Change-Id: Iff5bff4fc1042e85866df9faa01bce8d04335ab8
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 acdc087..792cd33 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -142,8 +142,13 @@ static struct srcu_struct pmus_srcu; * 0 - disallow raw tracepoint access for unpriv * 1 - disallow cpu events for unpriv * 2 - disallow kernel profiling for unpriv + * 3 - disallow all unpriv perf event use */ +#ifdef CONFIG_SECURITY_PERF_EVENTS_RESTRICT +int sysctl_perf_event_paranoid __read_mostly = 3; +#else int sysctl_perf_event_paranoid __read_mostly = 1; +#endif /* Minimum for 512 kiB + 1 user control page */ int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */ @@ -6473,6 +6478,9 @@ SYSCALL_DEFINE5(perf_event_open, if (flags & ~PERF_FLAG_ALL) return -EINVAL; + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN)) + return -EACCES; + err = perf_copy_attr(attr_uptr, &attr); if (err) return err; |