summaryrefslogtreecommitdiff
path: root/rust/kernel/alloc/allocator
diff options
context:
space:
mode:
authorVincent Donnefort <vdonnefort@google.com>2026-11-13 15:27:11 +0000
committerSteven Rostedt <rostedt@goodmis.org>2026-11-20 10:02:37 -0500
commit27d44f1c58092c56cf38adf831ca4cfe05b4a03c (patch)
treed0aab40fcc07afb8371a9807a384b55459242eaf /rust/kernel/alloc/allocator
parent2a6d7231c79ecb0e6a1d4e6549302e0c47175d22 (diff)
ring-buffer: Check remote reader page commit before meta entries
__rb_get_reader_page_from_remote() bails out when rb_num_of_entries() is zero before verifying if there is more data committed on the current reader_page (rb_page_size()), while simple_ring_buffer updates page::commit before meta::entries. As a consequence, a race between the writer and reader could lead to __rb_get_reader_page_from_remote() returning NULL, while more data is available for reading on the ring buffer. CPU0 (writer) CPU1 (reader) ------------- ------------- local_set(&page->commit, write); __rb_get_reader_page_from_remote() !rb_read_remote_meta_page() return NULL; simple_rb_meta_inc(meta->entries, 1); This is an issue for rb_advance_reader() which always expects rb_get_reader_page() to return a page. Fix this issue by swapping the checks in __rb_get_reader_page_from_remote(): first it verifies if there is more to read in the current reader page, then it verifies if there's anything at all in the ring buffer. Also, if the reader observes the meta::entries update before page::commit while the writer moves tail_page, it could swap reader_page out and drop unread events. Order page::commit before meta::entries on the writer and rb_read_remote_meta_page() before rb_page_size() on the reader size. Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261113152729.837429-3-vdonnefort@google.com Fixes: 2e67fabd8b77 ("ring-buffer: Introduce ring-buffer remotes") Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer") Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'rust/kernel/alloc/allocator')
0 files changed, 0 insertions, 0 deletions