syzbot


possible deadlock in console_trylock_spinning
Status: upstream: reported C repro on 2019/06/20 13:17
Reported-by: syzbot+fc1da0f1a577d15b64fc@syzkaller.appspotmail.com
First crash: 1072d, last: 11d

Cause bisection: introduced by (bisect log) :
commit e80b18599a39a625bc8b2e39ba3004a62f78805a
Author: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date: Fri Apr 12 11:04:54 2019 +0000

  tomoyo: Add a kernel config option for fuzzing testing.

Crash: possible deadlock in console_unlock (log)
Repro: C syz .config

Fix bisection: the fix commit could be any of (bisect log):
  6b643a07a7e4 x86/entry, ubsan, objtool: Whitelist __ubsan_handle_*()
  8e8bb06d199a x86/entry, bug: Comment the instrumentation_begin() usage for WARN()
  14d3b376b6c3 x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline()
  33aea07f30c2 compiler_attributes.h: Support no_sanitize_undefined check with GCC 4
  5144f8a8dfd7 compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr
  acf7b0bf7dcf kasan: Fix required compiler version
  734d099ba644 objtool: Don't consider vmlinux a C-file
  7b861a53e46b kasan: Bump required compiler version
  5ddbc4082e10 x86, kcsan: Add __no_kcsan to noinstr
  e3a9e681adb7 x86/entry: Fixup bad_iret vs noinstr
  c7aadc09321d x86/entry: Increase entry_stack size to a full page
  e79302ae8c8c kcsan: Remove __no_kcsan_or_inline
  145a773aef83 x86/entry: Fix #UD vs WARN more
  e82587336695 x86, kcsan: Remove __no_kcsan_or_inline usage
  2c92d787cc9f Merge branch 'linus' into x86/entry, to resolve conflicts

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.2.0-rc5+ #4 Not tainted
------------------------------------------------------
syz-executor155/8057 is trying to acquire lock:
000000009bd46550 (console_owner){-.-.}, at: console_trylock_spinning+0x12f/0x390 kernel/printk/printk.c:1718

but task is already holding lock:
0000000056678186 (&(&port->lock)->rlock){-.-.}, at: pty_write+0xbd/0x190 drivers/tty/pty.c:120

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&(&port->lock)->rlock){-.-.}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xa1/0xc0 kernel/locking/spinlock.c:159
       tty_port_tty_get drivers/tty/tty_port.c:287 [inline]
       tty_port_default_wakeup+0x20/0xa0 drivers/tty/tty_port.c:47
       tty_port_tty_wakeup+0x5a/0x70 drivers/tty/tty_port.c:387
       uart_write_wakeup+0x48/0x60 drivers/tty/serial/serial_core.c:103
       serial8250_tx_chars+0x623/0x830 drivers/tty/serial/8250/8250_port.c:1806
       serial8250_handle_irq+0x255/0x390 drivers/tty/serial/8250/8250_port.c:1879
       serial8250_default_handle_irq+0xc5/0x1d0 drivers/tty/serial/8250/8250_port.c:1895
       serial8250_interrupt+0xad/0x190 drivers/tty/serial/8250/8250_core.c:125
       __handle_irq_event_percpu+0x113/0x560 kernel/irq/handle.c:149
       handle_irq_event_percpu kernel/irq/handle.c:189 [inline]
       handle_irq_event+0x10a/0x2f0 kernel/irq/handle.c:206
       handle_edge_irq+0x29f/0xca0 kernel/irq/chip.c:822
       generic_handle_irq_desc include/linux/irqdesc.h:156 [inline]
       handle_irq+0x3e/0x50 arch/x86/kernel/irq_64.c:34
       do_IRQ+0xc4/0x1a0 arch/x86/kernel/irq.c:247
       ret_from_intr+0x0/0x1e
       native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:60
       arch_cpu_idle+0xa/0x10 arch/x86/kernel/process.c:571
       default_idle_call kernel/sched/idle.c:94 [inline]
       cpuidle_idle_call kernel/sched/idle.c:154 [inline]
       do_idle+0x18a/0x760 kernel/sched/idle.c:263
       cpu_startup_entry+0x25/0x30 kernel/sched/idle.c:354
       start_secondary+0x425/0x4c0 arch/x86/kernel/smpboot.c:265
       secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243

