public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [trace?] WARNING in tracing_buffers_mmap_close (2)
@ 2025-11-11 17:05 syzbot
  2025-11-11 23:27 ` Hillf Danton
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: syzbot @ 2025-11-11 17:05 UTC (permalink / raw)
  To: linux-kernel, linux-trace-kernel, mathieu.desnoyers, mhiramat,
	rostedt, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    4a0c9b339199 Merge tag 'probes-fixes-v6.18-rc4' of git://g..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=127c3bcd980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=19d831c6d0386a9c
dashboard link: https://syzkaller.appspot.com/bug?extid=a72c325b042aae6403c7
compiler:       gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=13fb5342580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=167c3bcd980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0885fd14dc45/disk-4a0c9b33.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d090edb8df65/vmlinux-4a0c9b33.xz
kernel image: https://storage.googleapis.com/syzbot-assets/fe620e34d128/bzImage-4a0c9b33.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+a72c325b042aae6403c7@syzkaller.appspotmail.com

------------[ cut here ]------------
WARNING: CPU: 0 PID: 5989 at kernel/trace/trace.c:8780 tracing_buffers_mmap_close kernel/trace/trace.c:8780 [inline]
WARNING: CPU: 0 PID: 5989 at kernel/trace/trace.c:8780 tracing_buffers_mmap_close+0xdd/0x130 kernel/trace/trace.c:8775
Modules linked in:
CPU: 0 UID: 0 PID: 5989 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/02/2025
RIP: 0010:tracing_buffers_mmap_close kernel/trace/trace.c:8780 [inline]
RIP: 0010:tracing_buffers_mmap_close+0xdd/0x130 kernel/trace/trace.c:8775
Code: 75 46 48 8b 7b 08 e8 b2 94 ff ff 31 ff 89 c3 89 c6 e8 07 4b fb ff 85 db 75 0a 48 83 c4 08 5b e9 b9 4f fb ff e8 b4 4f fb ff 90 <0f> 0b 90 48 83 c4 08 5b e9 a6 4f fb ff e8 b1 e6 62 00 eb 87 e8 da
RSP: 0018:ffffc90003047ba8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000ffffffed RCX: ffffffff81c11d89
RDX: ffff888020713c80 RSI: ffffffff81c11d9c RDI: 0000000000000005
RBP: ffffffff81c11cc0 R08: 0000000000000005 R09: 0000000000000000
R10: 00000000ffffffed R11: 0000000000000000 R12: ffff8880217512c8
R13: dffffc0000000000 R14: ffffc90003047c30 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff888124a0d000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005555606ff808 CR3: 000000000e182000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 vma_close mm/internal.h:190 [inline]
 remove_vma+0x88/0x160 mm/vma.c:464
 exit_mmap+0x50a/0xb90 mm/mmap.c:1305
 __mmput+0x12a/0x410 kernel/fork.c:1133
 mmput+0x62/0x70 kernel/fork.c:1156
 exit_mm kernel/exit.c:582 [inline]
 do_exit+0x7c7/0x2bf0 kernel/exit.c:954
 do_group_exit+0xd3/0x2a0 kernel/exit.c:1107
 __do_sys_exit_group kernel/exit.c:1118 [inline]
 __se_sys_exit_group kernel/exit.c:1116 [inline]
 __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1116
 x64_sys_call+0x150b/0x1730 arch/x86/include/generated/asm/syscalls_64.h:232
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0xfa0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f168a18f6c9
Code: Unable to access opcode bytes at 0x7f168a18f69f.
RSP: 002b:00007ffff8c604f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f168a18f6c9
RDX: 0000000000000064 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000003 R08: 00000004f8c605ef R09: 00007f168a3b1280
R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f168a3b1280 R14: 0000000000000003 R15: 00007ffff8c605b0
 </TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [trace?] WARNING in tracing_buffers_mmap_close (2)
  2025-11-11 17:05 [syzbot] [trace?] WARNING in tracing_buffers_mmap_close (2) syzbot
@ 2025-11-11 23:27 ` Hillf Danton
  2025-11-11 23:44   ` syzbot
  2025-11-19  5:51 ` Forwarded: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close for split VMAs syzbot
  2025-11-19  6:14 ` syzbot
  2 siblings, 1 reply; 5+ messages in thread
From: Hillf Danton @ 2025-11-11 23:27 UTC (permalink / raw)
  To: syzbot; +Cc: linux-kernel, syzkaller-bugs

> Date: Tue, 11 Nov 2025 09:05:31 -0800
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    4a0c9b339199 Merge tag 'probes-fixes-v6.18-rc4' of git://g..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=127c3bcd980000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=19d831c6d0386a9c
> dashboard link: https://syzkaller.appspot.com/bug?extid=a72c325b042aae6403c7
> compiler:       gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=13fb5342580000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=167c3bcd980000

#syz test

--- x/mm/mmap_lock.c
+++ y/mm/mmap_lock.c
@@ -240,6 +240,7 @@ retry:
 		/* Check if the VMA got isolated after we found it */
 		if (PTR_ERR(vma) == -EAGAIN) {
 			count_vm_vma_lock_event(VMA_LOCK_MISS);
+			mas_set(&mas, address);
 			/* The area was replaced with another one */
 			goto retry;
 		}
--

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [trace?] WARNING in tracing_buffers_mmap_close (2)
  2025-11-11 23:27 ` Hillf Danton
