Skip to content

Commit

Permalink
perf: Fix alloc_callchain_buffers()
Browse files Browse the repository at this point in the history
Commit 927c7a9 ("perf: Fix race in callchains") introduced
a mismatch in the sizing of struct callchain_cpus_entries.

nr_cpu_ids must be used instead of num_possible_cpus(), or we
might get out of bound memory accesses on some machines.

Signed-off-by: Eric Dumazet <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: David Miller <[email protected]>
Cc: Stephane Eranian <[email protected]>
CC: [email protected]
LKML-Reference: <1295980851.3588.351.camel@edumazet-laptop>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Eric Dumazet authored and Ingo Molnar committed Jan 27, 2011
1 parent 6fb1b30 commit 88d4f0d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1999,8 +1999,7 @@ static int alloc_callchain_buffers(void)
* accessed from NMI. Use a temporary manual per cpu allocation
* until that gets sorted out.
*/
size = sizeof(*entries) + sizeof(struct perf_callchain_entry *) *
num_possible_cpus();
size = offsetof(struct callchain_cpus_entries, cpu_entries[nr_cpu_ids]);

entries = kzalloc(size, GFP_KERNEL);
if (!entries)
Expand Down

0 comments on commit 88d4f0d

Please sign in to comment.