Kernel bug: possible deadlock in console_lock_spinning_enable (5)
Subsystem: serial
Status: open

Crash report:
------------[ cut here ]------------
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
kworker/0:3/5931 is trying to acquire lock:
ffffffff8e2d6ac0 (console_owner){....}-{0:0}, at: console_lock_spinning_enable+0x61/0x80 kernel/printk/printk.c:1900

but task is already holding lock:
ffff8880b843add8 (&rq->__lock){-.-.}-{2:2}, at: raw_spin_rq_lock_nested kernel/sched/core.c:647 [inline]
ffff8880b843add8 (&rq->__lock){-.-.}-{2:2}, at: raw_spin_rq_lock_nested+0x7e/0x130 kernel/sched/core.c:632

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&rq->__lock){-.-.}-{2:2}:
       _raw_spin_lock_nested+0x31/0x40 kernel/locking/spinlock.c:378
       raw_spin_rq_lock_nested+0x29/0x130 kernel/sched/core.c:639
       raw_spin_rq_lock kernel/sched/sched.h:1558 [inline]
       task_rq_lock+0xcf/0x490 kernel/sched/core.c:739
       cgroup_move_task+0x81/0x2a0 kernel/sched/psi.c:1170
       css_set_move_task+0x288/0x5f0 kernel/cgroup/cgroup.c:951
       cgroup_post_fork+0x201/0x9e0 kernel/cgroup/cgroup.c:6913
       copy_process+0x56b6/0x7430 kernel/fork.c:2465
       kernel_clone+0xfc/0x910 kernel/fork.c:2651
       user_mode_thread+0xc8/0x110 kernel/fork.c:2727
       rest_init+0x23/0x2b0 init/main.c:722
       start_kernel+0x3ef/0x4d0 init/main.c:1206
       x86_64_start_reservations+0x18/0x30 arch/x86/kernel/head64.c:310
       x86_64_start_kernel+0x130/0x190 arch/x86/kernel/head64.c:291
       common_startup_64+0x13e/0x148

