syzbot


possible deadlock in n_tty_receive_buf_common
Status: upstream: reported C repro on 2020/02/14 17:37
Reported-by: syzbot+41a045bca47dde704c4c@syzkaller.appspotmail.com
First crash: 834d, last: 785d

Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: WARNING in sysfs_warn_dup (log)
Repro: C syz .config

Fix bisection: failed (bisect log)

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.6.0-rc3-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor368/10776 is trying to acquire lock:
ffff8880974d72a0 (&tty->termios_rwsem){++++}, at: n_tty_receive_buf_common+0x8a/0x2b70 drivers/tty/n_tty.c:1705

but task is already holding lock:
ffffffff8a13cc40 (sel_lock){+.+.}, at: paste_selection+0x15a/0x4d0 drivers/tty/vt/selection.c:374

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (sel_lock){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:956 [inline]
       __mutex_lock+0x156/0x13c0 kernel/locking/mutex.c:1103
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1118
       set_selection_kernel+0x39d/0x13d0 drivers/tty/vt/selection.c:217
       set_selection_user+0x95/0xd9 drivers/tty/vt/selection.c:181
       tioclinux+0x11c/0x480 drivers/tty/vt/vt.c:3050
       vt_ioctl+0x1a41/0x26c0 drivers/tty/vt/vt_ioctl.c:364
       tty_ioctl+0xa37/0x14f0 drivers/tty/tty_io.c:2660
       vfs_ioctl fs/ioctl.c:47 [inline]
       ksys_ioctl+0x123/0x180 fs/ioctl.c:763
       __do_sys_ioctl fs/ioctl.c:772 [inline]
       __se_sys_ioctl fs/ioctl.c:770 [inline]
       __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:770
       do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #1 (console_lock){+.+.}:
       console_lock+0x47/0x80 kernel/printk/printk.c:2289
       con_flush_chars drivers/tty/vt/vt.c:3223 [inline]
       con_flush_chars+0x3d/0xa0 drivers/tty/vt/vt.c:3215
       n_tty_write+0xc85/0x1080 drivers/tty/n_tty.c:2350
       do_tty_write drivers/tty/tty_io.c:962 [inline]
       tty_write+0x496/0x7f0 drivers/tty/tty_io.c:1046
       __vfs_write+0x8a/0x110 fs/read_write.c:494
       vfs_write+0x268/0x5d0 fs/read_write.c:558
       ksys_write+0x14f/0x290 fs/read_write.c:611
       __do_sys_write fs/read_write.c:623 [inline]
       __se_sys_write fs/read_write.c:620 [inline]
       __x64_sys_write+0x73/0xb0 fs/read_write.c:620
       do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&tty->termios_rwsem){++++}:
       check_prev_add kernel/locking/lockdep.c:2475 [inline]
       check_prevs_add kernel/locking/lockdep.c:2580 [inline]
       validate_chain kernel/locking/lockdep.c:2970 [inline]
       __lock_acquire+0x2596/0x4a00 kernel/locking/lockdep.c:3954
       lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4484
       down_read+0x95/0x430 kernel/locking/rwsem.c:1495
       n_tty_receive_buf_common+0x8a/0x2b70 drivers/tty/n_tty.c:1705
       n_tty_receive_buf2+0x34/0x40 drivers/tty/n_tty.c:1777
       tty_ldisc_receive_buf+0xad/0x1c0 drivers/tty/tty_buffer.c:461
       paste_selection+0x1ff/0x4d0 drivers/tty/vt/selection.c:389
       tioclinux+0x133/0x480 drivers/tty/vt/vt.c:3055
       vt_ioctl+0x1a41/0x26c0 drivers/tty/vt/vt_ioctl.c:364
       tty_ioctl+0xa37/0x14f0 drivers/tty/tty_io.c:2660
       vfs_ioctl fs/ioctl.c:47 [inline]
       ksys_ioctl+0x123/0x180 fs/ioctl.c:763
       __do_sys_ioctl fs/ioctl.c:772 [inline]
       __se_sys_ioctl fs/ioctl.c:770 [inline]
       __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:770
       do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