-> #1 (&port_lock_key){-.-.}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xa1/0xc0 kernel/locking/spinlock.c:159
       serial8250_console_write+0x1d1/0xba0 drivers/tty/serial/8250/8250_port.c:3245
       univ8250_console_write+0x50/0x70 drivers/tty/serial/8250/8250_core.c:586
       call_console_drivers kernel/printk/printk.c:1779 [inline]
       console_unlock+0x95f/0xf20 kernel/printk/printk.c:2463
       vprintk_emit+0x239/0x3a0 kernel/printk/printk.c:1986
       vprintk_default+0x28/0x30 kernel/printk/printk.c:2013
       vprintk_func+0x158/0x170 kernel/printk/printk_safe.c:386
       printk+0xc4/0x11d kernel/printk/printk.c:2046
       register_console+0xa81/0xe30 kernel/printk/printk.c:2788
       univ8250_console_init+0x4b/0x4d drivers/tty/serial/8250/8250_core.c:681
       console_init+0x56/0x9c kernel/printk/printk.c:2874
       start_kernel+0x49e/0x860 init/main.c:688
       x86_64_start_reservations+0x18/0x2e arch/x86/kernel/head64.c:470
       x86_64_start_kernel+0x7a/0x7d arch/x86/kernel/head64.c:451
       secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243

-> #0 (console_owner){-.-.}:
       lock_acquire+0x158/0x250 kernel/locking/lockdep.c:4303
       console_trylock_spinning+0x14f/0x390 kernel/printk/printk.c:1735
       vprintk_emit+0x21c/0x3a0 kernel/printk/printk.c:1985
       vprintk_default+0x28/0x30 kernel/printk/printk.c:2013
       vprintk_func+0x158/0x170 kernel/printk/printk_safe.c:386
       printk+0xc4/0x11d kernel/printk/printk.c:2046
       fail_dump lib/fault-inject.c:45 [inline]
       should_fail+0x5c5/0x860 lib/fault-inject.c:144
       __should_fail_alloc_page mm/page_alloc.c:3278 [inline]
       should_fail_alloc_page+0x55/0x60 mm/page_alloc.c:3315
       prepare_alloc_pages+0x283/0x460 mm/page_alloc.c:4598
       __alloc_pages_nodemask+0x11c/0x790 mm/page_alloc.c:4645
       __alloc_pages include/linux/gfp.h:473 [inline]
       __alloc_pages_node include/linux/gfp.h:486 [inline]
       kmem_getpages+0x46/0x480 mm/slab.c:1373
       cache_grow_begin+0x7e/0x2c0 mm/slab.c:2606
       cache_alloc_refill+0x311/0x3f0 mm/slab.c:2978
       ____cache_alloc mm/slab.c:3061 [inline]
       __do_cache_alloc mm/slab.c:3283 [inline]
       slab_alloc mm/slab.c:3318 [inline]
       __do_kmalloc mm/slab.c:3658 [inline]
       __kmalloc+0x2e5/0x310 mm/slab.c:3669
       kmalloc include/linux/slab.h:552 [inline]
       tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline]
       __tty_buffer_request_room+0x1ef/0x560 drivers/tty/tty_buffer.c:273
       tty_insert_flip_string_fixed_flag+0xa4/0x2b0 drivers/tty/tty_buffer.c:318
       tty_insert_flip_string include/linux/tty_flip.h:37 [inline]
       pty_write+0xe2/0x190 drivers/tty/pty.c:122
       tty_put_char+0x115/0x180 drivers/tty/tty_io.c:3031
       __process_echoes+0x19d/0x920 drivers/tty/n_tty.c:746
       flush_echoes drivers/tty/n_tty.c:829 [inline]
       __receive_buf drivers/tty/n_tty.c:1648 [inline]
       n_tty_receive_buf_common+0x297f/0x3080 drivers/tty/n_tty.c:1742
       n_tty_receive_buf+0x30/0x40 drivers/tty/n_tty.c:1771
       tiocsti drivers/tty/tty_io.c:2195 [inline]
       tty_ioctl+0xd63/0x15d0 drivers/tty/tty_io.c:2571
       do_vfs_ioctl+0x7d4/0x1890 fs/ioctl.c:46
       ksys_ioctl fs/ioctl.c:713 [inline]
       __do_sys_ioctl fs/ioctl.c:720 [inline]
       __se_sys_ioctl fs/ioctl.c:718 [inline]
       __x64_sys_ioctl+0xe3/0x120 fs/ioctl.c:718
       do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