-> #3 (&p->pi_lock){-.-.}-{2:2}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162
       class_raw_spinlock_irqsave_constructor include/linux/spinlock.h:557 [inline]
       try_to_wake_up+0xb7/0x1860 kernel/sched/core.c:4106
       __wake_up_common+0x135/0x1f0 kernel/sched/wait.c:108
       __wake_up_common_lock kernel/sched/wait.c:125 [inline]
       __wake_up+0x31/0x60 kernel/sched/wait.c:146
       tty_port_default_wakeup+0x4d/0x60 drivers/tty/tty_port.c:67
       serial8250_tx_chars+0x68e/0x860 drivers/tty/serial/8250/8250_port.c:1719
       serial8250_handle_irq+0x761/0xcb0 drivers/tty/serial/8250/8250_port.c:1827
       serial8250_default_handle_irq+0x9e/0x270 drivers/tty/serial/8250/8250_port.c:1846
       serial8250_interrupt+0xf8/0x1d0 drivers/tty/serial/8250/8250_core.c:86
       __handle_irq_event_percpu+0x236/0x890 kernel/irq/handle.c:211
       handle_irq_event_percpu kernel/irq/handle.c:248 [inline]
       handle_irq_event+0xab/0x1e0 kernel/irq/handle.c:265
       handle_edge_irq+0x3ca/0x9e0 kernel/irq/chip.c:855
       generic_handle_irq_desc include/linux/irqdesc.h:172 [inline]
       handle_irq arch/x86/kernel/irq.c:255 [inline]
       call_irq_handler arch/x86/kernel/irq.c:311 [inline]
       __common_interrupt+0xd0/0x2f0 arch/x86/kernel/irq.c:326
       common_interrupt+0xba/0xe0 arch/x86/kernel/irq.c:319
       asm_common_interrupt+0x26/0x40 arch/x86/include/asm/idtentry.h:688
       mte_to_node lib/maple_tree.c:302 [inline]
       mte_dead_node lib/maple_tree.c:586 [inline]
       mas_start lib/maple_tree.c:1207 [inline]
       mt_validate_nulls+0x228/0x9d0 lib/maple_tree.c:7115
       mt_validate+0x2f80/0x3f90 lib/maple_tree.c:7179
       validate_mm+0xa9/0x560 mm/vma.c:644
       vms_complete_munmap_vmas+0x602/0x970 mm/vma.c:1299
       do_vmi_align_munmap+0x446/0x7e0 mm/vma.c:1539
       do_vmi_munmap+0x204/0x3e0 mm/vma.c:1587
       __vm_munmap+0x196/0x380 mm/vma.c:3203
       elf_map fs/binfmt_elf.c:397 [inline]
       elf_load+0x349/0x780 fs/binfmt_elf.c:422
       load_elf_binary+0x1422/0x4fe0 fs/binfmt_elf.c:1188
       search_binary_handler fs/exec.c:1669 [inline]
       exec_binprm fs/exec.c:1701 [inline]
       bprm_execve fs/exec.c:1753 [inline]
       bprm_execve+0x8c2/0x1620 fs/exec.c:1729
       do_execveat_common.isra.0+0x4a5/0x610 fs/exec.c:1859
       do_execve fs/exec.c:1933 [inline]
       __do_sys_execve fs/exec.c:2009 [inline]
       __se_sys_execve fs/exec.c:2004 [inline]
       __x64_sys_execve+0x8e/0xb0 fs/exec.c:2004
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xcd/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&tty->write_wait){-...}-{3:3}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162
       __wake_up_common_lock kernel/sched/wait.c:124 [inline]
       __wake_up+0x1c/0x60 kernel/sched/wait.c:146
       tty_port_default_wakeup+0x4d/0x60 drivers/tty/tty_port.c:67
       serial8250_tx_chars+0x68e/0x860 drivers/tty/serial/8250/8250_port.c:1719
       serial8250_handle_irq+0x761/0xcb0 drivers/tty/serial/8250/8250_port.c:1827
       serial8250_default_handle_irq+0x9e/0x270 drivers/tty/serial/8250/8250_port.c:1846
       serial8250_interrupt+0xf8/0x1d0 drivers/tty/serial/8250/8250_core.c:86
       __handle_irq_event_percpu+0x236/0x890 kernel/irq/handle.c:211
       handle_irq_event_percpu kernel/irq/handle.c:248 [inline]
       handle_irq_event+0xab/0x1e0 kernel/irq/handle.c:265
       handle_edge_irq+0x3ca/0x9e0 kernel/irq/chip.c:855
       generic_handle_irq_desc include/linux/irqdesc.h:172 [inline]
       handle_irq arch/x86/kernel/irq.c:255 [inline]
       call_irq_handler arch/x86/kernel/irq.c:311 [inline]
       __common_interrupt+0xd0/0x2f0 arch/x86/kernel/irq.c:326
       common_interrupt+0xba/0xe0 arch/x86/kernel/irq.c:319
       asm_common_interrupt+0x26/0x40 arch/x86/include/asm/idtentry.h:688
       __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:151 [inline]
       _raw_spin_unlock_irqrestore+0x31/0x80 kernel/locking/spinlock.c:194
       spin_unlock_irqrestore include/linux/spinlock.h:406 [inline]
       uart_port_unlock_irqrestore include/linux/serial_core.h:788 [inline]
       uart_port_unlock_deref drivers/tty/serial/serial_core.c:91 [inline]
       uart_port_unlock_deref drivers/tty/serial/serial_core.c:88 [inline]
       uart_write+0x2a4/0xb30 drivers/tty/serial/serial_core.c:634
       process_output_block drivers/tty/n_tty.c:557 [inline]
       n_tty_write+0x434/0x1280 drivers/tty/n_tty.c:2366
       iterate_tty_write drivers/tty/tty_io.c:1006 [inline]
       file_tty_write.constprop.0+0x503/0x9b0 drivers/tty/tty_io.c:1081
       tty_write drivers/tty/tty_io.c:1102 [inline]
       redirected_tty_write drivers/tty/tty_io.c:1125 [inline]
       redirected_tty_write+0xd4/0x120 drivers/tty/tty_io.c:1105
       new_sync_write fs/read_write.c:593 [inline]
       vfs_write+0x7d3/0x11d0 fs/read_write.c:686
       ksys_write+0x12a/0x250 fs/read_write.c:738
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xcd/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&port_lock_key){-...}-{3:3}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162
       uart_port_lock_irqsave include/linux/serial_core.h:717 [inline]
       serial8250_console_write+0x181/0x1890 drivers/tty/serial/8250/8250_port.c:3301
       console_emit_next_record kernel/printk/printk.c:3129 [inline]
       console_flush_one_record+0x796/0xc60 kernel/printk/printk.c:3215
       console_flush_all kernel/printk/printk.c:3289 [inline]
       __console_flush_and_unlock kernel/printk/printk.c:3319 [inline]
       console_unlock+0xef/0x240 kernel/printk/printk.c:3359
       vprintk_emit+0x407/0x6b0 kernel/printk/printk.c:2426
       _printk+0xc7/0x100 kernel/printk/printk.c:2451
       register_console+0x823/0x1210 kernel/printk/printk.c:4170
       univ8250_console_init+0x5f/0x90 drivers/tty/serial/8250/8250_core.c:515
       console_init+0x152/0x600 kernel/printk/printk.c:4369
       start_kernel+0x298/0x4d0 init/main.c:1143
       x86_64_start_reservations+0x18/0x30 arch/x86/kernel/head64.c:310
       x86_64_start_kernel+0x130/0x190 arch/x86/kernel/head64.c:291
       common_startup_64+0x13e/0x148

