Unverified Commit 5a3aeaf3 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!9264 ring-buffer: Fix a race between readers and resize checks

parents 01815e5c 86193567
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1471,6 +1471,11 @@ static int rb_check_bpage(struct ring_buffer_per_cpu *cpu_buffer,
 *
 * As a safety measure we check to make sure the data pages have not
 * been corrupted.
 *
 * Callers of this function need to guarantee that the list of pages doesn't get
 * modified during the check. In particular, if it's possible that the function
 * is invoked with concurrent readers which can swap in a new reader page then
 * the caller should take cpu_buffer->reader_lock.
 */
static int rb_check_pages(struct ring_buffer_per_cpu *cpu_buffer)
{
@@ -2195,8 +2200,12 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
		 */
		synchronize_rcu();
		for_each_buffer_cpu(buffer, cpu) {
			unsigned long flags;

			cpu_buffer = buffer->buffers[cpu];
			raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
			rb_check_pages(cpu_buffer);
			raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
		}
		atomic_dec(&buffer->record_disabled);
	}