other info that might help us debug this:

Chain exists of:
  console_owner --> &port_lock_key --> &(&port->lock)->rlock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&(&port->lock)->rlock);
                               lock(&port_lock_key);
                               lock(&(&port->lock)->rlock);
  lock(console_owner);

 *** DEADLOCK ***

4 locks held by syz-executor155/8057:
 #0: 00000000537d947b (&tty->ldisc_sem){++++}, at: tty_ldisc_ref_wait+0x25/0x70 drivers/tty/tty_ldisc.c:272
 #1: 00000000edca1b1e (&o_tty->termios_rwsem/1){++++}, at: n_tty_receive_buf_common+0x8b/0x3080 drivers/tty/n_tty.c:1705
 #2: 00000000e4a6cb09 (&ldata->output_lock){+.+.}, at: flush_echoes drivers/tty/n_tty.c:827 [inline]
 #2: 00000000e4a6cb09 (&ldata->output_lock){+.+.}, at: __receive_buf drivers/tty/n_tty.c:1648 [inline]
 #2: 00000000e4a6cb09 (&ldata->output_lock){+.+.}, at: n_tty_receive_buf_common+0x2940/0x3080 drivers/tty/n_tty.c:1742
 #3: 0000000056678186 (&(&port->lock)->rlock){-.-.}, at: pty_write+0xbd/0x190 drivers/tty/pty.c:120