-> #0 (console_owner){....}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3165 [inline]
       check_prevs_add kernel/locking/lockdep.c:3284 [inline]
       validate_chain kernel/locking/lockdep.c:3908 [inline]
       __lock_acquire+0x1669/0x2890 kernel/locking/lockdep.c:5237
       lock_acquire kernel/locking/lockdep.c:5868 [inline]
       lock_acquire+0x179/0x330 kernel/locking/lockdep.c:5825
       console_lock_spinning_enable+0x72/0x80 kernel/printk/printk.c:1900
       console_emit_next_record kernel/printk/printk.c:3123 [inline]
       console_flush_one_record+0x73f/0xc60 kernel/printk/printk.c:3215
       console_flush_all kernel/printk/printk.c:3289 [inline]
       __console_flush_and_unlock kernel/printk/printk.c:3319 [inline]
       console_unlock+0xef/0x240 kernel/printk/printk.c:3359
       vprintk_emit+0x407/0x6b0 kernel/printk/printk.c:2426
       _printk+0xc7/0x100 kernel/printk/printk.c:2451
       __report_bug+0x3a6/0x520 lib/bug.c:243
       report_bug+0xb2/0x220 lib/bug.c:281
       handle_bug+0x127/0x260 arch/x86/kernel/traps.c:435
       exc_invalid_op+0x17/0x50 arch/x86/kernel/traps.c:489
       asm_exc_invalid_op+0x1a/0x20 arch/x86/include/asm/idtentry.h:616
       lockdep_assert_rq_held kernel/sched/sched.h:1549 [inline]
       lockdep_assert_rq_held kernel/sched/sched.h:1547 [inline]
       update_rq_clock+0x34a/0xc70 kernel/sched/core.c:837
       pick_next_task kernel/sched/core.c:6088 [inline]
       __schedule+0x212d/0x6150 kernel/sched/core.c:6805
       __schedule_loop kernel/sched/core.c:6945 [inline]
       schedule+0xe7/0x3a0 kernel/sched/core.c:6960
       schedule_timeout+0x123/0x290 kernel/time/sleep_timeout.c:99
       msleep+0x32/0x50 kernel/time/sleep_timeout.c:318
       nsim_fib4_rt_add+0xbfb/0x1670 drivers/net/netdevsim/fib.c:369
       nsim_fib4_rt_insert drivers/net/netdevsim/fib.c:432 [inline]
       nsim_fib4_event drivers/net/netdevsim/fib.c:464 [inline]
       nsim_fib_event drivers/net/netdevsim/fib.c:884 [inline]
       nsim_fib_event_work+0x2072/0x65f0 drivers/net/netdevsim/fib.c:1493
       process_one_work+0x9ba/0x1b20 kernel/workqueue.c:3257
       process_scheduled_works kernel/workqueue.c:3340 [inline]
       worker_thread+0x6c8/0xf10 kernel/workqueue.c:3421
       kthread+0x3c5/0x780 kernel/kthread.c:463
       ret_from_fork+0x983/0xb10 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246

other info that might help us debug this:

Chain exists of:
  console_owner --> &p->pi_lock --> &rq->__lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&rq->__lock);
                               lock(&p->pi_lock);
                               lock(&rq->__lock);
  lock(console_owner);

 *** DEADLOCK ***

