syzbot


possible deadlock in serial8250_handle_irq

Status: upstream: reported on 2025/04/10 18:11
Reported-by: syzbot+92941aea813026040216@syzkaller.appspotmail.com
First crash: 11d, last: 11d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in serial8250_handle_irq hams 90 3d14h 640d 0/28 upstream: reported on 2023/07/22 01:33
linux-6.1 possible deadlock in serial8250_handle_irq 1 125d 125d 0/3 auto-obsoleted due to no activity on 2025/03/27 21:41

Sample crash report:
=====================================================
WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
5.15.180-syzkaller #0 Not tainted
-----------------------------------------------------
kworker/u4:8/4974 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
ffffffff8d4d7278 (disc_data_lock){.+.+}-{2:2}, at: sp_get drivers/net/hamradio/6pack.c:375 [inline]
ffffffff8d4d7278 (disc_data_lock){.+.+}-{2:2}, at: sixpack_write_wakeup+0x2c/0x3c0 drivers/net/hamradio/6pack.c:396

and this task is already holding:
ffffffff96dbf480 (&port_lock_key){-.-.}-{2:2}, at: uart_write+0x11e/0x930 drivers/tty/serial/serial_core.c:571
which would create a new lock dependency:
 (&port_lock_key){-.-.}-{2:2} -> (disc_data_lock){.+.+}-{2:2}

but this new dependency connects a HARDIRQ-irq-safe lock:
 (&port_lock_key){-.-.}-{2:2}

... which became HARDIRQ-irq-safe at:
  lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
  __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
  _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
  serial8250_handle_irq+0x73/0x600 drivers/tty/serial/8250/8250_port.c:1895
  serial8250_default_handle_irq+0xc8/0x1e0 drivers/tty/serial/8250/8250_port.c:1941
  serial8250_interrupt+0xa1/0x1e0 drivers/tty/serial/8250/8250_core.c:127
  __handle_irq_event_percpu+0x292/0xa70 kernel/irq/handle.c:156
  handle_irq_event_percpu kernel/irq/handle.c:196 [inline]
  handle_irq_event+0xff/0x2b0 kernel/irq/handle.c:213
  handle_edge_irq+0x245/0xbf0 kernel/irq/chip.c:819
  generic_handle_irq_desc include/linux/irqdesc.h:158 [inline]
  handle_irq arch/x86/kernel/irq.c:233 [inline]
  __common_interrupt+0xd7/0x1f0 arch/x86/kernel/irq.c:252
  common_interrupt+0xae/0xd0 arch/x86/kernel/irq.c:242
  asm_common_interrupt+0x22/0x40 arch/x86/include/asm/idtentry.h:667
  native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline]
  arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline]
  default_idle+0xb/0x10 arch/x86/kernel/process.c:722
  default_idle_call+0x81/0xc0 kernel/sched/idle.c:112
  cpuidle_idle_call kernel/sched/idle.c:194 [inline]
  do_idle+0x271/0x670 kernel/sched/idle.c:306
  cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:403
  start_secondary+0x371/0x500 arch/x86/kernel/smpboot.c:281
  secondary_startup_64_no_verify+0xb1/0xbb

to a HARDIRQ-irq-unsafe lock:
 (disc_data_lock){.+.+}-{2:2}

... which became HARDIRQ-irq-unsafe at:
...
  lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
  __raw_read_lock include/linux/rwlock_api_smp.h:149 [inline]
  _raw_read_lock+0x32/0x40 kernel/locking/spinlock.c:228
  sp_get drivers/net/hamradio/6pack.c:375 [inline]
  sixpack_receive_buf+0x51/0x1430 drivers/net/hamradio/6pack.c:438
  tty_ldisc_receive_buf+0x121/0x160 drivers/tty/tty_buffer.c:455
  tty_port_default_receive_buf+0x6a/0x90 drivers/tty/tty_port.c:39
  receive_buf drivers/tty/tty_buffer.c:471 [inline]
  flush_to_ldisc+0x2b9/0x540 drivers/tty/tty_buffer.c:523
  process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
  worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
  kthread+0x3f6/0x4f0 kernel/kthread.c:334
  ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

other info that might help us debug this:

 Possible interrupt unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(disc_data_lock);
                               local_irq_disable();
                               lock(&port_lock_key);
                               lock(disc_data_lock);
  <Interrupt>
    lock(&port_lock_key);

 *** DEADLOCK ***

