public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [trace?] WARNING in tracing_buffers_mmap_close
@ 2024-12-15 20:34 syzbot
  0 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2024-12-15 20:34 UTC (permalink / raw)
  To: linux-kernel, linux-trace-kernel, mathieu.desnoyers, mhiramat,
	rostedt, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    f92f4749861b Merge tag 'clk-fixes-for-linus' of git://git...
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15d92cdf980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=99a5586995ec03b2
dashboard link: https://syzkaller.appspot.com/bug?extid=ddc001b92c083dbf2b97
compiler:       gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12de78f8580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17d92cdf980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b85403132ddc/disk-f92f4749.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/20613d034287/vmlinux-f92f4749.xz
kernel image: https://storage.googleapis.com/syzbot-assets/d1ea80bf7e4e/bzImage-f92f4749.xz

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

------------[ cut here ]------------
WARNING: CPU: 1 PID: 5829 at kernel/trace/trace.c:8464 tracing_buffers_mmap_close kernel/trace/trace.c:8464 [inline]
WARNING: CPU: 1 PID: 5829 at kernel/trace/trace.c:8464 tracing_buffers_mmap_close+0xe3/0x130 kernel/trace/trace.c:8459
Modules linked in:
CPU: 1 UID: 0 PID: 5829 Comm: syz-executor210 Not tainted 6.13.0-rc2-syzkaller-00031-gf92f4749861b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
RIP: 0010:tracing_buffers_mmap_close kernel/trace/trace.c:8464 [inline]
RIP: 0010:tracing_buffers_mmap_close+0xe3/0x130 kernel/trace/trace.c:8459
Code: 75 46 48 8b 7b 08 e8 7c 85 ff ff 31 ff 89 c3 89 c6 e8 21 63 fb ff 85 db 75 0a 48 83 c4 08 5b e9 d3 60 fb ff e8 ce 60 fb ff 90 <0f> 0b 90 48 83 c4 08 5b e9 c0 60 fb ff e8 bb e7 5d 00 eb 87 e8 e4
RSP: 0018:ffffc90003857bb8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000ffffffed RCX: ffffffff819ddd0f
RDX: ffff8880339f3c00 RSI: ffffffff819ddd22 RDI: 0000000000000005
RBP: 0000000000000001 R08: 0000000000000005 R09: 0000000000000000
R10: 00000000ffffffed R11: 0000000000000000 R12: ffffffff819ddc40
R13: 0000000000000001 R14: ffff88807610a548 R15: 0000000000000ff9
FS:  0000000000000000(0000) GS:ffff8880b8700000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f44ec4e1110 CR3: 000000000db7e000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 vma_close mm/internal.h:147 [inline]
 remove_vma+0x91/0x1b0 mm/vma.c:380
 exit_mmap+0x4e2/0xb20 mm/mmap.c:1692
 __mmput+0x12a/0x4c0 kernel/fork.c:1353
 mmput+0x62/0x70 kernel/fork.c:1375
 exit_mm kernel/exit.c:570 [inline]
 do_exit+0x9bf/0x2d70 kernel/exit.c:925
 do_group_exit+0xd3/0x2a0 kernel/exit.c:1087
 __do_sys_exit_group kernel/exit.c:1098 [inline]
 __se_sys_exit_group kernel/exit.c:1096 [inline]
 __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1096
 x64_sys_call+0x151f/0x1720 arch/x86/include/generated/asm/syscalls_64.h:232
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f44ec464b49
Code: Unable to access opcode bytes at 0x7f44ec464b1f.
RSP: 002b:00007ffc68920f08 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f44ec464b49
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000001
RBP: 00007f44ec4e02b0 R08: ffffffffffffffb8 R09: 0000000100000000
R10: 0000000000000012 R11: 0000000000000246 R12: 00007f44ec4e02b0
R13: 0000000000000000 R14: 00007f44ec4e0d00 R15: 00007f44ec436160
 </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] 4+ messages in thread

* [PATCH] ring buffer: propagate __rb_map_vma return value to caller
@ 2025-10-07 17:12 Ankit Khushwaha
  2025-10-07 17:45 ` [syzbot] [trace?] WARNING in tracing_buffers_mmap_close syzbot
  2025-10-08 16:11 ` [PATCH] ring buffer: propagate __rb_map_vma return value to caller Steven Rostedt
  0 siblings, 2 replies; 4+ messages in thread
From: Ankit Khushwaha @ 2025-10-07 17:12 UTC (permalink / raw)
  To: linux-kernel, linux-trace-kernel
  Cc: david.hunter.linux, skhan, linux-kernel-mentees, Steven Rostedt,
	Masami Hiramatsu, Mathieu Desnoyers, Ankit Khushwaha,
	syzbot+ddc001b92c083dbf2b97