6 locks held by kworker/0:3/5931:
 #0: ffff88813ff55948 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x128d/0x1b20 kernel/workqueue.c:3232
 #1: ffffc900037f7c90 ((work_completion)(&data->fib_event_work)){+.+.}-{0:0}, at: process_one_work+0x914/0x1b20 kernel/workqueue.c:3233
 #2: ffff888056cd2240 (&data->fib_lock){+.+.}-{4:4}, at: nsim_fib_event_work+0x1b8/0x65f0 drivers/net/netdevsim/fib.c:1490
 #3: ffff8880b843add8 (&rq->__lock){-.-.}-{2:2}, at: raw_spin_rq_lock_nested kernel/sched/core.c:647 [inline]
 #3: ffff8880b843add8 (&rq->__lock){-.-.}-{2:2}, at: raw_spin_rq_lock_nested+0x7e/0x130 kernel/sched/core.c:632
 #4: ffffffff8e3b6f00 (console_lock){+.+.}-{0:0}, at: _printk+0xc7/0x100 kernel/printk/printk.c:2451
 #5: ffffffff8e3b6f78 (console_srcu){....}-{0:0}, at: rcu_try_lock_acquire include/linux/rcupdate.h:336 [inline]
 #5: ffffffff8e3b6f78 (console_srcu){....}-{0:0}, at: srcu_read_lock_nmisafe include/linux/srcu.h:409 [inline]
 #5: ffffffff8e3b6f78 (console_srcu){....}-{0:0}, at: console_srcu_read_lock kernel/printk/printk.c:289 [inline]
 #5: ffffffff8e3b6f78 (console_srcu){....}-{0:0}, at: console_flush_one_record+0x103/0xc60 kernel/printk/printk.c:3192

stack backtrace:
CPU: 0 UID: 0 PID: 5931 Comm: kworker/0:3 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
Workqueue: events nsim_fib_event_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_circular_bug+0x275/0x340 kernel/locking/lockdep.c:2043
 check_noncircular+0x146/0x160 kernel/locking/lockdep.c:2175
 check_prev_add kernel/locking/lockdep.c:3165 [inline]
 check_prevs_add kernel/locking/lockdep.c:3284 [inline]
 validate_chain kernel/locking/lockdep.c:3908 [inline]
 __lock_acquire+0x1669/0x2890 kernel/locking/lockdep.c:5237
 lock_acquire kernel/locking/lockdep.c:5868 [inline]
 lock_acquire+0x179/0x330 kernel/locking/lockdep.c:5825
 console_lock_spinning_enable+0x72/0x80 kernel/printk/printk.c:1900
 console_emit_next_record kernel/printk/printk.c:3123 [inline]
 console_flush_one_record+0x73f/0xc60 kernel/printk/printk.c:3215
 console_flush_all kernel/printk/printk.c:3289 [inline]
 __console_flush_and_unlock kernel/printk/printk.c:3319 [inline]
 console_unlock+0xef/0x240 kernel/printk/printk.c:3359
 vprintk_emit+0x407/0x6b0 kernel/printk/printk.c:2426
 _printk+0xc7/0x100 kernel/printk/printk.c:2451
 __report_bug+0x3a6/0x520 lib/bug.c:243
 report_bug+0xb2/0x220 lib/bug.c:281
 handle_bug+0x127/0x260 arch/x86/kernel/traps.c:435
 exc_invalid_op+0x17/0x50 arch/x86/kernel/traps.c:489
 asm_exc_invalid_op+0x1a/0x20 arch/x86/include/asm/idtentry.h:616
RIP: 0010:lockdep_assert_rq_held kernel/sched/sched.h:1549 [inline]
RIP: 0010:lockdep_assert_rq_held kernel/sched/sched.h:1547 [inline]
RIP: 0010:update_rq_clock+0x34a/0xc70 kernel/sched/core.c:837
Code: ab 48 0b 00 00 48 83 c4 18 5b 5d 41 5c 41 5d 41 5e 41 5f e9 48 af ed 09 a8 04 0f 84 9c fd ff ff 90 0f 0b 90 e9 93 fd ff ff 90 <0f> 0b 90 e9 4f fd ff ff 48 8d bb 18 0e 00 00 48 b8 00 00 00 00 00
RSP: 0018:ffffc900037f7680 EFLAGS: 00010046
RAX: 0000000000000000 RBX: ffff8880b853adc0 RCX: 0000000000000001
RDX: 0000000000000000 RSI: ffffffff8daa490a RDI: ffffffff8bf2b580
RBP: 0000000000000001 R08: ffff8880b843b8c8 R09: fffffbfff2111d1a
R10: ffffffff9088e8d7 R11: 0000000000000001 R12: ffffffff90891954
R13: ffffffff8dd65220 R14: ffff88802fa8bd00 R15: ffff8880b853adc0
 pick_next_task kernel/sched/core.c:6088 [inline]
 __schedule+0x212d/0x6150 kernel/sched/core.c:6805
 __schedule_loop kernel/sched/core.c:6945 [inline]
 schedule+0xe7/0x3a0 kernel/sched/core.c:6960
 schedule_timeout+0x123/0x290 kernel/time/sleep_timeout.c:99
 msleep+0x32/0x50 kernel/time/sleep_timeout.c:318
 nsim_fib4_rt_add+0xbfb/0x1670 drivers/net/netdevsim/fib.c:369
 nsim_fib4_rt_insert drivers/net/netdevsim/fib.c:432 [inline]
 nsim_fib4_event drivers/net/netdevsim/fib.c:464 [inline]
 nsim_fib_event drivers/net/netdevsim/fib.c:884 [inline]
 nsim_fib_event_work+0x2072/0x65f0 drivers/net/netdevsim/fib.c:1493
 process_one_work+0x9ba/0x1b20 kernel/workqueue.c:3257
 process_scheduled_works kernel/workqueue.c:3340 [inline]
 worker_thread+0x6c8/0xf10 kernel/workqueue.c:3421
 kthread+0x3c5/0x780 kernel/kthread.c:463
 ret_from_fork+0x983/0xb10 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246
 </TASK>
