BUG: sleeping function called from invalid context in do_con_write

From: syzbot
Date: Thu Dec 26 2019 - 16:25:19 EST


Hello,

syzbot found the following crash on:

HEAD commit: 46cf053e Linux 5.5-rc3
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11c3fa15e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=ed9d672709340e35
dashboard link: https://syzkaller.appspot.com/bug?extid=c9278c0d201bb6cff538
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+c9278c0d201bb6cff538@xxxxxxxxxxxxxxxxxxxxxxxxx

BUG: sleeping function called from invalid context at drivers/tty/vt/vt.c:2568
in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 30842, name: syz-executor.5
3 locks held by syz-executor.5/30842:
#0: ffff888094d05090 (&tty->ldisc_sem){++++}, at: ldsem_down_read+0x33/0x40 drivers/tty/tty_ldsem.c:340
#1: ffff888094d05390 (&(&tty->flow_lock)->rlock){....}, at: spin_lock_irq include/linux/spinlock.h:363 [inline]
#1: ffff888094d05390 (&(&tty->flow_lock)->rlock){....}, at: n_tty_ioctl_helper drivers/tty/tty_ioctl.c:914 [inline]
#1: ffff888094d05390 (&(&tty->flow_lock)->rlock){....}, at: n_tty_ioctl_helper+0xd1/0x3b0 drivers/tty/tty_ioctl.c:894
#2: ffff888094d05090 (&tty->ldisc_sem){++++}, at: tty_ldisc_ref+0x22/0x90 drivers/tty/tty_ldisc.c:288
irq event stamp: 3506
hardirqs last enabled at (3505): [<ffffffff81b29986>] kfree+0x226/0x2c0 mm/slab.c:3758
hardirqs last disabled at (3506): [<ffffffff87c8c09a>] __raw_spin_lock_irq include/linux/spinlock_api_smp.h:126 [inline]
hardirqs last disabled at (3506): [<ffffffff87c8c09a>] _raw_spin_lock_irq+0x3a/0x80 kernel/locking/spinlock.c:167
softirqs last enabled at (3386): [<ffffffff864dc83b>] sock_net include/net/sock.h:2474 [inline]
softirqs last enabled at (3386): [<ffffffff864dc83b>] netlink_release+0xd4b/0x1c60 net/netlink/af_netlink.c:799
softirqs last disabled at (3384): [<ffffffff864dc7ff>] netlink_release+0xd0f/0x1c60 net/netlink/af_netlink.c:780
Preemption disabled at:
[<ffffffff83dc30f1>] spin_lock_irq include/linux/spinlock.h:363 [inline]
[<ffffffff83dc30f1>] n_tty_ioctl_helper drivers/tty/tty_ioctl.c:914 [inline]
[<ffffffff83dc30f1>] n_tty_ioctl_helper+0xd1/0x3b0 drivers/tty/tty_ioctl.c:894
CPU: 0 PID: 30842 Comm: syz-executor.5 Not tainted 5.5.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x197/0x210 lib/dump_stack.c:118
___might_sleep.cold+0x1fb/0x23e kernel/sched/core.c:6800
__might_sleep+0x95/0x190 kernel/sched/core.c:6753
do_con_write.part.0+0xa6/0x1ef0 drivers/tty/vt/vt.c:2568
do_con_write drivers/tty/vt/vt.c:2565 [inline]
con_write+0x46/0xd0 drivers/tty/vt/vt.c:3135
n_hdlc_send_frames+0x29a/0x480 drivers/tty/n_hdlc.c:403
n_hdlc_tty_wakeup+0xc0/0xe0 drivers/tty/n_hdlc.c:479
tty_wakeup+0xe9/0x120 drivers/tty/tty_io.c:536
__start_tty.part.0+0xd6/0x100 drivers/tty/tty_io.c:808
__start_tty+0x64/0x80 drivers/tty/tty_io.c:803
n_tty_ioctl_helper drivers/tty/tty_ioctl.c:917 [inline]
n_tty_ioctl_helper+0x355/0x3b0 drivers/tty/tty_ioctl.c:894
n_hdlc_tty_ioctl+0x107/0x360 drivers/tty/n_hdlc.c:783
tty_ioctl+0xaf9/0x14f0 drivers/tty/tty_io.c:2669
vfs_ioctl fs/ioctl.c:47 [inline]
file_ioctl fs/ioctl.c:545 [inline]
do_vfs_ioctl+0x977/0x14e0 fs/ioctl.c:732
ksys_ioctl+0xab/0xd0 fs/ioctl.c:749
__do_sys_ioctl fs/ioctl.c:756 [inline]
__se_sys_ioctl fs/ioctl.c:754 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:754
do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45a919
Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fc3234f5c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045a919
RDX: 0000000000000001 RSI: 000000000000540a RDI: 0000000000000007
RBP: 000000000075bfc8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fc3234f66d4
R13: 00000000004c5a99 R14: 00000000004dbdc8 R15: 00000000ffffffff


---
This bug 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@xxxxxxxxxxxxxxxxx

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