linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ring-buffer: Check for uninitialized cpu buffer before resizing
@ 2012-10-10 23:40 Vaibhav Nagarnaik
  2012-10-21 18:37 ` [tip:perf/urgent] " tip-bot for Vaibhav Nagarnaik
  0 siblings, 1 reply; 2+ messages in thread
From: Vaibhav Nagarnaik @ 2012-10-10 23:40 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, Vaibhav Nagarnaik

With a system where, num_present_cpus < num_possible_cpus, even if all
CPUs are online, non-present CPUs don't have per_cpu buffers allocated.
If per_cpu/<cpu>/buffer_size_kb is modified for such a CPU, it can cause
a panic due to NULL dereference in ring_buffer_resize().

To fix this, resize operation is allowed only if the per-cpu buffer has
been initialized.

Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
---
 kernel/trace/ring_buffer.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index b32ed0e..b979426 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1567,6 +1567,10 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
 
 		put_online_cpus();
 	} else {
+		/* Make sure this CPU has been intitialized */
+		if (!cpumask_test_cpu(cpu_id, buffer->cpumask))
+			goto out;
+
 		cpu_buffer = buffer->buffers[cpu_id];
 
 		if (nr_pages == cpu_buffer->nr_pages)
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:perf/urgent] ring-buffer: Check for uninitialized cpu buffer before resizing
  2012-10-10 23:40 [PATCH] ring-buffer: Check for uninitialized cpu buffer before resizing Vaibhav Nagarnaik
@ 2012-10-21 18:37 ` tip-bot for Vaibhav Nagarnaik
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Vaibhav Nagarnaik @ 2012-10-21 18:37 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, vnagarnaik, hpa, mingo, rostedt, tglx

Commit-ID:  8e49f418c9632790bf456634742d34d97120a784
Gitweb:     http://git.kernel.org/tip/8e49f418c9632790bf456634742d34d97120a784
Author:     Vaibhav Nagarnaik <vnagarnaik@google.com>
AuthorDate: Wed, 10 Oct 2012 16:40:27 -0700
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Thu, 11 Oct 2012 12:21:48 -0400

ring-buffer: Check for uninitialized cpu buffer before resizing

With a system where, num_present_cpus < num_possible_cpus, even if all
CPUs are online, non-present CPUs don't have per_cpu buffers allocated.
If per_cpu/<cpu>/buffer_size_kb is modified for such a CPU, it can cause
a panic due to NULL dereference in ring_buffer_resize().

To fix this, resize operation is allowed only if the per-cpu buffer has
been initialized.

Link: http://lkml.kernel.org/r/1349912427-6486-1-git-send-email-vnagarnaik@google.com

Cc: stable@vger.kernel.org # 3.5+
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ring_buffer.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index b32ed0e..b979426 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1567,6 +1567,10 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
 
 		put_online_cpus();
 	} else {
+		/* Make sure this CPU has been intitialized */
+		if (!cpumask_test_cpu(cpu_id, buffer->cpumask))
+			goto out;
+
 		cpu_buffer = buffer->buffers[cpu_id];
 
 		if (nr_pages == cpu_buffer->nr_pages)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-21 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-10 23:40 [PATCH] ring-buffer: Check for uninitialized cpu buffer before resizing Vaibhav Nagarnaik
2012-10-21 18:37 ` [tip:perf/urgent] " tip-bot for Vaibhav Nagarnaik

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).