From: Peter Zijlstra Date: Thu, 15 May 2014 18:23:48 +0000 (+0200) Subject: perf: Limit perf_event_attr::sample_period to 63 bits X-Git-Tag: upstream/snapshot3+hdmi~2559 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git;a=commitdiff_plain;h=23d92064081ba10489b7a654b97255d8dfcfa6f4 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 Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-p25fhunibl4y3qi0zuqmyf4b@git.kernel.org Signed-off-by: Thomas Gleixner Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/events/core.c b/kernel/events/core.c index e80611f..e756171 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7025,6 +7025,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; } /*