summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2014-05-15 20:23:48 +0200
committerJiri Slaby <jslaby@suse.cz>2014-06-20 17:33:52 +0200
commited8acba3f62f4cb479628215582b487872c398d7 (patch)
tree68f5ce0a88df09a943baf0ae08bcf2e9b35afc57 /kernel
parente36e8c8f72bc4f8309bf0dea92d58aa661c74c84 (diff)
downloadlwn-ed8acba3f62f4cb479628215582b487872c398d7.tar.gz
lwn-ed8acba3f62f4cb479628215582b487872c398d7.zip
perf: Limit perf_event_attr::sample_period to 63 bits
commit 0819b2e30ccb93edf04876237b6205eef84ec8d2 upstream. Vince reported that using a large sample_period (one with bit 63 set) results in wreckage since while the sample_period is fundamentally unsigned (negative periods don't make sense) the way we implement things very much rely on signed logic. So limit sample_period to 63 bits to avoid tripping over this. Reported-by: Vince Weaver <vincent.weaver@maine.edu> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/n/tip-p25fhunibl4y3qi0zuqmyf4b@git.kernel.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/events/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 6e0f9648fa68..01eeaf6cc95a 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6956,6 +6956,9 @@ SYSCALL_DEFINE5(perf_event_open,
if (attr.freq) {
if (attr.sample_freq > sysctl_perf_event_sample_rate)
return -EINVAL;
+ } else {
+ if (attr.sample_period & (1ULL << 63))
+ return -EINVAL;
}
/*