6 locks held by kworker/u4:8/4974:
 #0: ffff888017479138 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work+0x78a/0x10c0 kernel/workqueue.c:2283
 #1: ffffc9000137fd20 ((work_completion)(&buf->work)){+.+.}-{0:0}, at: process_one_work+0x7d0/0x10c0 kernel/workqueue.c:2285
 #2: ffff888020518ca0 (&buf->lock){+.+.}-{3:3}, at: flush_to_ldisc+0x34/0x540 drivers/tty/tty_buffer.c:495
 #3: ffff888020121098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref+0x18/0x80 drivers/tty/tty_ldisc.c:273
 #4: ffffffff96dbf480 (&port_lock_key){-.-.}-{2:2}, at: uart_write+0x11e/0x930 drivers/tty/serial/serial_core.c:571
 #5: ffff888020121098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref+0x18/0x80 drivers/tty/tty_ldisc.c:273

the dependencies between HARDIRQ-irq-safe lock and the holding lock:
-> (&port_lock_key){-.-.}-{2:2} {
   IN-HARDIRQ-W at:
                    lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
                    __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
                    _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
                    serial8250_handle_irq+0x73/0x600 drivers/tty/serial/8250/8250_port.c:1895
                    serial8250_default_handle_irq+0xc8/0x1e0 drivers/tty/serial/8250/8250_port.c:1941
                    serial8250_interrupt+0xa1/0x1e0 drivers/tty/serial/8250/8250_core.c:127
                    __handle_irq_event_percpu+0x292/0xa70 kernel/irq/handle.c:156
                    handle_irq_event_percpu kernel/irq/handle.c:196 [inline]
                    handle_irq_event+0xff/0x2b0 kernel/irq/handle.c:213
                    handle_edge_irq+0x245/0xbf0 kernel/irq/chip.c:819
                    generic_handle_irq_desc include/linux/irqdesc.h:158 [inline]
                    handle_irq arch/x86/kernel/irq.c:233 [inline]
                    __common_interrupt+0xd7/0x1f0 arch/x86/kernel/irq.c:252
                    common_interrupt+0xae/0xd0 arch/x86/kernel/irq.c:242
                    asm_common_interrupt+0x22/0x40 arch/x86/include/asm/idtentry.h:667
                    native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline]
                    arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline]
                    default_idle+0xb/0x10 arch/x86/kernel/process.c:722
                    default_idle_call+0x81/0xc0 kernel/sched/idle.c:112
                    cpuidle_idle_call kernel/sched/idle.c:194 [inline]
                    do_idle+0x271/0x670 kernel/sched/idle.c:306
                    cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:403
                    start_secondary+0x371/0x500 arch/x86/kernel/smpboot.c:281
                    secondary_startup_64_no_verify+0xb1/0xbb
   IN-SOFTIRQ-W at:
                    lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
                    __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
                    _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
                    serial8250_handle_irq+0x73/0x600 drivers/tty/serial/8250/8250_port.c:1895
                    serial8250_default_handle_irq+0xc8/0x1e0 drivers/tty/serial/8250/8250_port.c:1941
                    serial8250_interrupt+0xa1/0x1e0 drivers/tty/serial/8250/8250_core.c:127
                    __handle_irq_event_percpu+0x292/0xa70 kernel/irq/handle.c:156
                    handle_irq_event_percpu kernel/irq/handle.c:196 [inline]
                    handle_irq_event+0xff/0x2b0 kernel/irq/handle.c:213
                    handle_edge_irq+0x245/0xbf0 kernel/irq/chip.c:819
                    generic_handle_irq_desc include/linux/irqdesc.h:158 [inline]
                    handle_irq arch/x86/kernel/irq.c:233 [inline]
                    __common_interrupt+0xd7/0x1f0 arch/x86/kernel/irq.c:252
                    common_interrupt+0x59/0xd0 arch/x86/kernel/irq.c:242
                    asm_common_interrupt+0x22/0x40 arch/x86/include/asm/idtentry.h:667
                    __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:161 [inline]
                    _raw_spin_unlock_irqrestore+0xd4/0x130 kernel/locking/spinlock.c:194
                    __mod_timer+0xa8e/0xeb0 kernel/time/timer.c:1065
                    call_timer_fn+0x16d/0x560 kernel/time/timer.c:1451
                    expire_timers kernel/time/timer.c:1496 [inline]
                    __run_timers+0x67c/0x890 kernel/time/timer.c:1767
                    run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1780
                    handle_softirqs+0x3a7/0x930 kernel/softirq.c:558
                    __do_softirq kernel/softirq.c:592 [inline]
                    invoke_softirq kernel/softirq.c:432 [inline]
                    __irq_exit_rcu+0x157/0x240 kernel/softirq.c:641
                    irq_exit_rcu+0x5/0x20 kernel/softirq.c:653
                    instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1108 [inline]
                    sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1108
                    asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:676
                    native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline]
                    arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline]
                    default_idle+0xb/0x10 arch/x86/kernel/process.c:722
                    default_idle_call+0x81/0xc0 kernel/sched/idle.c:112
                    cpuidle_idle_call kernel/sched/idle.c:194 [inline]
                    do_idle+0x271/0x670 kernel/sched/idle.c:306
                    cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:403
                    start_secondary+0x371/0x500 arch/x86/kernel/smpboot.c:281
                    secondary_startup_64_no_verify+0xb1/0xbb
   INITIAL USE at:
                   lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
                   __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
                   _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
                   serial8250_do_set_termios+0x544/0x1830 drivers/tty/serial/8250/8250_port.c:2773
                   uart_set_options+0x3e1/0x740 drivers/tty/serial/serial_core.c:2154
                   serial8250_console_setup+0x3be/0x650 drivers/tty/serial/8250/8250_port.c:3448
                   univ8250_console_setup+0xe3/0x180 drivers/tty/serial/8250/8250_core.c:605
                   console_call_setup+0xd2/0xf0 kernel/printk/printk.c:2897
                   try_enable_preferred_console+0x3e3/0x530 kernel/printk/printk.c:2938
                   register_console+0x2ef/0x940 kernel/printk/printk.c:3037
                   univ8250_console_init+0x41/0x50 drivers/tty/serial/8250/8250_core.c:690
                   console_init+0x18c/0x660 kernel/printk/printk.c:3207
                   start_kernel+0x301/0x540 init/main.c:1076
                   secondary_startup_64_no_verify+0xb1/0xbb
 }
 ... key      at: [<ffffffff96dbe960>] port_lock_key+0x0/0x20