stack backtrace:
CPU: 1 PID: 8057 Comm: syz-executor155 Not tainted 5.2.0-rc5+ #4
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+0x1d8/0x2f8 lib/dump_stack.c:113
 print_circular_bug+0xd34/0xf20 kernel/locking/lockdep.c:1564
 check_prev_add kernel/locking/lockdep.c:2310 [inline]
 check_prevs_add kernel/locking/lockdep.c:2418 [inline]
 validate_chain+0x59d0/0x84f0 kernel/locking/lockdep.c:2800
 __lock_acquire+0xcf7/0x1a40 kernel/locking/lockdep.c:3793
 lock_acquire+0x158/0x250 kernel/locking/lockdep.c:4303
 console_trylock_spinning+0x14f/0x390 kernel/printk/printk.c:1735
 vprintk_emit+0x21c/0x3a0 kernel/printk/printk.c:1985
 vprintk_default+0x28/0x30 kernel/printk/printk.c:2013
 vprintk_func+0x158/0x170 kernel/printk/printk_safe.c:386
 printk+0xc4/0x11d kernel/printk/printk.c:2046
 fail_dump lib/fault-inject.c:45 [inline]
 should_fail+0x5c5/0x860 lib/fault-inject.c:144
 __should_fail_alloc_page mm/page_alloc.c:3278 [inline]
 should_fail_alloc_page+0x55/0x60 mm/page_alloc.c:3315
 prepare_alloc_pages+0x283/0x460 mm/page_alloc.c:4598
 __alloc_pages_nodemask+0x11c/0x790 mm/page_alloc.c:4645
 __alloc_pages include/linux/gfp.h:473 [inline]
 __alloc_pages_node include/linux/gfp.h:486 [inline]
 kmem_getpages+0x46/0x480 mm/slab.c:1373
 cache_grow_begin+0x7e/0x2c0 mm/slab.c:2606
 cache_alloc_refill+0x311/0x3f0 mm/slab.c:2978
 ____cache_alloc mm/slab.c:3061 [inline]
 __do_cache_alloc mm/slab.c:3283 [inline]
 slab_alloc mm/slab.c:3318 [inline]
 __do_kmalloc mm/slab.c:3658 [inline]
 __kmalloc+0x2e5/0x310 mm/slab.c:3669
 kmalloc include/linux/slab.h:552 [inline]
 tty_buffer_alloc drivers/tty/tty_buffer.c:175 [inline]
 __tty_buffer_request_room+0x1ef/0x560 drivers/tty/tty_buffer.c:273
 tty_insert_flip_string_fixed_flag+0xa4/0x2b0 drivers/tty/tty_buffer.c:318
 tty_insert_flip_string include/linux/tty_flip.h:37 [inline]
 pty_write+0xe2/0x190 drivers/tty/pty.c:122
 tty_put_char+0x115/0x180 drivers/tty/tty_io.c:3031
 __process_echoes+0x19d/0x920 drivers/tty/n_tty.c:746
 flush_echoes drivers/tty/n_tty.c:829 [inline]
 __receive_buf drivers/tty/n_tty.c:1648 [inline]
 n_tty_receive_buf_common+0x297f/0x3080 drivers/tty/n_tty.c:1742
 n_tty_receive_buf+0x30/0x40 drivers/tty/n_tty.c:1771
 tiocsti drivers/tty/tty_io.c:2195 [inline]
 tty_ioctl+0xd63/0x15d0 drivers/tty/tty_io.c:2571
 do_vfs_ioctl+0x7d4/0x1890 fs/ioctl.c:46
 ksys_ioctl fs/ioctl.c:713 [inline]
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0xe3/0x120 fs/ioctl.c:718
 do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x441439
Code: e8 8c e8 ff ff 48 83 c4 18 c3 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 0f 83 eb 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffeff301068 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441439
RDX: 0000000020000040 RSI: 0000000000005412 RDI: 0000000000000004
RBP: 00007ffeff301080 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: ffffffffffffffff
R13: 0000000000000005 R14: 0000000000000000 R15: 0000000000000000