WARNING: kernel/sched/sched.h:1549 at lockdep_assert_rq_held kernel/sched/sched.h:1549 [inline], CPU#0: kworker/0:3/5931
WARNING: kernel/sched/sched.h:1549 at lockdep_assert_rq_held kernel/sched/sched.h:1547 [inline], CPU#0: kworker/0:3/5931
WARNING: kernel/sched/sched.h:1549 at update_rq_clock+0x34a/0xc70 kernel/sched/core.c:837, CPU#0: kworker/0:3/5931
Modules linked in:
CPU: 0 UID: 0 PID: 5931 Comm: kworker/0:3 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
Workqueue: events nsim_fib_event_work
RIP: 0010:lockdep_assert_rq_held kernel/sched/sched.h:1549 [inline]
RIP: 0010:lockdep_assert_rq_held kernel/sched/sched.h:1547 [inline]
RIP: 0010:update_rq_clock+0x34a/0xc70 kernel/sched/core.c:837
Code: ab 48 0b 00 00 48 83 c4 18 5b 5d 41 5c 41 5d 41 5e 41 5f e9 48 af ed 09 a8 04 0f 84 9c fd ff ff 90 0f 0b 90 e9 93 fd ff ff 90 <0f> 0b 90 e9 4f fd ff ff 48 8d bb 18 0e 00 00 48 b8 00 00 00 00 00
RSP: 0018:ffffc900037f7680 EFLAGS: 00010046
RAX: 0000000000000000 RBX: ffff8880b853adc0 RCX: 0000000000000001
RDX: 0000000000000000 RSI: ffffffff8daa490a RDI: ffffffff8bf2b580
RBP: 0000000000000001 R08: ffff8880b843b8c8 R09: fffffbfff2111d1a
R10: ffffffff9088e8d7 R11: 0000000000000001 R12: ffffffff90891954
R13: ffffffff8dd65220 R14: ffff88802fa8bd00 R15: ffff8880b853adc0
FS:  0000000000000000(0000) GS:ffff8881248fc000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f24f7bef358 CR3: 000000002939a000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 pick_next_task kernel/sched/core.c:6088 [inline]
 __schedule+0x212d/0x6150 kernel/sched/core.c:6805
 __schedule_loop kernel/sched/core.c:6945 [inline]
 schedule+0xe7/0x3a0 kernel/sched/core.c:6960
 schedule_timeout+0x123/0x290 kernel/time/sleep_timeout.c:99
 msleep+0x32/0x50 kernel/time/sleep_timeout.c:318
 nsim_fib4_rt_add+0xbfb/0x1670 drivers/net/netdevsim/fib.c:369
 nsim_fib4_rt_insert drivers/net/netdevsim/fib.c:432 [inline]
 nsim_fib4_event drivers/net/netdevsim/fib.c:464 [inline]
 nsim_fib_event drivers/net/netdevsim/fib.c:884 [inline]
 nsim_fib_event_work+0x2072/0x65f0 drivers/net/netdevsim/fib.c:1493
 process_one_work+0x9ba/0x1b20 kernel/workqueue.c:3257
 process_scheduled_works kernel/workqueue.c:3340 [inline]
 worker_thread+0x6c8/0xf10 kernel/workqueue.c:3421
 kthread+0x3c5/0x780 kernel/kthread.c:463
 ret_from_fork+0x983/0xb10 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246
 </TASK>