The return value from `__rb_map_vma()`, which rejects writable or
executable mappings (VM_WRITE, VM_EXEC, or !VM_MAYSHARE), was being
ignored. As a result the caller of `__rb_map_vma` always returned 0 
even when the mapping had actually failed, allowing it to proceed
with an invalid VMA.

Reported-by: syzbot+ddc001b92c083dbf2b97@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=194151be8eaebd826005329b2e123aecae714bdb
Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
---

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 4ff71af020ae

---
 kernel/trace/ring_buffer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 43460949ad3f..4efb90364f48 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -7271,6 +7271,8 @@ int ring_buffer_map(struct trace_buffer *buffer, int cpu,
 		cpu_buffer->subbuf_ids = NULL;
 		rb_free_meta_page(cpu_buffer);
 		atomic_dec(&cpu_buffer->resize_disabled);
+		/* VM failed to be mapped */
+		return err;
 	}
 
 	return 0;
-- 
2.51.0


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

* Re: [syzbot] [trace?] WARNING in tracing_buffers_mmap_close
  2025-10-07 17:12 [PATCH] ring buffer: propagate __rb_map_vma return value to caller Ankit Khushwaha
@ 2025-10-07 17:45 ` syzbot
  2025-10-08 16:11 ` [PATCH] ring buffer: propagate __rb_map_vma return value to caller Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: syzbot @ 2025-10-07 17:45 UTC (permalink / raw)
  To: ankitkhushwaha.linux, david.hunter.linux, linux-kernel-mentees,
	linux-kernel, linux-trace-kernel, mathieu.desnoyers, mhiramat,
	rostedt, skhan, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+ddc001b92c083dbf2b97@syzkaller.appspotmail.com
Tested-by: syzbot+ddc001b92c083dbf2b97@syzkaller.appspotmail.com

Tested on:

commit:         4ff71af0 Merge tag 'net-6.17-rc8' of git://git.kernel...
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=17676892580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=595e5938a1dd5b4e
dashboard link: https://syzkaller.appspot.com/bug?extid=ddc001b92c083dbf2b97
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=1249d1e2580000

Note: testing is done by a robot and is best-effort only.

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

* Re: [PATCH] ring buffer: propagate __rb_map_vma return value to caller
  2025-10-07 17:12 [PATCH] ring buffer: propagate __rb_map_vma return value to caller Ankit Khushwaha
  2025-10-07 17:45 ` [syzbot] [trace?] WARNING in tracing_buffers_mmap_close syzbot
@ 2025-10-08 16:11 ` Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2025-10-08 16:11 UTC (permalink / raw)
  To: Ankit Khushwaha
  Cc: linux-kernel, linux-trace-kernel, david.hunter.linux, skhan,
	linux-kernel-mentees, Masami Hiramatsu, Mathieu Desnoyers,
	syzbot+ddc001b92c083dbf2b97

On Tue,  7 Oct 2025 22:42:56 +0530
Ankit Khushwaha <ankitkhushwaha.linux@gmail.com> wrote:

Note, tracing subsystem expects the subject to start with a capital letter:

 ring buffer: Propagate __rb_map_vma return value to caller

> The return value from `__rb_map_vma()`, which rejects writable or
> executable mappings (VM_WRITE, VM_EXEC, or !VM_MAYSHARE), was being
> ignored. As a result the caller of `__rb_map_vma` always returned 0 
> even when the mapping had actually failed, allowing it to proceed
> with an invalid VMA.
> 
> Reported-by: syzbot+ddc001b92c083dbf2b97@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?id=194151be8eaebd826005329b2e123aecae714bdb
> Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
> ---
> 
> #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 4ff71af020ae
> 
> ---
>  kernel/trace/ring_buffer.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index 43460949ad3f..4efb90364f48 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -7271,6 +7271,8 @@ int ring_buffer_map(struct trace_buffer *buffer, int cpu,
>  		cpu_buffer->subbuf_ids = NULL;
>  		rb_free_meta_page(cpu_buffer);
>  		atomic_dec(&cpu_buffer->resize_disabled);
> +		/* VM failed to be mapped */

No need to add the comment. It's obvious what happened.

> +		return err;

Don't return here.

>  	}
>  
>  	return 0;

Change this to:

	return err;

as after that if statement, err will be 0 on success or the value you want
to return.

-- Steve

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

end of thread, other threads:[~2025-10-08 16:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 17:12 [PATCH] ring buffer: propagate __rb_map_vma return value to caller Ankit Khushwaha
2025-10-07 17:45 ` [syzbot] [trace?] WARNING in tracing_buffers_mmap_close syzbot
2025-10-08 16:11 ` [PATCH] ring buffer: propagate __rb_map_vma return value to caller Steven Rostedt
  -- strict thread matches above, loose matches on Subject: below --
2024-12-15 20:34 [syzbot] [trace?] WARNING in tracing_buffers_mmap_close syzbot

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