RBP: 00007f5c513aaca0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe46e6e56f R14: 00007f5c513ab9c0 R15: 000000000119c034
======================================================
WARNING: possible circular locking dependency detected
4.19.165-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/27970 is trying to acquire lock:
0000000049ecd41a (console_owner){-.-.}, at: console_trylock_spinning kernel/printk/printk.c:1697 [inline]
0000000049ecd41a (console_owner){-.-.}, at: vprintk_emit+0x3fe/0x740 kernel/printk/printk.c:1964

but task is already holding lock:
00000000aa03d76d (&(&port->lock)->rlock){-.-.}, at: pty_write+0xf4/0x1f0 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){-.-.}:
       tty_port_tty_get+0x1d/0x80 drivers/tty/tty_port.c:289
       tty_port_default_wakeup+0x11/0x40 drivers/tty/tty_port.c:47
       serial8250_tx_chars+0x490/0xaf0 drivers/tty/serial/8250/8250_port.c:1806
       serial8250_handle_irq.part.0+0x31f/0x3d0 drivers/tty/serial/8250/8250_port.c:1893
       serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1866 [inline]
       serial8250_default_handle_irq+0xae/0x220 drivers/tty/serial/8250/8250_port.c:1909
       serial8250_interrupt+0x101/0x240 drivers/tty/serial/8250/8250_core.c:125
       __handle_irq_event_percpu+0x27e/0x8e0 kernel/irq/handle.c:149
       handle_irq_event_percpu kernel/irq/handle.c:189 [inline]
       handle_irq_event+0x102/0x285 kernel/irq/handle.c:206
       handle_edge_irq+0x260/0xcf0 kernel/irq/chip.c:797
       generic_handle_irq_desc include/linux/irqdesc.h:155 [inline]
       handle_irq+0x35/0x50 arch/x86/kernel/irq_64.c:87
       do_IRQ+0x93/0x1c0 arch/x86/kernel/irq.c:246
       ret_from_intr+0x0/0x1e
       native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:60
       arch_safe_halt arch/x86/include/asm/paravirt.h:94 [inline]
       default_idle+0x49/0x310 arch/x86/kernel/process.c:557
       cpuidle_idle_call kernel/sched/idle.c:153 [inline]
       do_idle+0x2ec/0x4b0 kernel/sched/idle.c:263
       cpu_startup_entry+0xc5/0xe0 kernel/sched/idle.c:369
       start_kernel+0x8d6/0x911 init/main.c:736
       secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243

-> #1 (&port_lock_key){-.-.}:
       serial8250_console_write+0x89b/0xad0 drivers/tty/serial/8250/8250_port.c:3270
       call_console_drivers kernel/printk/printk.c:1764 [inline]
       console_unlock+0xbb6/0x1110 kernel/printk/printk.c:2460
       vprintk_emit+0x2d1/0x740 kernel/printk/printk.c:1965
       vprintk_func+0x79/0x17e kernel/printk/printk_safe.c:397
       printk+0xba/0xed kernel/printk/printk.c:2040
       register_console+0x87f/0xc90 kernel/printk/printk.c:2776
       univ8250_console_init+0x3a/0x46 drivers/tty/serial/8250/8250_core.c:684
       console_init+0x4cb/0x718 kernel/printk/printk.c:2862
       start_kernel+0x686/0x911 init/main.c:659
       secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243