other info that might help us debug this:

Chain exists of:
  &tty->termios_rwsem --> console_lock --> sel_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sel_lock);
                               lock(console_lock);
                               lock(sel_lock);
  lock(&tty->termios_rwsem);

 *** DEADLOCK ***

3 locks held by syz-executor368/10776:
 #0: ffff8880974d7090 (&tty->ldisc_sem){++++}, at: ldsem_down_read+0x33/0x40 drivers/tty/tty_ldsem.c:340
 #1: ffff8880aa5be0a8 (&buf->lock){+.+.}, at: tty_buffer_lock_exclusive+0x30/0x40 drivers/tty/tty_buffer.c:61
 #2: ffffffff8a13cc40 (sel_lock){+.+.}, at: paste_selection+0x15a/0x4d0 drivers/tty/vt/selection.c:374

stack backtrace:
CPU: 0 PID: 10776 Comm: syz-executor368 Not tainted 5.6.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
 print_circular_bug.isra.0.cold+0x163/0x172 kernel/locking/lockdep.c:1684
 check_noncircular+0x32e/0x3e0 kernel/locking/lockdep.c:1808
 check_prev_add kernel/locking/lockdep.c:2475 [inline]
 check_prevs_add kernel/locking/lockdep.c:2580 [inline]
 validate_chain kernel/locking/lockdep.c:2970 [inline]
 __lock_acquire+0x2596/0x4a00 kernel/locking/lockdep.c:3954
 lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4484
 down_read+0x95/0x430 kernel/locking/rwsem.c:1495
 n_tty_receive_buf_common+0x8a/0x2b70 drivers/tty/n_tty.c:1705
 n_tty_receive_buf2+0x34/0x40 drivers/tty/n_tty.c:1777
 tty_ldisc_receive_buf+0xad/0x1c0 drivers/tty/tty_buffer.c:461
 paste_selection+0x1ff/0x4d0 drivers/tty/vt/selection.c:389
 tioclinux+0x133/0x480 drivers/tty/vt/vt.c:3055
 vt_ioctl+0x1a41/0x26c0 drivers/tty/vt/vt_ioctl.c:364
 tty_ioctl+0xa37/0x14f0 drivers/tty/tty_io.c:2660
 vfs_ioctl fs/ioctl.c:47 [inline]
 ksys_ioctl+0x123/0x180 fs/ioctl.c:763
 __do_sys_ioctl fs/ioctl.c:772 [inline]
 __se_sys_ioctl fs/ioctl.c:770 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:770
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440239
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 0f 83 5b 14 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fff0aba0a98 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 

