aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-01-25 13:40:51 -0500
committerIngo Molnar <mingo@elte.hu>2011-01-27 13:21:50 -0500
commit88d4f0db7fa8785859c1d637f9aac210932b6216 (patch)
treec03e79daa9101295614147dcb9b24ed04aef9a99 /kernel
parent6fb1b304255efc5c4c93874ac8c066272e257e28 (diff)
perf: Fix alloc_callchain_buffers()
Commit 927c7a9e92c4 ("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 <eric.dumazet@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: David Miller <davem@davemloft.net> Cc: Stephane Eranian <eranian@google.com> CC: stable@kernel.org LKML-Reference: <1295980851.3588.351.camel@edumazet-laptop> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/perf_event.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 126a302c481c..852ae8c66502 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1999,8 +1999,7 @@ static int alloc_callchain_buffers(void)
1999 * accessed from NMI. Use a temporary manual per cpu allocation 1999 * accessed from NMI. Use a temporary manual per cpu allocation
2000 * until that gets sorted out. 2000 * until that gets sorted out.
2001 */ 2001 */
2002 size = sizeof(*entries) + sizeof(struct perf_callchain_entry *) * 2002 size = offsetof(struct callchain_cpus_entries, cpu_entries[nr_cpu_ids]);
2003 num_possible_cpus();
2004 2003
2005 entries = kzalloc(size, GFP_KERNEL); 2004 entries = kzalloc(size, GFP_KERNEL);
2006 if (!entries) 2005 if (!entries)