Kernel bug: possible deadlock in console_flush_all (4)
Subsystem: cgroups
Status: open

Crash report:
FAULT_INJECTION: forcing a failure.
name fail_usercopy, interval 1, probability 0, space 0, times 1
======================================================
WARNING: possible circular locking dependency detected
6.16.0-syzkaller-g561c80369df0 #0 Not tainted
------------------------------------------------------
syz-executor209/5878 is trying to acquire lock:
ffffffff8e12e120 (console_owner){-...}-{0:0}, at: rcu_try_lock_acquire include/linux/rcupdate.h:336 [inline]
ffffffff8e12e120 (console_owner){-...}-{0:0}, at: srcu_read_lock_nmisafe include/linux/srcu.h:319 [inline]
ffffffff8e12e120 (console_owner){-...}-{0:0}, at: console_srcu_read_lock kernel/printk/printk.c:288 [inline]
ffffffff8e12e120 (console_owner){-...}-{0:0}, at: console_flush_all+0x13a/0xc40 kernel/printk/printk.c:3203

but task is already holding lock:
ffff8880b8739718 (&pool->lock){-.-.}-{2:2}, at: __queue_work+0x809/0xfb0 kernel/workqueue.c:-1

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&pool->lock){-.-.}-{2:2}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
       __queue_work+0x809/0xfb0 kernel/workqueue.c:-1
       queue_work_on+0x181/0x270 kernel/workqueue.c:2390
       queue_work include/linux/workqueue.h:669 [inline]
       rpm_suspend+0xe54/0x1720 drivers/base/power/runtime.c:685
       __pm_runtime_idle+0x12f/0x1a0 drivers/base/power/runtime.c:1124
       pm_runtime_put include/linux/pm_runtime.h:555 [inline]
       __device_attach+0x342/0x400 drivers/base/dd.c:1049
       bus_probe_device+0x185/0x260 drivers/base/bus.c:537
       device_add+0x7b6/0xb50 drivers/base/core.c:3689
       serial_base_port_add+0x2e3/0x410 drivers/tty/serial/serial_base_bus.c:183
       serial_core_port_device_add drivers/tty/serial/serial_core.c:3309 [inline]
       serial_core_register_port+0x369/0x27c0 drivers/tty/serial/serial_core.c:3348
       serial8250_register_8250_port+0x16db/0x2050 drivers/tty/serial/8250/8250_core.c:829
       serial_pnp_probe+0x527/0x790 drivers/tty/serial/8250/8250_pnp.c:480
       pnp_device_probe+0x308/0x4c0 drivers/pnp/driver.c:111
       call_driver_probe drivers/base/dd.c:-1 [inline]
       really_probe+0x26d/0x9e0 drivers/base/dd.c:659
       __driver_probe_device+0x18c/0x2f0 drivers/base/dd.c:801
       driver_probe_device+0x4f/0x430 drivers/base/dd.c:831
       __driver_attach+0x452/0x700 drivers/base/dd.c:1217
       bus_for_each_dev+0x233/0x2b0 drivers/base/bus.c:370
       bus_add_driver+0x345/0x640 drivers/base/bus.c:678
       driver_register+0x23a/0x320 drivers/base/driver.c:249
       serial8250_init+0x8f/0x160 drivers/tty/serial/8250/8250_platform.c:315
       do_one_initcall+0x233/0x820 init/main.c:1269
       do_initcall_level+0x104/0x190 init/main.c:1331
       do_initcalls+0x59/0xa0 init/main.c:1347
       kernel_init_freeable+0x334/0x4b0 init/main.c:1579
       kernel_init+0x1d/0x1d0 init/main.c:1469
       ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

-> #2 (&dev->power.lock){-.-.}-{3:3}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xa7/0xf0 kernel/locking/spinlock.c:162
       __pm_runtime_resume+0x10f/0x180 drivers/base/power/runtime.c:1191
       pm_runtime_get include/linux/pm_runtime.h:492 [inline]
       __uart_start+0x171/0x460 drivers/tty/serial/serial_core.c:149
       uart_write+0xdc/0x130 drivers/tty/serial/serial_core.c:636
       process_output_block drivers/tty/n_tty.c:561 [inline]
       n_tty_write+0xd2c/0x1200 drivers/tty/n_tty.c:2377
       iterate_tty_write drivers/tty/tty_io.c:1006 [inline]
       file_tty_write+0x554/0xa20 drivers/tty/tty_io.c:1081
       new_sync_write fs/read_write.c:593 [inline]
       vfs_write+0x5c6/0xb30 fs/read_write.c:686
       ksys_write+0x145/0x250 fs/read_write.c:738
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&port_lock_key){-.-.}-{3:3}:
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xa7/0xf0 kernel/locking/spinlock.c:162
       uart_port_lock_irqsave include/linux/serial_core.h:717 [inline]
       serial8250_console_write+0x17e/0x1ba0 drivers/tty/serial/8250/8250_port.c:3355
       console_emit_next_record kernel/printk/printk.c:3138 [inline]
       console_flush_all+0x728/0xc40 kernel/printk/printk.c:3226
       __console_flush_and_unlock kernel/printk/printk.c:3285 [inline]
       console_unlock+0xc4/0x270 kernel/printk/printk.c:3325
       vprintk_emit+0x5b7/0x7a0 kernel/printk/printk.c:2450
       _printk+0xcf/0x120 kernel/printk/printk.c:2475
       register_console+0xa8b/0xf90 kernel/printk/printk.c:4126
       univ8250_console_init+0x3a/0x70 drivers/tty/serial/8250/8250_core.c:516
       console_init+0x10e/0x430 kernel/printk/printk.c:4325
       start_kernel+0x254/0x410 init/main.c:1035
       x86_64_start_reservations+0x24/0x30 arch/x86/kernel/head64.c:307
       x86_64_start_kernel+0x143/0x1c0 arch/x86/kernel/head64.c:288
       common_startup_64+0x13e/0x147

-> #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+0xb9b/0x2140 kernel/locking/lockdep.c:3908
       __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5237
       lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868
       console_lock_spinning_enable kernel/printk/printk.c:1924 [inline]
       console_emit_next_record kernel/printk/printk.c:3132 [inline]
       console_flush_all+0x6d2/0xc40 kernel/printk/printk.c:3226
       __console_flush_and_unlock kernel/printk/printk.c:3285 [inline]
       console_unlock+0xc4/0x270 kernel/printk/printk.c:3325
       vprintk_emit+0x5b7/0x7a0 kernel/printk/printk.c:2450
       _printk+0xcf/0x120 kernel/printk/printk.c:2475
       fail_dump lib/fault-inject.c:66 [inline]
       should_fail_ex+0x3f5/0x560 lib/fault-inject.c:174
       strncpy_from_user+0x36/0x290 lib/strncpy_from_user.c:118
       strncpy_from_user_nofault+0x72/0x150 mm/maccess.c:192
       bpf_probe_read_user_str_common kernel/trace/bpf_trace.c:215 [inline]
       ____bpf_probe_read_compat_str kernel/trace/bpf_trace.c:310 [inline]
       bpf_probe_read_compat_str+0xe2/0x180 kernel/trace/bpf_trace.c:306
       bpf_prog_9bca56546c9b26d5+0x46/0x4c
       bpf_dispatcher_nop_func include/linux/bpf.h:1332 [inline]
       __bpf_prog_run include/linux/filter.h:718 [inline]
       bpf_prog_run include/linux/filter.h:725 [inline]
       __bpf_trace_run kernel/trace/bpf_trace.c:2257 [inline]
       bpf_trace_run1+0x27f/0x4b0 kernel/trace/bpf_trace.c:2297
       __bpf_trace_workqueue_activate_work+0xae/0x100 include/trace/events/workqueue.h:59
       __do_trace_workqueue_activate_work include/trace/events/workqueue.h:59 [inline]
       trace_workqueue_activate_work+0x170/0x1d0 include/trace/events/workqueue.h:59
       __queue_work+0xcc2/0xfb0 kernel/workqueue.c:2338
       queue_work_on+0x181/0x270 kernel/workqueue.c:2390
       queue_work include/linux/workqueue.h:669 [inline]
       schedule_work include/linux/workqueue.h:730 [inline]
       net_enable_timestamp+0x145/0x190 net/core/dev.c:2373
       sk_setsockopt+0x1adb/0x2dc0 net/core/sock.c:1425
       do_sock_setsockopt+0x11b/0x1b0 net/socket.c:2340
       __sys_setsockopt net/socket.c:2369 [inline]
       __do_sys_setsockopt net/socket.c:2375 [inline]
       __se_sys_setsockopt net/socket.c:2372 [inline]
       __x64_sys_setsockopt+0x13f/0x1b0 net/socket.c:2372
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  console_owner --> &dev->power.lock --> &pool->lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&pool->lock);
                               lock(&dev->power.lock);
                               lock(&pool->lock);
  lock(console_owner);

 *** DEADLOCK ***

6 locks held by syz-executor209/5878:
 #0: ffff888032c60258 (sk_lock-AF_TIPC){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1667 [inline]
 #0: ffff888032c60258 (sk_lock-AF_TIPC){+.+.}-{0:0}, at: sockopt_lock_sock net/core/sock.c:1146 [inline]
 #0: ffff888032c60258 (sk_lock-AF_TIPC){+.+.}-{0:0}, at: sk_setsockopt+0xe10/0x2dc0 net/core/sock.c:1304
 #1: ffffffff8e139ee0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:331 [inline]
 #1: ffffffff8e139ee0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:841 [inline]
 #1: ffffffff8e139ee0 (rcu_read_lock){....}-{1:3}, at: __queue_work+0x102/0xfb0 kernel/workqueue.c:2259
 #2: ffff8880b8739718 (&pool->lock){-.-.}-{2:2}, at: __queue_work+0x809/0xfb0 kernel/workqueue.c:-1
 #3: ffffffff8e139ee0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:331 [inline]
 #3: ffffffff8e139ee0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:841 [inline]
 #3: ffffffff8e139ee0 (rcu_read_lock){....}-{1:3}, at: __bpf_trace_run kernel/trace/bpf_trace.c:2256 [inline]
 #3: ffffffff8e139ee0 (rcu_read_lock){....}-{1:3}, at: bpf_trace_run1+0x181/0x4b0 kernel/trace/bpf_trace.c:2297
 #4: ffffffff8e12e180 (console_lock){+.+.}-{0:0}, at: _printk+0xcf/0x120 kernel/printk/printk.c:2475
 #5: ffffffff8e015a50 (console_srcu){....}-{0:0}, at: rcu_try_lock_acquire include/linux/rcupdate.h:336 [inline]
 #5: ffffffff8e015a50 (console_srcu){....}-{0:0}, at: srcu_read_lock_nmisafe include/linux/srcu.h:319 [inline]
 #5: ffffffff8e015a50 (console_srcu){....}-{0:0}, at: console_srcu_read_lock kernel/printk/printk.c:288 [inline]
 #5: ffffffff8e015a50 (console_srcu){....}-{0:0}, at: console_flush_all+0x13a/0xc40 kernel/printk/printk.c:3203

