====================================================== WARNING: possible circular locking dependency detected 5.10.123 #1 Not tainted ------------------------------------------------------ kworker/u4:3/7485 is trying to acquire lock: ffff88803d3a8578 (&tty->read_wait){....}-{2:2}, at: __wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:122 but task is already holding lock: ffff888056c8e3b8 (&tty->ctrl_lock){....}-{2:2}, at: spin_lock_irq include/linux/spinlock.h:379 [inline] ffff888056c8e3b8 (&tty->ctrl_lock){....}-{2:2}, at: pty_flush_buffer+0xaf/0x160 drivers/tty/pty.c:233 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&tty->ctrl_lock){....}-{2:2}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x36/0x50 kernel/locking/spinlock.c:159 __proc_set_tty+0x2c/0x610 drivers/tty/tty_jobctrl.c:98 proc_set_tty drivers/tty/tty_jobctrl.c:121 [inline] tiocsctty drivers/tty/tty_jobctrl.c:387 [inline] tty_jobctrl_ioctl+0x57e/0xe10 drivers/tty/tty_jobctrl.c:564 tty_ioctl+0x1361/0x1830 drivers/tty/tty_io.c:2737 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl fs/ioctl.c:739 [inline] __x64_sys_ioctl+0x196/0x210 fs/ioctl.c:739 do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 -> #1 (&sighand->siglock){-.-.}-{2:2}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x36/0x50 kernel/locking/spinlock.c:159 __lock_task_sighand+0xd3/0x2f0 kernel/signal.c:1391 lock_task_sighand include/linux/sched/signal.h:693 [inline] task_work_add+0x1db/0x2b0 kernel/task_work.c:58 io_req_task_work_add fs/io_uring.c:2062 [inline] __io_async_wake+0x40b/0x8d0 fs/io_uring.c:4938 __wake_up_common+0x14c/0x4c0 kernel/sched/wait.c:93 __wake_up_common_lock+0xd0/0x130 kernel/sched/wait.c:123 tty_ldisc_lock+0x40/0xb0 drivers/tty/tty_ldisc.c:335 tty_ldisc_hangup+0x204/0x690 drivers/tty/tty_ldisc.c:744 __tty_hangup.part.0+0x510/0x9b0 drivers/tty/tty_io.c:624 __tty_hangup drivers/tty/tty_io.c:574 [inline] tty_vhangup drivers/tty/tty_io.c:697 [inline] tty_ioctl+0x120e/0x1830 drivers/tty/tty_io.c:2683 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl fs/ioctl.c:739 [inline] __x64_sys_ioctl+0x196/0x210 fs/ioctl.c:739 do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 -> #0 (&tty->read_wait){....}-{2:2}: check_prev_add kernel/locking/lockdep.c:2988 [inline] check_prevs_add kernel/locking/lockdep.c:3113 [inline] validate_chain kernel/locking/lockdep.c:3728 [inline] __lock_acquire+0x29e3/0x5b00 kernel/locking/lockdep.c:4954 lock_acquire kernel/locking/lockdep.c:5564 [inline] lock_acquire+0x197/0x490 kernel/locking/lockdep.c:5529 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x36/0x50 kernel/locking/spinlock.c:159 __wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:122 pty_flush_buffer+0x124/0x160 drivers/tty/pty.c:235 tty_driver_flush_buffer+0x60/0x80 drivers/tty/tty_ioctl.c:95 isig+0x1da/0x430 drivers/tty/n_tty.c:1137 n_tty_receive_signal_char+0x1f/0x150 drivers/tty/n_tty.c:1238 n_tty_receive_char_special+0x1273/0x2aa0 drivers/tty/n_tty.c:1290 n_tty_receive_buf_fast drivers/tty/n_tty.c:1605 [inline] __receive_buf drivers/tty/n_tty.c:1639 [inline] n_tty_receive_buf_common+0x1e57/0x2b70 drivers/tty/n_tty.c:1737 tty_ldisc_receive_buf+0xac/0x190 drivers/tty/tty_buffer.c:462 tty_port_default_receive_buf+0x6e/0xa0 drivers/tty/tty_port.c:38 receive_buf drivers/tty/tty_buffer.c:482 [inline] flush_to_ldisc+0x212/0x3f0 drivers/tty/tty_buffer.c:534 process_one_work+0x9a9/0x1590 kernel/workqueue.c:2279 worker_thread+0x61d/0x1310 kernel/workqueue.c:2425 kthread+0x38f/0x470 kernel/kthread.c:313 ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:296 other info that might help us debug this: Chain exists of: &tty->read_wait --> &sighand->siglock --> &tty->ctrl_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&tty->ctrl_lock); lock(&sighand->siglock); lock(&tty->ctrl_lock); lock(&tty->read_wait); *** DEADLOCK *** 6 locks held by kworker/u4:3/7485: #0: ffff888007c61138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline] #0: ffff888007c61138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: atomic64_set include/asm-generic/atomic-instrumented.h:856 [inline] #0: ffff888007c61138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: atomic_long_set include/asm-generic/atomic-long.h:41 [inline] #0: ffff888007c61138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:617 [inline] #0: ffff888007c61138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:644 [inline] #0: ffff888007c61138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work+0x8ac/0x1590 kernel/workqueue.c:2250 #1: ffff8880560afda8 ((work_completion)(&buf->work)){+.+.}-{0:0}, at: process_one_work+0x8df/0x1590 kernel/workqueue.c:2254 #2: ffff88803fd9d0b8 (&port->buf.lock/1){+.+.}-{3:3}, at: flush_to_ldisc+0x42/0x3f0 drivers/tty/tty_buffer.c:506 #3: ffff888056c8e098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref+0x1d/0x80 drivers/tty/tty_ldisc.c:287 #4: ffff888056c8e2e8 (&o_tty->termios_rwsem/1){++++}-{3:3}, at: isig+0xe5/0x430 drivers/tty/n_tty.c:1126 #5: ffff888056c8e3b8 (&tty->ctrl_lock){....}-{2:2}, at: spin_lock_irq include/linux/spinlock.h:379 [inline] #5: ffff888056c8e3b8 (&tty->ctrl_lock){....}-{2:2}, at: pty_flush_buffer+0xaf/0x160 drivers/tty/pty.c:233 stack backtrace: CPU: 1 PID: 7485 Comm: kworker/u4:3 Not tainted 5.10.123 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 Workqueue: events_unbound flush_to_ldisc Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x107/0x163 lib/dump_stack.c:118 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2123 check_prev_add kernel/locking/lockdep.c:2988 [inline] check_prevs_add kernel/locking/lockdep.c:3113 [inline] validate_chain kernel/locking/lockdep.c:3728 [inline] __lock_acquire+0x29e3/0x5b00 kernel/locking/lockdep.c:4954 lock_acquire kernel/locking/lockdep.c:5564 [inline] lock_acquire+0x197/0x490 kernel/locking/lockdep.c:5529 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x36/0x50 kernel/locking/spinlock.c:159 __wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:122 pty_flush_buffer+0x124/0x160 drivers/tty/pty.c:235 tty_driver_flush_buffer+0x60/0x80 drivers/tty/tty_ioctl.c:95 isig+0x1da/0x430 drivers/tty/n_tty.c:1137 n_tty_receive_signal_char+0x1f/0x150 drivers/tty/n_tty.c:1238 n_tty_receive_char_special+0x1273/0x2aa0 drivers/tty/n_tty.c:1290 n_tty_receive_buf_fast drivers/tty/n_tty.c:1605 [inline] __receive_buf drivers/tty/n_tty.c:1639 [inline] n_tty_receive_buf_common+0x1e57/0x2b70 drivers/tty/n_tty.c:1737 tty_ldisc_receive_buf+0xac/0x190 drivers/tty/tty_buffer.c:462 tty_port_default_receive_buf+0x6e/0xa0 drivers/tty/tty_port.c:38 receive_buf drivers/tty/tty_buffer.c:482 [inline] flush_to_ldisc+0x212/0x3f0 drivers/tty/tty_buffer.c:534 process_one_work+0x9a9/0x1590 kernel/workqueue.c:2279 worker_thread+0x61d/0x1310 kernel/workqueue.c:2425 kthread+0x38f/0x470 kernel/kthread.c:313 ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:296