Crashes (698):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2020/02/29 15:11 upstream f8788d86ab28 59b57593 .config log report syz C
ci-upstream-kasan-gce-root 2020/02/28 14:56 upstream f8788d86ab28 59b57593 .config log report syz C
ci-upstream-kasan-gce-smack-root 2020/02/26 13:45 upstream f8788d86ab28 59b57593 .config log report syz C
ci-upstream-kasan-gce-selinux-root 2020/02/25 06:44 upstream f8788d86ab28 59b57593 .config log report syz C
ci-upstream-kasan-gce-root 2020/02/24 08:06 upstream d2eee25858f2 d801cb02 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/03/30 15:39 linux-next 770fbb32d34e c8d1cc20 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/03/06 17:29 linux-next c99b17ac0399 c88c7b75 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/02/23 09:40 linux-next bee46b309a13 2c36e7a7 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/02/14 09:14 linux-next 9f01828e9e16 5d7b90f1 .config log report syz C
ci-upstream-kasan-gce-root 2020/03/08 07:25 upstream c20037652700 2e9971bb .config log report syz
ci-upstream-kasan-gce-smack-root 2020/03/05 11:30 upstream 63623fd44972 c88c7b75 .config log report syz
ci-upstream-linux-next-kasan-gce-root 2020/03/21 08:28 linux-next 770fbb32d34e 2c31c529 .config log report syz
ci-upstream-kasan-gce-root 2020/03/09 07:09 upstream 61a09258f2e5 2e9971bb .config log report
ci-upstream-kasan-gce-selinux-root 2020/03/09 05:41 upstream 61a09258f2e5 2e9971bb .config log report
ci-upstream-kasan-gce-smack-root 2020/03/07 23:54 upstream 63849c8f4107 2e9971bb .config log report
ci-qemu-upstream 2020/03/05 11:23 upstream 776e49e8ddb5 b655d91b .config log report
ci-qemu-upstream-386 2020/02/22 09:13 upstream 54dedb5b571d 2c36e7a7 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/03 18:14 linux-next 770fbb32d34e 5ed396e6 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/03 12:03 linux-next 770fbb32d34e 5ed396e6 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/03 07:37 linux-next 770fbb32d34e a34e2c33 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/03 05:39 linux-next 770fbb32d34e a34e2c33 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/02 22:16 linux-next 770fbb32d34e a34e2c33 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/02 18:34 linux-next 770fbb32d34e a34e2c33 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/02 15:52 linux-next 770fbb32d34e a34e2c33 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/01 20:34 linux-next 770fbb32d34e a34e2c33 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/01 12:28 linux-next 770fbb32d34e a34e2c33 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/01 06:15 linux-next 770fbb32d34e a34e2c33 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/01 04:28 linux-next 770fbb32d34e a34e2c33 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/31 10:19 linux-next 770fbb32d34e c8d1cc20 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/31 02:48 linux-next 770fbb32d34e c8d1cc20 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/30 22:26 linux-next 770fbb32d34e c8d1cc20 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/30 21:08 linux-next 770fbb32d34e c8d1cc20 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/30 18:40 linux-next 770fbb32d34e c8d1cc20 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/30 06:36 linux-next 770fbb32d34e 05736b29 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/29 23:19 linux-next 770fbb32d34e 05736b29 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/29 19:52 linux-next 770fbb32d34e 05736b29 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/29 12:41 linux-next 770fbb32d34e 05736b29 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/29 11:12 linux-next 770fbb32d34e 05736b29 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/29 09:51 linux-next 770fbb32d34e 05736b29 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/29 07:41 linux-next 770fbb32d34e 05736b29 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/29 05:21 linux-next 770fbb32d34e 05736b29 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/29 02:43 linux-next 770fbb32d34e 05736b29 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/28 17:11 linux-next 770fbb32d34e f1ebdfba .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/28 11:22 linux-next 770fbb32d34e f1ebdfba .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/28 09:43 linux-next 770fbb32d34e 831e9a81 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/28 07:57 linux-next 770fbb32d34e 831e9a81 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/28 03:12 linux-next 770fbb32d34e 831e9a81 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/27 12:36 linux-next 770fbb32d34e 7d95711b .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/26 13:18 linux-next 770fbb32d34e e8e6c7d2 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/26 01:34 linux-next 770fbb32d34e 41f049cc .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/25 22:47 linux-next 770fbb32d34e 41f049cc .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/25 11:40 linux-next 770fbb32d34e 41f049cc .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/25 07:19 linux-next 770fbb32d34e 41f049cc .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/24 19:47 linux-next 770fbb32d34e 68660b21 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/24 13:33 linux-next 770fbb32d34e 33e14df3 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/24 12:29 linux-next 770fbb32d34e 33e14df3 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/24 05:41 linux-next 770fbb32d34e 33e14df3 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/23 21:01 linux-next 770fbb32d34e 84f999d6 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/23 13:20 linux-next 770fbb32d34e 78267cec .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/23 06:16 linux-next 770fbb32d34e 78267cec .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/23 05:41 linux-next 770fbb32d34e 78267cec .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/22 03:45 linux-next 770fbb32d34e 78267cec .config log report
ci-upstream-linux-next-kasan-gce-root 2020/02/14 02:43 linux-next 9f01828e9e16 c5ed587f .config log report