Skip to contentSkip to conversation

ring-buffer: A fix for v6.18

GIT PULL Merged Steven Rostedt 2 participants 2 messages Nov 26, 2025 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

Linus,

ring-buffer fixes for v6.18:

- Do not allow mmapped ring buffer to be split

When the ring buffer VMA is split by a partial munmap or a MAP_FIXED, the kernel calls vm_ops->close() on each portion. This causes the ring_buffer_unmap() to be called multiple times. This causes subsequent calls to return -ENODEV and triggers a warning.

There's no reason to allow user space to split up memory mapping of the ring buffer. Have it return -EINVAL when that happens.

Please pull the latest trace-ringbuffer-v6.18-rc7 tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-ringbuffer-v6.18-rc7

Tag SHA1: 0f396c7eb7f1d3ec728312e75cd42213d69916ff Head SHA1: b042fdf18e89a347177a49e795d8e5184778b5b6

Deepanshu Kartikey (1):
tracing: Fix WARN_ON in tracing_buffers_mmap_close for split VMAs

----

 kernel/trace/trace.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---------------------------
commit b042fdf18e89a347177a49e795d8e5184778b5b6
Author: Deepanshu Kartikey <[email protected]>
Date:   Wed Nov 19 12:10:19 2025 +0530

tracing: Fix WARN_ON in tracing_buffers_mmap_close for split VMAs

When a VMA is split (e.g., by partial munmap or MAP_FIXED), the kernel calls vm_ops->close on each portion. For trace buffer mappings, this results in ring_buffer_unmap() being called multiple times while ring_buffer_map() was only called once.

This causes ring_buffer_unmap() to return -ENODEV on subsequent calls because user_mapped is already 0, triggering a WARN_ON.

Trace buffer mappings cannot support partial mappings because the ring buffer structure requires the complete buffer including the meta page.

Fix this by adding a may_split callback that returns -EINVAL to prevent VMA splits entirely.

kernel/trace/trace.c +10 -0
index d1e527cf2aae..304e93597126 100644
@@ -8781,8 +8781,18 @@ static void tracing_buffers_mmap_close(struct vm_area_struct *vma)
 	put_snapshot_map(iter->tr);
 }
 
+static int tracing_buffers_may_split(struct vm_area_struct *vma, unsigned long addr)
+{
+	/*
+	 * Trace buffer mappings require the complete buffer including
+	 * the meta page. Partial mappings are not supported.
+	 */
+	return -EINVAL;
+}
+
 static const struct vm_operations_struct tracing_buffers_vmops = {
 	.close		= tracing_buffers_mmap_close,
+	.may_split      = tracing_buffers_may_split,
 };
 
 static int tracing_buffers_mmap(struct file *filp, struct vm_area_struct *vma)
merge bot Merged
#1 lore raw
The pull request you sent on Wed, 26 Nov 2025 15:31:41 -0500:

The pull request you sent on Wed, 26 Nov 2025 15:31:41 -0500:

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace-ringbuffer-v6.18-rc7

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/4941a17751c99e17422be743c02c923ad706f888

Thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html