@ 2025-11-11 23:44   ` syzbot
  0 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2025-11-11 23:44 UTC (permalink / raw)
  To: hdanton, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in tracing_buffers_mmap_close

------------[ cut here ]------------
WARNING: CPU: 0 PID: 6465 at kernel/trace/trace.c:8780 tracing_buffers_mmap_close kernel/trace/trace.c:8780 [inline]
WARNING: CPU: 0 PID: 6465 at kernel/trace/trace.c:8780 tracing_buffers_mmap_close+0xdd/0x130 kernel/trace/trace.c:8775
Modules linked in:
CPU: 0 UID: 0 PID: 6465 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
RIP: 0010:tracing_buffers_mmap_close kernel/trace/trace.c:8780 [inline]
RIP: 0010:tracing_buffers_mmap_close+0xdd/0x130 kernel/trace/trace.c:8775
Code: 75 46 48 8b 7b 08 e8 92 94 ff ff 31 ff 89 c3 89 c6 e8 e7 4a fb ff 85 db 75 0a 48 83 c4 08 5b e9 99 4f fb ff e8 94 4f fb ff 90 <0f> 0b 90 48 83 c4 08 5b e9 86 4f fb ff e8 51 f9 62 00 eb 87 e8 7a
RSP: 0018:ffffc900033a7980 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000ffffffed RCX: ffffffff81c108d9
RDX: ffff88802f3b0000 RSI: ffffffff81c108ec RDI: 0000000000000005
RBP: ffffffff81c10810 R08: 0000000000000005 R09: 0000000000000000
R10: 00000000ffffffed R11: 0000000000000000 R12: ffff888046203408
R13: dffffc0000000000 R14: ffffc900033a7a08 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff888124a0d000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f36505f5f98 CR3: 000000000e182000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 vma_close mm/internal.h:190 [inline]
 remove_vma+0x88/0x160 mm/vma.c:464
 exit_mmap+0x50a/0xb90 mm/mmap.c:1305
 __mmput+0x12a/0x410 kernel/fork.c:1133
 mmput+0x62/0x70 kernel/fork.c:1156
 exit_mm kernel/exit.c:582 [inline]
 do_exit+0x7c7/0x2bf0 kernel/exit.c:954
 do_group_exit+0xd3/0x2a0 kernel/exit.c:1107
 get_signal+0x2671/0x26d0 kernel/signal.c:3034
 arch_do_signal_or_restart+0x8f/0x790 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop+0x85/0x130 kernel/entry/common.c:40
 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline]
 syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline]
 do_syscall_64+0x426/0xfa0 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f3650f8f6c9
Code: Unable to access opcode bytes at 0x7f3650f8f69f.
RSP: 002b:00007f36505f60e8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007f36511e5fa8 RCX: 00007f3650f8f6c9
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007f36511e5fa8
RBP: 00007f36511e5fa0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f36511e6038 R14: 00007ffdf110f910 R15: 00007ffdf110f9f8
 </TASK>


Tested on:

commit:         24172e0d Merge tag 'arm64-fixes' of git://git.kernel.o..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13370212580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=19d831c6d0386a9c
dashboard link: https://syzkaller.appspot.com/bug?extid=a72c325b042aae6403c7
compiler:       gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=135b560a580000


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Forwarded: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close for split VMAs
  2025-11-11 17:05 [syzbot] [trace?] WARNING in tracing_buffers_mmap_close (2) syzbot
  2025-11-11 23:27 ` Hillf Danton
@ 2025-11-19  5:51 ` syzbot
  2025-11-19  6:14 ` syzbot
  2 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2025-11-19  5:51 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close for split VMAs
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

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.

Fix this by handling -ENODEV gracefully in tracing_buffers_mmap_close().
When ring_buffer_unmap() returns -ENODEV, it means this VMA was a split
portion that doesn't hold a reference, so simply return without calling
put_snapshot_map().

Closes: https://syzkaller.appspot.com/bug?extid=a72c325b042aae6403c7
Reported-by: syzbot+a72c325b042aae6403c7@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 kernel/trace/trace.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d1e527cf2aae..fe593dd2c387 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -8776,8 +8776,17 @@ static void tracing_buffers_mmap_close(struct vm_area_struct *vma)
 {
 	struct ftrace_buffer_info *info = vma->vm_file->private_data;
 	struct trace_iterator *iter = &info->iter;
+	int ret;
 
-	WARN_ON(ring_buffer_unmap(iter->array_buffer->buffer, iter->cpu_file));
+	ret = ring_buffer_unmap(iter->array_buffer->buffer, iter->cpu_file);
+	if (ret == -ENODEV) {
+		/*
+		 * This VMA was split from the original mapping. Since
+		 * ring buffer mappings do not support partial mappings,
+		 * the split VMA does not hold a reference.
+		 */
+		return;
+	}
 	put_snapshot_map(iter->tr);
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Forwarded: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close for split VMAs
  2025-11-11 17:05 [syzbot] [trace?] WARNING in tracing_buffers_mmap_close (2) syzbot
  2025-11-11 23:27 ` Hillf Danton
  2025-11-19  5:51 ` Forwarded: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close for split VMAs syzbot
@ 2025-11-19  6:14 ` syzbot
  2 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2025-11-19  6:14 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close for split VMAs
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master


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.

Closes: https://syzkaller.appspot.com/bug?extid=a72c325b042aae6403c7
Reported-by: syzbot+a72c325b042aae6403c7@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 kernel/trace/trace.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d1e527cf2aae..304e93597126 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -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)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-19  6:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11 17:05 [syzbot] [trace?] WARNING in tracing_buffers_mmap_close (2) syzbot
2025-11-11 23:27 ` Hillf Danton
2025-11-11 23:44   ` syzbot
2025-11-19  5:51 ` Forwarded: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close for split VMAs syzbot
2025-11-19  6:14 ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox