====================================================== WARNING: possible circular locking dependency detected 6.13.0-syzkaller-09998-gcabb4685d57e #0 Not tainted ------------------------------------------------------ kworker/0:6/6492 is trying to acquire lock: ffff88801b0990b8 (&buf->lock){+.+.}-{4:4}, at: tty_buffer_flush+0x72/0x310 drivers/tty/tty_buffer.c:229 but task is already holding lock: ffffffff8e1aa580 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x13/0x310 drivers/tty/vt/vt_ioctl.c:983 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (console_lock){+.+.}-{0:0}: console_lock+0x7a/0xa0 kernel/printk/printk.c:2833 uart_configure_port drivers/tty/serial/serial_core.c:2599 [inline] serial_core_add_one_port drivers/tty/serial/serial_core.c:3160 [inline] serial_core_register_port+0xeba/0x25c0 drivers/tty/serial/serial_core.c:3391 serial8250_register_8250_port+0x158f/0x2370 drivers/tty/serial/8250/8250_core.c:822 serial_pnp_probe+0x44f/0x930 drivers/tty/serial/8250/8250_pnp.c:490 pnp_device_probe+0x2a5/0x4d0 drivers/pnp/driver.c:111 call_driver_probe drivers/base/dd.c:579 [inline] really_probe+0x23e/0xa90 drivers/base/dd.c:658 __driver_probe_device+0x1de/0x440 drivers/base/dd.c:800 driver_probe_device+0x4c/0x1b0 drivers/base/dd.c:830 __driver_attach+0x283/0x580 drivers/base/dd.c:1216 bus_for_each_dev+0x13c/0x1d0 drivers/base/bus.c:370 bus_add_driver+0x2e9/0x690 drivers/base/bus.c:678 driver_register+0x15c/0x4b0 drivers/base/driver.c:249 serial8250_init+0xc9/0x1e0 drivers/tty/serial/8250/8250_platform.c:324 do_one_initcall+0x128/0x700 init/main.c:1257 do_initcall_level init/main.c:1319 [inline] do_initcalls init/main.c:1335 [inline] do_basic_setup init/main.c:1354 [inline] kernel_init_freeable+0x5c7/0x900 init/main.c:1568 kernel_init+0x1c/0x2b0 init/main.c:1457 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 -> #2 (&port->mutex){+.+.}-{4:4}: __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x19b/0xb10 kernel/locking/mutex.c:730 class_mutex_constructor include/linux/mutex.h:201 [inline] uart_set_termios+0x8e/0x6a0 drivers/tty/serial/serial_core.c:1688 tty_set_termios+0x667/0x9b0 drivers/tty/tty_ioctl.c:345 set_termios+0x5ba/0x7f0 drivers/tty/tty_ioctl.c:520 tty_mode_ioctl+0x57a/0xd20 drivers/tty/tty_ioctl.c:807 n_tty_ioctl_helper+0x4b/0x2b0 drivers/tty/tty_ioctl.c:986 n_tty_ioctl+0x7f/0x370 drivers/tty/n_tty.c:2521 tty_ioctl+0x6ee/0x15d0 drivers/tty/tty_io.c:2811 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __x64_sys_ioctl+0x190/0x200 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #1 (&tty->termios_rwsem){++++}-{4:4}: down_read+0x9a/0x330 kernel/locking/rwsem.c:1524 n_tty_receive_buf_common+0x85/0x1980 drivers/tty/n_tty.c:1702 tty_ldisc_receive_buf+0xa2/0x190 drivers/tty/tty_buffer.c:387 tty_port_default_receive_buf+0x70/0xb0 drivers/tty/tty_port.c:37 receive_buf drivers/tty/tty_buffer.c:445 [inline] flush_to_ldisc+0x264/0x780 drivers/tty/tty_buffer.c:495 process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3236 process_scheduled_works kernel/workqueue.c:3317 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3398 kthread+0x3af/0x750 kernel/kthread.c:464 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 -> #0 (&buf->lock){+.+.}-{4:4}: check_prev_add kernel/locking/lockdep.c:3163 [inline] check_prevs_add kernel/locking/lockdep.c:3282 [inline] validate_chain kernel/locking/lockdep.c:3906 [inline] __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5228 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5851 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x19b/0xb10 kernel/locking/mutex.c:730 tty_buffer_flush+0x72/0x310 drivers/tty/tty_buffer.c:229 tty_ldisc_flush+0xa4/0xe0 drivers/tty/tty_ldisc.c:388 __do_SAK+0x6a7/0x800 drivers/tty/tty_io.c:3037 vc_SAK+0x7f/0x310 drivers/tty/vt/vt_ioctl.c:993 process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3236 process_scheduled_works kernel/workqueue.c:3317 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3398 kthread+0x3af/0x750 kernel/kthread.c:464 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 other info that might help us debug this: Chain exists of: &buf->lock --> &port->mutex --> console_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(console_lock); lock(&port->mutex); lock(console_lock); lock(&buf->lock); *** DEADLOCK *** 3 locks held by kworker/0:6/6492: #0: ffff88801b078d48 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x1293/0x1ba0 kernel/workqueue.c:3211 #1: ffffc90002fc7d18 ((work_completion)(&vc_cons[currcons].SAK_work)){+.+.}-{0:0}, at: process_one_work+0x921/0x1ba0 kernel/workqueue.c:3212 #2: ffffffff8e1aa580 (console_lock){+.+.}-{0:0}, at: vc_SAK+0x13/0x310 drivers/tty/vt/vt_ioctl.c:983 stack backtrace: CPU: 0 UID: 0 PID: 6492 Comm: kworker/0:6 Not tainted 6.13.0-syzkaller-09998-gcabb4685d57e #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 Workqueue: events vc_SAK Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_circular_bug+0x490/0x760 kernel/locking/lockdep.c:2076 check_noncircular+0x31a/0x400 kernel/locking/lockdep.c:2208 check_prev_add kernel/locking/lockdep.c:3163 [inline] check_prevs_add kernel/locking/lockdep.c:3282 [inline] validate_chain kernel/locking/lockdep.c:3906 [inline] __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5228 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5851 __mutex_lock_common kernel/locking/mutex.c:585 [inline] __mutex_lock+0x19b/0xb10 kernel/locking/mutex.c:730 tty_buffer_flush+0x72/0x310 drivers/tty/tty_buffer.c:229 tty_ldisc_flush+0xa4/0xe0 drivers/tty/tty_ldisc.c:388 __do_SAK+0x6a7/0x800 drivers/tty/tty_io.c:3037 vc_SAK+0x7f/0x310 drivers/tty/vt/vt_ioctl.c:993 process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3236 process_scheduled_works kernel/workqueue.c:3317 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3398 kthread+0x3af/0x750 kernel/kthread.c:464 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244