Skip to content

Commit b042fdf

Browse files
deepanshu406rostedt
authored andcommitted
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. Cc: stable@vger.kernel.org Fixes: cf9f0f7 ("tracing: Allow user-space mapping of the ring-buffer") Link: https://patch.msgid.link/20251119064019.25904-1-kartikey406@gmail.com Closes: https://syzkaller.appspot.com/bug?extid=a72c325b042aae6403c7 Tested-by: syzbot+a72c325b042aae6403c7@syzkaller.appspotmail.com Reported-by: syzbot+a72c325b042aae6403c7@syzkaller.appspotmail.com Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent dcb6fa3 commit b042fdf

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

kernel/trace/trace.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8781,8 +8781,18 @@ static void tracing_buffers_mmap_close(struct vm_area_struct *vma)
87818781
put_snapshot_map(iter->tr);
87828782
}
87838783

8784+
static int tracing_buffers_may_split(struct vm_area_struct *vma, unsigned long addr)
8785+
{
8786+
/*
8787+
* Trace buffer mappings require the complete buffer including
8788+
* the meta page. Partial mappings are not supported.
8789+
*/
8790+
return -EINVAL;
8791+
}
8792+
87848793
static const struct vm_operations_struct tracing_buffers_vmops = {
87858794
.close = tracing_buffers_mmap_close,
8795+
.may_split = tracing_buffers_may_split,
87868796
};
87878797

87888798
static int tracing_buffers_mmap(struct file *filp, struct vm_area_struct *vma)

0 commit comments

Comments
 (0)