Skip to content

Commit

Permalink
ring-buffer: Move disabled check into preempt disable section
Browse files Browse the repository at this point in the history
The ring buffer resizing and resetting relies on a schedule RCU
action. The buffers are disabled, a synchronize_sched() is called
and then the resize or reset takes place.

But this only works if the disabling of the buffers are within the
preempt disabled section, otherwise a window exists that the buffers
can be written to while a reset or resize takes place.

Cc: stable@kernel.org
Reported-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
LKML-Reference: <4B949E43.2010906@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Lai Jiangshan authored and Steven Rostedt committed Mar 13, 2010
1 parent 915a0b5 commit 52fbe9c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2232,12 +2232,12 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer, unsigned long length)
if (ring_buffer_flags != RB_BUFFERS_ON)
return NULL;

if (atomic_read(&buffer->record_disabled))
return NULL;

/* If we are tracing schedule, we don't want to recurse */
resched = ftrace_preempt_disable();

if (atomic_read(&buffer->record_disabled))
goto out_nocheck;

if (trace_recursive_lock())
goto out_nocheck;

Expand Down Expand Up @@ -2469,11 +2469,11 @@ int ring_buffer_write(struct ring_buffer *buffer,
if (ring_buffer_flags != RB_BUFFERS_ON)
return -EBUSY;

if (atomic_read(&buffer->record_disabled))
return -EBUSY;

resched = ftrace_preempt_disable();

if (atomic_read(&buffer->record_disabled))
goto out;

cpu = raw_smp_processor_id();

if (!cpumask_test_cpu(cpu, buffer->cpumask))
Expand Down

0 comments on commit 52fbe9c

Please sign in to comment.