Crashes (168):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-smack-root 2019/06/22 13:54 upstream abf02e2964b3 34bf9440 .config log report syz C
ci-upstream-kasan-gce-smack-root 2022/05/16 01:52 upstream bc403203d65a 744a39e2 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2022/05/11 13:31 upstream feb9c5e19e91 8d7b3b67 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2022/04/24 20:22 upstream 22da5264abf4 131df97d .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2022/04/18 15:19 upstream b2d229d4ddb1 8bcc32a6 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2022/02/06 12:04 upstream 90c9e950c0de a7dab638 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2022/01/18 14:46 upstream e3a8b6a1e70c 731a2d23 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2022/01/14 03:34 upstream 455e73a07f6e b8d780ab .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2022/01/01 13:45 upstream 800829388818 e1768e9c .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/12/18 16:59 upstream 9eaa88c7036e 44068e19 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/12/17 22:18 upstream 6441998e2e37 44068e19 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/12/16 06:55 upstream 2b14864acbaa 572bcb40 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/12/10 19:11 upstream c741e49150db 49ca1f59 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/11/22 00:45 upstream 40c93d7fff6f 4eb20a4e .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/11/15 06:55 upstream fa55b7dcdc43 83f5c9b5 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/11/12 08:07 upstream 5833291ab6de 75b04091 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/11/04 23:11 upstream 7ddb58cb0eca 4c1be0be .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/11/02 01:30 upstream e66435936756 098b5d53 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/08/19 11:12 upstream d6d09a694205 a2fe1cb5 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/08/02 14:40 upstream c500bee1c5b2 6c236867 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/04/22 02:07 upstream 16fc44d6387e 2bc8999a .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/04/11 14:48 upstream 52e44129fba5 bfeda1b1 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/04/06 11:11 upstream 0a50438c8436 6a81331a .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/03/27 12:52 upstream 0f4498cef9f5 a8529b82 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/03/24 10:06 upstream 7acac4b3196c e613994b .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/02/18 12:55 upstream f40ddce88593 14052202 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/02/13 08:19 upstream dcc0b49040c7 98682e5e .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2021/01/23 18:37 upstream fe75a21824e7 52e37319 .config log report info possible deadlock in console_trylock_spinning
ci-upstream-kasan-gce-smack-root 2020/11/17 06:55 upstream 9c87c9f41245 1bf9a662 .config log report info
ci-upstream-kasan-gce-smack-root 2020/09/12 16:49 upstream 729e3d091984 ce441f06 .config log report
ci-upstream-kasan-gce-smack-root 2020/09/09 05:47 upstream 6f6a73c8b715 abf9ba4f .config log report
ci-upstream-kasan-gce-smack-root 2020/08/27 10:43 upstream 15bc20c6af4c 816e0689 .config log report
ci-upstream-kasan-gce-smack-root 2020/08/25 21:46 upstream abb3438d69fb 344da168 .config log report
ci-upstream-kasan-gce-smack-root 2020/08/21 07:36 upstream da2968ff879b 1d75fe45 .config log report
ci-upstream-kasan-gce-smack-root 2020/08/19 23:34 upstream 18445bf405cb 94b45706 .config log report
ci-upstream-kasan-gce-smack-root 2020/08/19 12:44 upstream 18445bf405cb e1c29030 .config log report
ci-upstream-kasan-gce-smack-root 2020/08/15 21:05 upstream c9c9735c46f5 424dd8e7 .config log report
ci-upstream-kasan-gce-smack-root 2020/08/03 08:07 upstream 5a30a78924ec 196277c4 .config log report
ci-upstream-kasan-gce-smack-root 2020/07/31 09:43 upstream 83bdc7275e62 8df85ed9 .config log report
ci-upstream-kasan-gce-smack-root 2020/07/26 17:29 upstream 04300d66f0a0 51265195 .config log report
ci-upstream-kasan-gce-smack-root 2020/07/19 18:19 upstream f932d58abc38 9c812472 .config log report
ci-upstream-kasan-gce-smack-root 2020/07/15 19:31 upstream e9919e11e219 f3bec699 .config log report
ci-upstream-kasan-gce-smack-root 2020/07/13 09:27 upstream 4437dd6e8f71 9ebcc5b1 .config log report
ci-upstream-kasan-gce-smack-root 2020/07/08 05:39 upstream 7cc2a8ea1048 51095195 .config log report
ci-upstream-kasan-gce-smack-root 2020/07/08 03:47 upstream 7cc2a8ea1048 51095195 .config log report
ci-upstream-kasan-gce-smack-root 2020/06/28 09:05 upstream 1590a2e1c681 ffec44b5 .config log report
ci-upstream-kasan-gce-smack-root 2020/06/24 22:00 upstream 7ae77150d94d 54566aff .config log report
ci-upstream-kasan-gce-smack-root 2020/06/17 19:24 upstream 7ae77150d94d b9f3810b .config log report
ci-upstream-kasan-gce-smack-root 2020/06/16 19:09 upstream 7ae77150d94d 559fbe2d .config log report
ci-upstream-kasan-gce-smack-root 2020/06/12 07:30 upstream 7ae77150d94d 58802067 .config log report
ci-upstream-kasan-gce-smack-root 2020/06/11 18:08 upstream 7ae77150d94d 3ab7a05a .config log report
ci-upstream-kasan-gce-smack-root 2019/06/19 18:57 upstream bed3c0d84e7e 34bf9440 .config log report