History

perf: Limit perf_event_attr::sample_period to 63 bits

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.

Peter Zijlstra committed 12 years ago

Commit 0819b2e1 parent a45e9031 file · +3 −0Browse files

Unified · Split

kernel/events/core.c+3−0
@@ -7029,6 +7029,9 @@ SYSCALL_DEFINE5(perf_event_open, · 7028 unmodified lines
7029 if (attr.freq) {7029 if (attr.freq) {
7030 if (attr.sample_freq > sysctl_perf_event_sample_rate)7030 if (attr.sample_freq > sysctl_perf_event_sample_rate)
7031 return -EINVAL;7031 return -EINVAL;
7032 } else {
7033 if (attr.sample_period & (1ULL << 63))
7034 return -EINVAL;
7032 }7035 }
7033 7036
7034 /*7037 /*