Skip to content

Commit 913a90b

Browse files
Ravi BangoriaIngo Molnar
authored andcommitted
perf/ioctl: Add check for the sample_period value
perf_event_open() limits the sample_period to 63 bits. See: 0819b2e ("perf: Limit perf_event_attr::sample_period to 63 bits") Make ioctl() consistent with it. Also on PowerPC, negative sample_period could cause a recursive PMIs leading to a hang (reported when running perf-fuzzer). Signed-off-by: Ravi Bangoria <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Fixes: 0819b2e ("perf: Limit perf_event_attr::sample_period to 63 bits") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 085ebfe commit 913a90b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/events/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5005,6 +5005,9 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
50055005
if (perf_event_check_period(event, value))
50065006
return -EINVAL;
50075007

5008+
if (!event->attr.freq && (value & (1ULL << 63)))
5009+
return -EINVAL;
5010+
50085011
event_function_call(event, __perf_event_period, &value);
50095012

50105013
return 0;

0 commit comments

Comments
 (0)