Message ID | 20240220095112.77e9cb81@gandalf.local.home (mailing list archive) |
---|---|
State | Accepted |
Commit | e78fb4eac817308027da88d02e5d0213462a7562 |
Headers | show |
Series | ring-buffer: Do not let subbuf be bigger than write mask | expand |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index aa54266f5e1f..3852f3b001cc 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -5878,6 +5878,10 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order) if (psize <= BUF_PAGE_HDR_SIZE) return -EINVAL; + /* Size of a subbuf cannot be greater than the write counter */ + if (psize > RB_WRITE_MASK + 1) + return -EINVAL; + old_order = buffer->subbuf_order; old_size = buffer->subbuf_size;