the dependencies between the lock to be acquired
 and HARDIRQ-irq-unsafe lock:
-> (disc_data_lock){.+.+}-{2:2} {
   HARDIRQ-ON-R at:
                    lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
                    __raw_read_lock include/linux/rwlock_api_smp.h:149 [inline]
                    _raw_read_lock+0x32/0x40 kernel/locking/spinlock.c:228
                    sp_get drivers/net/hamradio/6pack.c:375 [inline]
                    sixpack_receive_buf+0x51/0x1430 drivers/net/hamradio/6pack.c:438
                    tty_ldisc_receive_buf+0x121/0x160 drivers/tty/tty_buffer.c:455
                    tty_port_default_receive_buf+0x6a/0x90 drivers/tty/tty_port.c:39
                    receive_buf drivers/tty/tty_buffer.c:471 [inline]
                    flush_to_ldisc+0x2b9/0x540 drivers/tty/tty_buffer.c:523
                    process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
                    worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
                    kthread+0x3f6/0x4f0 kernel/kthread.c:334
                    ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
   SOFTIRQ-ON-R at:
                    lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
                    __raw_read_lock include/linux/rwlock_api_smp.h:149 [inline]
                    _raw_read_lock+0x32/0x40 kernel/locking/spinlock.c:228
                    sp_get drivers/net/hamradio/6pack.c:375 [inline]
                    sixpack_receive_buf+0x51/0x1430 drivers/net/hamradio/6pack.c:438
                    tty_ldisc_receive_buf+0x121/0x160 drivers/tty/tty_buffer.c:455
                    tty_port_default_receive_buf+0x6a/0x90 drivers/tty/tty_port.c:39
                    receive_buf drivers/tty/tty_buffer.c:471 [inline]
                    flush_to_ldisc+0x2b9/0x540 drivers/tty/tty_buffer.c:523
                    process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
                    worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
                    kthread+0x3f6/0x4f0 kernel/kthread.c:334
                    ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
   INITIAL READ USE at:
                        lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
                        __raw_read_lock include/linux/rwlock_api_smp.h:149 [inline]
                        _raw_read_lock+0x32/0x40 kernel/locking/spinlock.c:228
                        sp_get drivers/net/hamradio/6pack.c:375 [inline]
                        sixpack_receive_buf+0x51/0x1430 drivers/net/hamradio/6pack.c:438
                        tty_ldisc_receive_buf+0x121/0x160 drivers/tty/tty_buffer.c:455
                        tty_port_default_receive_buf+0x6a/0x90 drivers/tty/tty_port.c:39
                        receive_buf drivers/tty/tty_buffer.c:471 [inline]
                        flush_to_ldisc+0x2b9/0x540 drivers/tty/tty_buffer.c:523
                        process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
                        worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
                        kthread+0x3f6/0x4f0 kernel/kthread.c:334
                        ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 }
 ... key      at: [<ffffffff8d4d7278>] disc_data_lock+0x18/0x100
 ... acquired at:
   lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
   __raw_read_lock include/linux/rwlock_api_smp.h:149 [inline]
   _raw_read_lock+0x32/0x40 kernel/locking/spinlock.c:228
   sp_get drivers/net/hamradio/6pack.c:375 [inline]
   sixpack_write_wakeup+0x2c/0x3c0 drivers/net/hamradio/6pack.c:396
   tty_wakeup+0xb3/0xf0 drivers/tty/tty_io.c:534
   tty_port_default_wakeup+0xa8/0x100 drivers/tty/tty_port.c:51
   serial8250_tx_chars+0x60d/0x800 drivers/tty/serial/8250/8250_port.c:1828
   __start_tx drivers/tty/serial/8250/8250_port.c:1548 [inline]
   serial8250_start_tx+0x722/0xa50 drivers/tty/serial/8250/8250_port.c:1652
   __uart_start drivers/tty/serial/serial_core.c:132 [inline]
   uart_write+0x6a2/0x930 drivers/tty/serial/serial_core.c:591
   decode_prio_command drivers/net/hamradio/6pack.c:886 [inline]
   sixpack_decode drivers/net/hamradio/6pack.c:959 [inline]
   sixpack_receive_buf+0x443/0x1430 drivers/net/hamradio/6pack.c:452
   tty_ldisc_receive_buf+0x121/0x160 drivers/tty/tty_buffer.c:455
   tty_port_default_receive_buf+0x6a/0x90 drivers/tty/tty_port.c:39
   receive_buf drivers/tty/tty_buffer.c:471 [inline]
   flush_to_ldisc+0x2b9/0x540 drivers/tty/tty_buffer.c:523
   process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
   worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
   kthread+0x3f6/0x4f0 kernel/kthread.c:334
   ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287


