* [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter
@ 2025-01-31 20:47 syzbot
2025-02-01 1:04 ` Edward Adam Davis
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: syzbot @ 2025-01-31 20:47 UTC (permalink / raw)
To: brauner, jack, linux-fsdevel, linux-kernel, syzkaller-bugs, viro
Hello,
syzbot found the following issue on:
HEAD commit: 69e858e0b8b2 Merge tag 'uml-for-linus-6.14-rc1' of git://g..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=127f4518580000
kernel config: https://syzkaller.appspot.com/x/.config?x=98d83cc1742b7377
dashboard link: https://syzkaller.appspot.com/bug?extid=c041985778e4069e1ce3
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=1493f6b0580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13c2dddf980000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/3d07b0558b0e/disk-69e858e0.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/e5e2250eb3b1/vmlinux-69e858e0.xz
kernel image: https://storage.googleapis.com/syzbot-assets/3e676d17effc/bzImage-69e858e0.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c041985778e4069e1ce3@syzkaller.appspotmail.com
Code: 48 83 c4 28 c3 e8 17 1a 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe566caee8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007ffe566caef0 RCX: 00007f1f6401a2e9
RDX: 0000000000006c64 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000000001 R08: 00007ffe566cac87 R09: 00007f1f64080032
R10: 0000000000000001 R11: 0000000000000246 R12: 00007f1f64085618
R13: 00007ffe566cb0c8 R14: 0000000000000001 R15: 0000000000000001
</TASK>
=====================================
WARNING: bad unlock balance detected!
6.13.0-syzkaller-09760-g69e858e0b8b2 #0 Not tainted
-------------------------------------
syz-executor359/5828 is trying to release lock (event_mutex) at:
[<ffffffff8239231f>] seq_read_iter+0x5ff/0x12b0 fs/seq_file.c:251
but there are no more locks to release!
other info that might help us debug this:
1 lock held by syz-executor359/5828:
#0: ffff88802fd120a0 (&p->lock){+.+.}-{4:4}, at: seq_read_iter+0xd8/0x12b0 fs/seq_file.c:182
stack backtrace:
CPU: 0 UID: 0 PID: 5828 Comm: syz-executor359 Not tainted 6.13.0-syzkaller-09760-g69e858e0b8b2 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
print_unlock_imbalance_bug kernel/locking/lockdep.c:5289 [inline]
print_unlock_imbalance_bug+0x1aa/0x1f0 kernel/locking/lockdep.c:5263
__lock_release kernel/locking/lockdep.c:5528 [inline]
lock_release+0x525/0x6f0 kernel/locking/lockdep.c:5872
__mutex_unlock_slowpath+0xa3/0x6a0 kernel/locking/mutex.c:891
seq_read_iter+0x5ff/0x12b0 fs/seq_file.c:251
seq_read+0x39f/0x4e0 fs/seq_file.c:162
vfs_read+0x1df/0xbf0 fs/read_write.c:563
ksys_read+0x12b/0x250 fs/read_write.c:708
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:0x7f1f6401a2e9
Code: 48 83 c4 28 c3 e8 17 1a 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe566caee8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007ffe566caef0 RCX: 00007f1f6401a2e9
RDX: 0000000000006c64 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000000001 R08: 00007ffe566cac87 R09: 00007f1f64080032
R10: 0000000000000001 R11: 0000000000000246 R12: 00007f1f64085618
R13: 00007ffe566
----------------
Code disassembly (best guess):
0: 48 83 c4 28 add $0x28,%rsp
4: c3 ret
5: e8 17 1a 00 00 call 0x1a21
a: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
11: 48 89 f8 mov %rdi,%rax
14: 48 89 f7 mov %rsi,%rdi
17: 48 89 d6 mov %rdx,%rsi
1a: 48 89 ca mov %rcx,%rdx
1d: 4d 89 c2 mov %r8,%r10
20: 4d 89 c8 mov %r9,%r8
23: 4c 8b 4c 24 08 mov 0x8(%rsp),%r9
28: 0f 05 syscall
* 2a: 48 3d 01 f0 ff ff cmp $0xfffffffffffff001,%rax <-- trapping instruction
30: 73 01 jae 0x33
32: c3 ret
33: 48 c7 c1 b8 ff ff ff mov $0xffffffffffffffb8,%rcx
3a: f7 d8 neg %eax
3c: 64 89 01 mov %eax,%fs:(%rcx)
3f: 48 rex.W
---
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] 11+ messages in thread* Re: [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter
2025-01-31 20:47 [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter syzbot
@ 2025-02-01 1:04 ` Edward Adam Davis
2025-02-01 1:24 ` syzbot
2025-02-01 2:27 ` Edward Adam Davis
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Edward Adam Davis @ 2025-02-01 1:04 UTC (permalink / raw)
To: syzbot+c041985778e4069e1ce3; +Cc: linux-kernel, syzkaller-bugs
#syz test: https://github.com/ea1davis/linux ftr/syz
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter
2025-01-31 20:47 [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter syzbot
2025-02-01 1:04 ` Edward Adam Davis
@ 2025-02-01 2:27 ` Edward Adam Davis
2025-02-01 2:48 ` syzbot
2025-02-01 3:43 ` Edward Adam Davis
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Edward Adam Davis @ 2025-02-01 2:27 UTC (permalink / raw)
To: syzbot+c041985778e4069e1ce3; +Cc: linux-kernel, syzkaller-bugs
#syz test: https://github.com/ea1davis/linux ftr/syz
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter
2025-01-31 20:47 [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter syzbot
2025-02-01 1:04 ` Edward Adam Davis
2025-02-01 2:27 ` Edward Adam Davis
@ 2025-02-01 3:43 ` Edward Adam Davis
2025-02-01 4:04 ` syzbot
2025-02-01 5:30 ` Edward Adam Davis
2025-02-01 5:50 ` [PATCH] tracing: keep the event lock balanced Edward Adam Davis
4 siblings, 1 reply; 11+ messages in thread
From: Edward Adam Davis @ 2025-02-01 3:43 UTC (permalink / raw)
To: syzbot+c041985778e4069e1ce3; +Cc: linux-kernel, syzkaller-bugs
#syz test: https://github.com/ea1davis/linux ftr/syz
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter
2025-01-31 20:47 [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter syzbot
` (2 preceding siblings ...)
2025-02-01 3:43 ` Edward Adam Davis
@ 2025-02-01 5:30 ` Edward Adam Davis
2025-02-01 5:50 ` syzbot
2025-02-01 5:50 ` [PATCH] tracing: keep the event lock balanced Edward Adam Davis
4 siblings, 1 reply; 11+ messages in thread
From: Edward Adam Davis @ 2025-02-01 5:30 UTC (permalink / raw)
To: syzbot+c041985778e4069e1ce3; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 4cb275316e51..dad032912e1e 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1600,11 +1600,12 @@ static void *s_start(struct seq_file *m, loff_t *pos)
struct set_event_iter *iter;
loff_t l;
+ mutex_lock(&event_mutex);
+
iter = kzalloc(sizeof(*iter), GFP_KERNEL);
- if (!iter)
+ if (!iter) {
return NULL;
-
- mutex_lock(&event_mutex);
+ }
iter->type = SET_EVENT_FILE;
iter->file = list_entry(&tr->events, struct trace_event_file, list);
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH] tracing: keep the event lock balanced
2025-01-31 20:47 [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter syzbot
` (3 preceding siblings ...)
2025-02-01 5:30 ` Edward Adam Davis
@ 2025-02-01 5:50 ` Edward Adam Davis
4 siblings, 0 replies; 11+ messages in thread
From: Edward Adam Davis @ 2025-02-01 5:50 UTC (permalink / raw)
To: syzbot+c041985778e4069e1ce3
Cc: rostedt, mhiramat, mathieu.desnoyers, linux-kernel,
syzkaller-bugs
syzbot reported a bad unlock balance in seq_read_iter(). [1]
The reproducer uses "/proc/thread-self/fail-nth" to make s_start() fail when
applying for memory, thus exiting s_start() before acquiring event_mutex.
This destroys the lock holding and reclaiming process in the start() and
stop() processes in seq_read_iter().
Hold the event mutex before allocating memory in s_start() to avoid this
problem.
[1]
WARNING: bad unlock balance detected!
6.13.0-syzkaller-09760-g69e858e0b8b2 #0 Not tainted
-------------------------------------
syz-executor359/5828 is trying to release lock (event_mutex) at:
[<ffffffff8239231f>] seq_read_iter+0x5ff/0x12b0 fs/seq_file.c:251
but there are no more locks to release!
other info that might help us debug this:
1 lock held by syz-executor359/5828:
#0: ffff88802fd120a0 (&p->lock){+.+.}-{4:4}, at: seq_read_iter+0xd8/0x12b0 fs/seq_file.c:182
stack backtrace:
CPU: 0 UID: 0 PID: 5828 Comm: syz-executor359 Not tainted 6.13.0-syzkaller-09760-g69e858e0b8b2 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
print_unlock_imbalance_bug kernel/locking/lockdep.c:5289 [inline]
print_unlock_imbalance_bug+0x1aa/0x1f0 kernel/locking/lockdep.c:5263
__lock_release kernel/locking/lockdep.c:5528 [inline]
lock_release+0x525/0x6f0 kernel/locking/lockdep.c:5872
__mutex_unlock_slowpath+0xa3/0x6a0 kernel/locking/mutex.c:891
seq_read_iter+0x5ff/0x12b0 fs/seq_file.c:251
seq_read+0x39f/0x4e0 fs/seq_file.c:162
vfs_read+0x1df/0xbf0 fs/read_write.c:563
ksys_read+0x12b/0x250 fs/read_write.c:708
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
Fixes: b355247df104 ("tracing: Cache ":mod:" events for modules not loaded yet")
Reported-by: syzbot+c041985778e4069e1ce3@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c041985778e4069e1ce3
Tested-by: syzbot+c041985778e4069e1ce3@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
kernel/trace/trace_events.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 4cb275316e51..991dd17887ea 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1600,12 +1600,12 @@ static void *s_start(struct seq_file *m, loff_t *pos)
struct set_event_iter *iter;
loff_t l;
+ mutex_lock(&event_mutex);
+
iter = kzalloc(sizeof(*iter), GFP_KERNEL);
if (!iter)
return NULL;
- mutex_lock(&event_mutex);
-
iter->type = SET_EVENT_FILE;
iter->file = list_entry(&tr->events, struct trace_event_file, list);
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
[parent not found: <tencent_58E8BAED46CE2479A26D8C2E716D5895940A@qq.com>]
end of thread, other threads:[~2025-02-01 6:04 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-31 20:47 [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter syzbot
2025-02-01 1:04 ` Edward Adam Davis
2025-02-01 1:24 ` syzbot
2025-02-01 2:27 ` Edward Adam Davis
2025-02-01 2:48 ` syzbot
2025-02-01 3:43 ` Edward Adam Davis
2025-02-01 4:04 ` syzbot
2025-02-01 5:30 ` Edward Adam Davis
2025-02-01 5:50 ` syzbot
2025-02-01 5:50 ` [PATCH] tracing: keep the event lock balanced Edward Adam Davis
[not found] <tencent_58E8BAED46CE2479A26D8C2E716D5895940A@qq.com>
2025-02-01 2:03 ` [syzbot] [fs?] WARNING: bad unlock balance in seq_read_iter syzbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox