LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] perf: fix alloc_callchain_buffers()
@ 2011-01-25 18:40 Eric Dumazet
2011-01-26 7:25 ` [tip:perf/urgent] perf: Fix alloc_callchain_buffers() tip-bot for Eric Dumazet
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2011-01-25 18:40 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Frederic Weisbecker, stable, Peter Zijlstra,
Arnaldo Carvalho de Melo, David Miller, Stephane Eranian
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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [tip:perf/urgent] perf: Fix alloc_callchain_buffers()
2011-01-25 18:40 [PATCH] perf: fix alloc_callchain_buffers() Eric Dumazet
@ 2011-01-26 7:25 ` tip-bot for Eric Dumazet
2011-01-26 16:23 ` [PATCH] perf: fix alloc_callchain_buffers() Frederic Weisbecker
2011-01-27 18:28 ` [tip:perf/urgent] perf: Fix alloc_callchain_buffers() tip-bot for Eric Dumazet
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Eric Dumazet @ 2011-01-26 7:25 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, eranian, acme, hpa, mingo, eric.dumazet,
a.p.zijlstra, davem, fweisbec, tglx, mingo
Commit-ID: 10f633a1a5cd8b9e2605d1f64a14ca008bce962b
Gitweb: http://git.kernel.org/tip/10f633a1a5cd8b9e2605d1f64a14ca008bce962b
Author: Eric Dumazet <eric.dumazet@gmail.com>
AuthorDate: Tue, 25 Jan 2011 19:40:51 +0100
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 26 Jan 2011 07:55:15 +0100
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>
---
kernel/perf_event.c | 3 +--
1 files changed, 1 insertions(+), 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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf: fix alloc_callchain_buffers()
2011-01-25 18:40 [PATCH] perf: fix alloc_callchain_buffers() Eric Dumazet
2011-01-26 7:25 ` [tip:perf/urgent] perf: Fix alloc_callchain_buffers() tip-bot for Eric Dumazet
@ 2011-01-26 16:23 ` Frederic Weisbecker
2011-01-27 18:28 ` [tip:perf/urgent] perf: Fix alloc_callchain_buffers() tip-bot for Eric Dumazet
2 siblings, 0 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2011-01-26 16:23 UTC (permalink / raw)
To: Eric Dumazet
Cc: Ingo Molnar, linux-kernel, stable, Peter Zijlstra,
Arnaldo Carvalho de Melo, David Miller, Stephane Eranian
On Tue, Jan 25, 2011 at 07:40:51PM +0100, Eric Dumazet wrote:
> 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
Good catch, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:perf/urgent] perf: Fix alloc_callchain_buffers()
2011-01-25 18:40 [PATCH] perf: fix alloc_callchain_buffers() Eric Dumazet
2011-01-26 7:25 ` [tip:perf/urgent] perf: Fix alloc_callchain_buffers() tip-bot for Eric Dumazet
2011-01-26 16:23 ` [PATCH] perf: fix alloc_callchain_buffers() Frederic Weisbecker
@ 2011-01-27 18:28 ` tip-bot for Eric Dumazet
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Eric Dumazet @ 2011-01-27 18:28 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, eranian, acme, hpa, mingo, eric.dumazet,
a.p.zijlstra, davem, fweisbec, tglx, mingo
Commit-ID: 88d4f0db7fa8785859c1d637f9aac210932b6216
Gitweb: http://git.kernel.org/tip/88d4f0db7fa8785859c1d637f9aac210932b6216
Author: Eric Dumazet <eric.dumazet@gmail.com>
AuthorDate: Tue, 25 Jan 2011 19:40:51 +0100
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 27 Jan 2011 19:21:50 +0100
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>
---
kernel/perf_event.c | 3 +--
1 files changed, 1 insertions(+), 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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-01-27 18:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-25 18:40 [PATCH] perf: fix alloc_callchain_buffers() Eric Dumazet
2011-01-26 7:25 ` [tip:perf/urgent] perf: Fix alloc_callchain_buffers() tip-bot for Eric Dumazet
2011-01-26 16:23 ` [PATCH] perf: fix alloc_callchain_buffers() Frederic Weisbecker
2011-01-27 18:28 ` [tip:perf/urgent] perf: Fix alloc_callchain_buffers() tip-bot for Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).