diff options
author | David S. Miller <davem@davemloft.net> | 2017-06-15 11:31:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-15 11:59:32 -0400 |
commit | 0ddead90b223faae475f3296a50bf574b7f7c69a (patch) | |
tree | e729c7fcdc7e3697f7fae2f3028ed0d11931c425 /kernel/events | |
parent | f7aec129a356ad049edddcb7e77b04a474fcf41f (diff) | |
parent | a090bd4ff8387c409732a8e059fbf264ea0bdd56 (diff) | |
download | linux-stable-0ddead90b223faae475f3296a50bf574b7f7c69a.tar.gz linux-stable-0ddead90b223faae475f3296a50bf574b7f7c69a.tar.bz2 linux-stable-0ddead90b223faae475f3296a50bf574b7f7c69a.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
The conflicts were two cases of overlapping changes in
batman-adv and the qed driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 51e40e4876c0..9afab55c68c2 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7329,6 +7329,21 @@ int perf_event_account_interrupt(struct perf_event *event) return __perf_event_account_interrupt(event, 1); } +static bool sample_is_allowed(struct perf_event *event, struct pt_regs *regs) +{ + /* + * Due to interrupt latency (AKA "skid"), we may enter the + * kernel before taking an overflow, even if the PMU is only + * counting user events. + * To avoid leaking information to userspace, we must always + * reject kernel samples when exclude_kernel is set. + */ + if (event->attr.exclude_kernel && !user_mode(regs)) + return false; + + return true; +} + /* * Generic event overflow handling, sampling. */ @@ -7350,6 +7365,12 @@ static int __perf_event_overflow(struct perf_event *event, ret = __perf_event_account_interrupt(event, throttle); /* + * For security, drop the skid kernel samples if necessary. + */ + if (!sample_is_allowed(event, regs)) + return ret; + + /* * XXX event_limit might not quite work as expected on inherited * events */ |