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: 965d, last: 916d

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)
Patch testing requests:
Created Duration User Patch Repo Result
2022/09/17 06:29 16m upstream OK log
2022/09/17 02:29 15m upstream OK log
2022/09/16 22:29 15m upstream OK log
2022/09/14 07:27 16m upstream OK log
2022/09/14 04:27 16m upstream OK log
2022/09/13 16:27 16m upstream OK log
2022/09/13 13:27 10m linux-next report log
2022/09/13 12:27 16m upstream OK log
2022/09/13 09:27 10m linux-next report log
2022/09/13 04:27 10m linux-next report log
2022/09/13 01:27 10m linux-next report log
2022/09/12 21:27 10m linux-next report log

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.6.0-rc3-next-20200228-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor385/9522 is trying to acquire lock:
ffff8880a1cb82a0 (&tty->termios_rwsem){++++}, at: n_tty_receive_buf_common+0x87/0x2ac0 drivers/tty/n_tty.c:1705

but task is already holding lock:
ffffffff89f414c0 (sel_lock){+.+.}, at: paste_selection+0x155/0x490 drivers/tty/vt/selection.c:379

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
       set_selection_kernel+0x38a/0x13c0 drivers/tty/vt/selection.c:222
       set_selection_user+0x94/0xd7 drivers/tty/vt/selection.c:186
       tioclinux+0x115/0x480 drivers/tty/vt/vt.c:3051
       vt_ioctl+0x18a6/0x2450 drivers/tty/vt/vt_ioctl.c:379
       tty_ioctl+0xedd/0x1440 drivers/tty/tty_io.c:2660
       vfs_ioctl fs/ioctl.c:47 [inline]
       ksys_ioctl+0x11a/0x180 fs/ioctl.c:763
       __do_sys_ioctl fs/ioctl.c:772 [inline]
       __se_sys_ioctl fs/ioctl.c:770 [inline]
       __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:770
       do_syscall_64+0xf6/0x790 arch/x86/entry/common.c:295
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #1 (console_lock){+.+.}:
       console_lock+0x44/0x80 kernel/printk/printk.c:2290
       con_flush_chars drivers/tty/vt/vt.c:3224 [inline]
       con_flush_chars+0x35/0x90 drivers/tty/vt/vt.c:3216
       n_tty_write+0xd49/0xf90 drivers/tty/n_tty.c:2350
       do_tty_write drivers/tty/tty_io.c:962 [inline]
       tty_write+0x48f/0x7f0 drivers/tty/tty_io.c:1046
       __vfs_write+0x76/0x100 fs/read_write.c:494
       vfs_write+0x262/0x5c0 fs/read_write.c:558
       ksys_write+0x127/0x250 fs/read_write.c:611
       do_syscall_64+0xf6/0x790 arch/x86/entry/common.c:295
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&tty->termios_rwsem){++++}:
       check_prev_add kernel/locking/lockdep.c:2481 [inline]
       check_prevs_add kernel/locking/lockdep.c:2586 [inline]
       validate_chain kernel/locking/lockdep.c:3203 [inline]
       __lock_acquire+0x24b3/0x5270 kernel/locking/lockdep.c:4190
       lock_acquire+0x197/0x420 kernel/locking/lockdep.c:4720
       down_read+0x96/0x430 kernel/locking/rwsem.c:1492
       n_tty_receive_buf_common+0x87/0x2ac0 drivers/tty/n_tty.c:1705
       tty_ldisc_receive_buf+0xa9/0x190 drivers/tty/tty_buffer.c:461
       paste_selection+0x1e5/0x490 drivers/tty/vt/selection.c:394
       tioclinux+0x12c/0x480 drivers/tty/vt/vt.c:3056
       vt_ioctl+0x18a6/0x2450 drivers/tty/vt/vt_ioctl.c:379
       tty_ioctl+0xedd/0x1440 drivers/tty/tty_io.c:2660
       vfs_ioctl fs/ioctl.c:47 [inline]
       ksys_ioctl+0x11a/0x180 fs/ioctl.c:763
       __do_sys_ioctl fs/ioctl.c:772 [inline]
       __se_sys_ioctl fs/ioctl.c:770 [inline]
       __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:770
       do_syscall_64+0xf6/0x790 arch/x86/entry/common.c:295
       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-executor385/9522:
 #0: ffff8880a1cb8090 (&tty->ldisc_sem){++++}, at: tty_ldisc_ref_wait+0x22/0x80 drivers/tty/tty_ldisc.c:267
 #1: ffff8880a97f90a8 (&buf->lock){+.+.}, at: paste_selection+0x122/0x490 drivers/tty/vt/selection.c:376
 #2: ffffffff89f414c0 (sel_lock){+.+.}, at: paste_selection+0x155/0x490 drivers/tty/vt/selection.c:379

stack backtrace:
CPU: 0 PID: 9522 Comm: syz-executor385 Not tainted 5.6.0-rc3-next-20200228-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+0x188/0x20d lib/dump_stack.c:118
 check_noncircular+0x32e/0x3e0 kernel/locking/lockdep.c:1812
 check_prev_add kernel/locking/lockdep.c:2481 [inline]
 check_prevs_add kernel/locking/lockdep.c:2586 [inline]
 validate_chain kernel/locking/lockdep.c:3203 [inline]
 __lock_acquire+0x24b3/0x5270 kernel/locking/lockdep.c:4190
 lock_acquire+0x197/0x420 kernel/locking/lockdep.c:4720
 down_read+0x96/0x430 kernel/locking/rwsem.c:1492
 n_tty_receive_buf_common+0x87/0x2ac0 drivers/tty/n_tty.c:1705
 tty_ldisc_receive_buf+0xa9/0x190 drivers/tty/tty_buffer.c:461
 paste_selection+0x1e5/0x490 drivers/tty/vt/selection.c:394
 tioclinux+0x12c/0x480 drivers/tty/vt/vt.c:3056
 vt_ioctl+0x18a6/0x2450 drivers/tty/vt/vt_ioctl.c:379
 tty_ioctl+0xedd/0x1440 drivers/tty/tty_io.c:2660
 vfs_ioctl fs/ioctl.c:47 [inline]
 ksys_ioctl+0x11a/0x180 fs/ioctl.c:763
 __do_sys_ioctl fs/ioctl.c:772 [inline]
 __se_sys_ioctl fs/ioctl.c:770 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:770
 do_syscall_64+0xf6/0x790 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440219
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:00007fff27a0f0f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440219
RDX: 0000000020000200 RSI: 0

Crashes (698):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
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-linux-next-kasan-gce-root 2020/03/21 08:28 linux-next 770fbb32d34e 2c31c529 .config log report syz
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-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-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
* Struck through repros no longer work on HEAD.