Messages in this thread Patch in this message | | | Subject | [PATCH] perf: fix alloc_callchain_buffers() | From | Eric Dumazet <> | Date | Tue, 25 Jan 2011 19:40:51 +0100 |
| |
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 --- kernel/perf_event.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 126a302..852ae8c 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c @@ -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)
| |