stack backtrace:
CPU: 1 UID: 0 PID: 5878 Comm: syz-executor209 Not tainted 6.16.0-syzkaller-g561c80369df0 #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 print_circular_bug+0x2ee/0x310 kernel/locking/lockdep.c:2043
 check_noncircular+0x134/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+0xb9b/0x2140 kernel/locking/lockdep.c:3908
 __lock_acquire+0xab9/0xd20 kernel/locking/lockdep.c:5237
 lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5868
 console_lock_spinning_enable kernel/printk/printk.c:1924 [inline]
 console_emit_next_record kernel/printk/printk.c:3132 [inline]
 console_flush_all+0x6d2/0xc40 kernel/printk/printk.c:3226
 __console_flush_and_unlock kernel/printk/printk.c:3285 [inline]
 console_unlock+0xc4/0x270 kernel/printk/printk.c:3325
 vprintk_emit+0x5b7/0x7a0 kernel/printk/printk.c:2450
 _printk+0xcf/0x120 kernel/printk/printk.c:2475
 fail_dump lib/fault-inject.c:66 [inline]
 should_fail_ex+0x3f5/0x560 lib/fault-inject.c:174
 strncpy_from_user+0x36/0x290 lib/strncpy_from_user.c:118
 strncpy_from_user_nofault+0x72/0x150 mm/maccess.c:192
 bpf_probe_read_user_str_common kernel/trace/bpf_trace.c:215 [inline]
 ____bpf_probe_read_compat_str kernel/trace/bpf_trace.c:310 [inline]
 bpf_probe_read_compat_str+0xe2/0x180 kernel/trace/bpf_trace.c:306
 bpf_prog_9bca56546c9b26d5+0x46/0x4c
 bpf_dispatcher_nop_func include/linux/bpf.h:1332 [inline]
 __bpf_prog_run include/linux/filter.h:718 [inline]
 bpf_prog_run include/linux/filter.h:725 [inline]
 __bpf_trace_run kernel/trace/bpf_trace.c:2257 [inline]
 bpf_trace_run1+0x27f/0x4b0 kernel/trace/bpf_trace.c:2297
 __bpf_trace_workqueue_activate_work+0xae/0x100 include/trace/events/workqueue.h:59
 __do_trace_workqueue_activate_work include/trace/events/workqueue.h:59 [inline]
 trace_workqueue_activate_work+0x170/0x1d0 include/trace/events/workqueue.h:59
 __queue_work+0xcc2/0xfb0 kernel/workqueue.c:2338
 queue_work_on+0x181/0x270 kernel/workqueue.c:2390
 queue_work include/linux/workqueue.h:669 [inline]
 schedule_work include/linux/workqueue.h:730 [inline]
 net_enable_timestamp+0x145/0x190 net/core/dev.c:2373
 sk_setsockopt+0x1adb/0x2dc0 net/core/sock.c:1425
 do_sock_setsockopt+0x11b/0x1b0 net/socket.c:2340
 __sys_setsockopt net/socket.c:2369 [inline]
 __do_sys_setsockopt net/socket.c:2375 [inline]
 __se_sys_setsockopt net/socket.c:2372 [inline]
 __x64_sys_setsockopt+0x13f/0x1b0 net/socket.c:2372
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7feb755329e9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 a1 1a 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe51f7ea98 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00007ffe51f7eab0 RCX: 00007feb755329e9
RDX: 000000000000001d RSI: 0000000000000001 RDI: 0000000000000005
RBP: 0000000000000001 R08: 0000000000000004 R09: 0000000000000140
R10: 00002000000001c0 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>
CPU: 1 UID: 0 PID: 5878 Comm: syz-executor209 Not tainted 6.16.0-syzkaller-g561c80369df0 #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 fail_dump lib/fault-inject.c:73 [inline]
 should_fail_ex+0x414/0x560 lib/fault-inject.c:174
 strncpy_from_user+0x36/0x290 lib/strncpy_from_user.c:118
 strncpy_from_user_nofault+0x72/0x150 mm/maccess.c:192
 bpf_probe_read_user_str_common kernel/trace/bpf_trace.c:215 [inline]
 ____bpf_probe_read_compat_str kernel/trace/bpf_trace.c:310 [inline]
 bpf_probe_read_compat_str+0xe2/0x180 kernel/trace/bpf_trace.c:306
 bpf_prog_9bca56546c9b26d5+0x46/0x4c
 bpf_dispatcher_nop_func include/linux/bpf.h:1332 [inline]
 __bpf_prog_run include/linux/filter.h:718 [inline]
 bpf_prog_run include/linux/filter.h:725 [inline]
 __bpf_trace_run kernel/trace/bpf_trace.c:2257 [inline]
 bpf_trace_run1+0x27f/0x4b0 kernel/trace/bpf_trace.c:2297
 __bpf_trace_workqueue_activate_work+0xae/0x100 include/trace/events/workqueue.h:59
 __do_trace_workqueue_activate_work include/trace/events/workqueue.h:59 [inline]
 trace_workqueue_activate_work+0x170/0x1d0 include/trace/events/workqueue.h:59
 __queue_work+0xcc2/0xfb0 kernel/workqueue.c:2338
 queue_work_on+0x181/0x270 kernel/workqueue.c:2390
 queue_work include/linux/workqueue.h:669 [inline]
 schedule_work include/linux/workqueue.h:730 [inline]
 net_enable_timestamp+0x145/0x190 net/core/dev.c:2373
 sk_setsockopt+0x1adb/0x2dc0 net/core/sock.c:1425
 do_sock_setsockopt+0x11b/0x1b0 net/socket.c:2340
 __sys_setsockopt net/socket.c:2369 [inline]
 __do_sys_setsockopt net/socket.c:2375 [inline]
 __se_sys_setsockopt net/socket.c:2372 [inline]
 __x64_sys_setsockopt+0x13f/0x1b0 net/socket.c:2372
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7feb755329e9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 a1 1a 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe51f7ea98 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00007ffe51f7eab0 RCX: 00007feb755329e9
RDX: 000000000000001d RSI: 0000000000000001 RDI: 0000000000000005
RBP: 0000000000000001 R08: 0000000000000004 R09: 0000000000000140
R10: 00002000000001c0 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>