syzbot


BUG: sleeping function called from invalid context in __might_resched
Status: fixed on 2022/03/08 16:11
Reported-by: syzbot+5f47a8cea6a12b77a876@syzkaller.appspotmail.com
Fix commit: 1ee33b1ca2b8 tty: n_hdlc: make n_hdlc_tty_wakeup() asynchronous
First crash: 202d, last: 195d

Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: BUG: sleeping function called from invalid context in do_con_write (log)
Repro: C syz .config
Patch testing requests:
Created Duration User Patch Repo Result
2021/11/16 09:13 15m fmdefrancesco@gmail.com patch upstream OK
2021/11/16 09:03 16m fmdefrancesco@gmail.com patch git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git -- OK
2021/11/16 08:53 0m fmdefrancesco@gmail.com patch git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git --- error
2021/11/16 07:57 10m fmdefrancesco@gmail.com patch git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git -- report log

Sample crash report:
BUG: sleeping function called from invalid context at kernel/printk/printk.c:2525
in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 6529, name: syz-executor925
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
3 locks held by syz-executor925/6529:
 #0: ffff888018d79098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x22/0x80 drivers/tty/tty_ldisc.c:252
 #1: ffff888018d79468 (&tty->flow.lock){....}-{2:2}, at: spin_lock_irq include/linux/spinlock.h:379 [inline]
 #1: ffff888018d79468 (&tty->flow.lock){....}-{2:2}, at: n_tty_ioctl_helper+0xb6/0x2d0 drivers/tty/tty_ioctl.c:877
 #2: ffff888018d79098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref+0x1d/0x80 drivers/tty/tty_ldisc.c:273
irq event stamp: 16252
hardirqs last  enabled at (16251): [<ffffffff8952dbc0>] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:151 [inline]
hardirqs last  enabled at (16251): [<ffffffff8952dbc0>] _raw_spin_unlock_irqrestore+0x50/0x70 kernel/locking/spinlock.c:194
hardirqs last disabled at (16252): [<ffffffff8952d921>] __raw_spin_lock_irq include/linux/spinlock_api_smp.h:117 [inline]
hardirqs last disabled at (16252): [<ffffffff8952d921>] _raw_spin_lock_irq+0x41/0x50 kernel/locking/spinlock.c:170
softirqs last  enabled at (14452): [<ffffffff812bc45c>] fpu_reset_fpregs arch/x86/kernel/fpu/core.c:601 [inline]
softirqs last  enabled at (14452): [<ffffffff812bc45c>] fpu_flush_thread+0x23c/0x390 arch/x86/kernel/fpu/core.c:647
softirqs last disabled at (14450): [<ffffffff812bc3eb>] fpstate_reset arch/x86/kernel/fpu/core.c:452 [inline]
softirqs last disabled at (14450): [<ffffffff812bc3eb>] fpu_flush_thread+0x1cb/0x390 arch/x86/kernel/fpu/core.c:646
Preemption disabled at:
[<0000000000000000>] 0x0
CPU: 0 PID: 6529 Comm: syz-executor925 Not tainted 5.15.0-next-20211112-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 __might_resched.cold+0x222/0x26b kernel/sched/core.c:9554
 console_lock+0x17/0x80 kernel/printk/printk.c:2525
 do_con_write+0x10f/0x1e40 drivers/tty/vt/vt.c:2908
 con_write+0x21/0x40 drivers/tty/vt/vt.c:3295
 n_hdlc_send_frames+0x24b/0x490 drivers/tty/n_hdlc.c:290
 tty_wakeup+0xe1/0x120 drivers/tty/tty_io.c:534
 __start_tty drivers/tty/tty_io.c:806 [inline]
 __start_tty+0xfb/0x130 drivers/tty/tty_io.c:799
 n_tty_ioctl_helper+0x299/0x2d0 drivers/tty/tty_ioctl.c:880
 n_hdlc_tty_ioctl+0xd2/0x340 drivers/tty/n_hdlc.c:633
 tty_ioctl+0xc69/0x1670 drivers/tty/tty_io.c:2814
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl fs/ioctl.c:860 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f16c8522349
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff6ccb8b98 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f16c8522349
RDX: 0000000000000001 RSI: 000000000000540a RDI: 0000000000000005
RBP: 00007f16c84e61d0 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000000

Crashes (9):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2021/11/13 20:12 linux-next f2e19fd15bd7 83f5c9b5 .config log report syz C BUG: sleeping function called from invalid context in __might_resched
ci-upstream-kasan-gce-root 2021/11/11 13:22 upstream debe436e77c7 75b04091 .config log report info BUG: sleeping function called from invalid context in __might_resched
ci-upstream-kasan-gce-root 2021/11/10 23:36 upstream 881007522c8f 75b04091 .config log report info BUG: sleeping function called from invalid context in __might_resched
ci-upstream-kasan-gce-selinux-root 2021/11/10 15:59 upstream cb690f5238d7 75b04091 .config log report info BUG: sleeping function called from invalid context in __might_resched
ci-upstream-kasan-gce 2021/11/08 20:51 upstream e851dfae4371 d29682f1 .config log report info BUG: sleeping function called from invalid context in __might_resched
ci-upstream-kasan-gce 2021/11/07 06:47 upstream 512b7931ad05 4c1be0be .config log report info BUG: sleeping function called from invalid context in __might_resched
ci-qemu-upstream-386 2021/11/11 20:37 upstream debe436e77c7 75b04091 .config log report info BUG: sleeping function called from invalid context in __might_resched
ci-upstream-linux-next-kasan-gce-root 2021/11/13 19:43 linux-next f2e19fd15bd7 83f5c9b5 .config log report info BUG: sleeping function called from invalid context in __might_resched
ci-upstream-linux-next-kasan-gce-root 2021/11/06 10:15 linux-next 6a37ebbe07bf 4c1be0be .config log report info BUG: sleeping function called from invalid context in __might_resched