stack backtrace:
CPU: 0 PID: 4974 Comm: kworker/u4:8 Not tainted 5.15.180-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Workqueue: events_unbound flush_to_ldisc
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_bad_irq_dependency kernel/locking/lockdep.c:2567 [inline]
 check_irq_usage kernel/locking/lockdep.c:2806 [inline]
 check_prev_add kernel/locking/lockdep.c:3057 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain+0x4d01/0x5930 kernel/locking/lockdep.c:3788
 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
 __raw_read_lock include/linux/rwlock_api_smp.h:149 [inline]
 _raw_read_lock+0x32/0x40 kernel/locking/spinlock.c:228
 sp_get drivers/net/hamradio/6pack.c:375 [inline]
 sixpack_write_wakeup+0x2c/0x3c0 drivers/net/hamradio/6pack.c:396
 tty_wakeup+0xb3/0xf0 drivers/tty/tty_io.c:534
 tty_port_default_wakeup+0xa8/0x100 drivers/tty/tty_port.c:51
 serial8250_tx_chars+0x60d/0x800 drivers/tty/serial/8250/8250_port.c:1828
 __start_tx drivers/tty/serial/8250/8250_port.c:1548 [inline]
 serial8250_start_tx+0x722/0xa50 drivers/tty/serial/8250/8250_port.c:1652
 __uart_start drivers/tty/serial/serial_core.c:132 [inline]
 uart_write+0x6a2/0x930 drivers/tty/serial/serial_core.c:591
 decode_prio_command drivers/net/hamradio/6pack.c:886 [inline]
 sixpack_decode drivers/net/hamradio/6pack.c:959 [inline]
 sixpack_receive_buf+0x443/0x1430 drivers/net/hamradio/6pack.c:452
 tty_ldisc_receive_buf+0x121/0x160 drivers/tty/tty_buffer.c:455
 tty_port_default_receive_buf+0x6a/0x90 drivers/tty/tty_port.c:39
 receive_buf drivers/tty/tty_buffer.c:471 [inline]
 flush_to_ldisc+0x2b9/0x540 drivers/tty/tty_buffer.c:523
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/04/10 18:11 linux-5.15.y f7347f400572 1ef3ab4d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in serial8250_handle_irq
* Struck through repros no longer work on HEAD.