-> #0 (console_owner){-.-.}:
       console_trylock_spinning kernel/printk/printk.c:1718 [inline]
       vprintk_emit+0x43b/0x740 kernel/printk/printk.c:1964
       vprintk_func+0x79/0x17e kernel/printk/printk_safe.c:397
       printk+0xba/0xed kernel/printk/printk.c:2040
       fail_dump lib/fault-inject.c:44 [inline]
       should_fail+0x66b/0x7b0 lib/fault-inject.c:149
       __should_failslab+0x115/0x180 mm/failslab.c:32
       should_failslab+0x5/0xf mm/slab_common.c:1588
       slab_pre_alloc_hook mm/slab.h:424 [inline]
       slab_alloc mm/slab.c:3383 [inline]
       __do_kmalloc mm/slab.c:3725 [inline]
       __kmalloc+0x6d/0x3c0 mm/slab.c:3736
       kmalloc include/linux/slab.h:520 [inline]
       tty_buffer_alloc+0x23f/0x2a0 drivers/tty/tty_buffer.c:170
       __tty_buffer_request_room+0x156/0x2a0 drivers/tty/tty_buffer.c:268
       tty_insert_flip_string_fixed_flag+0x93/0x250 drivers/tty/tty_buffer.c:313
       tty_insert_flip_string include/linux/tty_flip.h:37 [inline]
       pty_write+0x126/0x1f0 drivers/tty/pty.c:122
       tty_put_char+0x122/0x150 drivers/tty/tty_io.c:2893
       __process_echoes+0x577/0x9f0 drivers/tty/n_tty.c:726
       flush_echoes drivers/tty/n_tty.c:827 [inline]
       __receive_buf drivers/tty/n_tty.c:1646 [inline]
       n_tty_receive_buf_common+0xc0c/0x2a90 drivers/tty/n_tty.c:1740
       tiocsti drivers/tty/tty_io.c:2194 [inline]
       tty_ioctl+0xff8/0x15c0 drivers/tty/tty_io.c:2580
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:501 [inline]
       do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
       ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
       __do_sys_ioctl fs/ioctl.c:712 [inline]
       __se_sys_ioctl fs/ioctl.c:710 [inline]
       __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       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-executor.0/27970:
 #0: 00000000aebf55d2 (&tty->ldisc_sem){++++}, at: tty_ldisc_ref_wait+0x22/0x80 drivers/tty/tty_ldisc.c:272
 #1: 000000006984a9c0 (&o_tty->termios_rwsem/1){++++}, at: isig+0x37d/0x430 drivers/tty/n_tty.c:1150
 #2: 0000000069300dac (&ldata->output_lock){+.+.}, at: flush_echoes drivers/tty/n_tty.c:825 [inline]
 #2: 0000000069300dac (&ldata->output_lock){+.+.}, at: __receive_buf drivers/tty/n_tty.c:1646 [inline]
 #2: 0000000069300dac (&ldata->output_lock){+.+.}, at: n_tty_receive_buf_common+0xbce/0x2a90 drivers/tty/n_tty.c:1740
 #3: 00000000aa03d76d (&(&port->lock)->rlock){-.-.}, at: pty_write+0xf4/0x1f0 drivers/tty/pty.c:120

stack backtrace:
CPU: 1 PID: 27970 Comm: syz-executor.0 Not tainted 4.19.165-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+0x1fc/0x2fe lib/dump_stack.c:118
 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1221
 check_prev_add kernel/locking/lockdep.c:1865 [inline]
 check_prevs_add kernel/locking/lockdep.c:1978 [inline]
 validate_chain kernel/locking/lockdep.c:2419 [inline]
 __lock_acquire+0x30c9/0x3ff0 kernel/locking/lockdep.c:3415
 lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3907
 console_trylock_spinning kernel/printk/printk.c:1718 [inline]
 vprintk_emit+0x43b/0x740 kernel/printk/printk.c:1964
 vprintk_func+0x79/0x17e kernel/printk/printk_safe.c:397
 printk+0xba/0xed kernel/printk/printk.c:2040
 fail_dump lib/fault-inject.c:44 [inline]
 should_fail+0x66b/0x7b0 lib/fault-inject.c:149
 __should_failslab+0x115/0x180 mm/failslab.c:32
 should_failslab+0x5/0xf mm/slab_common.c:1588
 slab_pre_alloc_hook mm/slab.h:424 [inline]
 slab_alloc mm/slab.c:3383 [inline]
 __do_kmalloc mm/slab.c:3725 [inline]
 __kmalloc+0x6d/0x3c0 mm/slab.c:3736
 kmalloc include/linux/slab.h:520 [inline]
 tty_buffer_alloc+0x23f/0x2a0 drivers/tty/tty_buffer.c:170
 __tty_buffer_request_room+0x156/0x2a0 drivers/tty/tty_buffer.c:268
 tty_insert_flip_string_fixed_flag+0x93/0x250 drivers/tty/tty_buffer.c:313
 tty_insert_flip_string include/linux/tty_flip.h:37 [inline]
 pty_write+0x126/0x1f0 drivers/tty/pty.c:122
 tty_put_char+0x122/0x150 drivers/tty/tty_io.c:2893
 __process_echoes+0x577/0x9f0 drivers/tty/n_tty.c:726
 flush_echoes drivers/tty/n_tty.c:827 [inline]
 __receive_buf drivers/tty/n_tty.c:1646 [inline]
 n_tty_receive_buf_common+0xc0c/0x2a90 drivers/tty/n_tty.c:1740
 tiocsti drivers/tty/tty_io.c:2194 [inline]
 tty_ioctl+0xff8/0x15c0 drivers/tty/tty_io.c:2580
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
 ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
 __do_sys_ioctl fs/ioctl.c:712 [inline]
 __se_sys_ioctl fs/ioctl.c:710 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45e219
Code: 0d b4 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 db b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f5c513aac68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 000000000045e219
RDX: 0000000020000080 RSI: 0000000000005412 RDI: 0000000000000003
RBP: 00007f5c513aaca0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe46e6e56f R14: 00007f5c513ab9c0 R15: 000000000119c034
Bluetooth: hci4: command 0x0401 tx timeout
Bluetooth: hci4: command 0x0401 tx timeout
syz-executor.1 (28174) used greatest stack depth: 22504 bytes left
Bluetooth: hci4: command 0x0401 tx timeout
Bluetooth: hci4: command 0x0401 tx timeout