KCSAN: data-race in __synchronize_irq / handle_irq_event

Status: moderation: reported on 2026/11/20 00:02
Subsystems: kernel
Labels: race:benign prio:low
[Documentation on labels]
Reported-by: syzbot+a6b82c5f167ee48c9ae4@syzkaller.appspotmail.com
First crash: 2d17h, last: 3h11m
✨ AI-generated root cause summary:

KCSAN reports a data race on irq_common_data::state_use_accessors between an interrupt handler clearing IRQD_IRQ_INPROGRESS via irqd_clear() in handle_irq_event() and a task performing a lockless spin-wait via irqd_irq_inprogress() in __synchronize_hardirq(). While handle_irq_event() holds desc->lock when calling irqd_clear(), __synchronize_hardirq() intentionally polls irqd_irq_inprogress() without desc->lock before acquiring desc->lock to double-check the state. Because irqd_irq_inprogress() and irqd_clear() perform plain, unmarked memory accesses (__irqd_to_state(d)) instead of READ_ONCE()/WRITE_ONCE() or data_race(), KCSAN flags the concurrent access.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 4405c18c95d2:

Root Cause Analysis

The KCSAN report identifies a data race on the 4-byte unsigned int field desc->irq_data.common->state_use_accessors (in struct irq_common_data, include/linux/irq.h:151), accessed via the __irqd_to_state(d) macro (ACCESS_PRIVATE((d)->common, state_use_accessors)). The value transition reported (0x1d440200 -> 0x1d400200) corresponds to clearing bit 18 (IRQD_IRQ_INPROGRESS, BIT(18)).

Conflicting Accesses

  1. Write (CPU 0, hardirq context): In handle_edge_irq() (kernel/irq/chip.c:827), desc->lock is held while invoking handle_irq_event() (kernel/irq/handle.c:255). handle_irq_event() sets IRQD_IRQ_INPROGRESS, drops desc->lock around handle_irq_event_percpu(desc), and then re-acquires raw_spin_lock(&desc->lock) before calling:

  2. Read (CPU 1, task context): When closing a serial port (serial8250_do_shutdown() at drivers/tty/serial/8250/8250_port.c:2453), synchronize_irq() (kernel/irq/manage.c:146) calls __synchronize_irq() -> __synchronize_hardirq() (kernel/irq/manage.c:51). Inside the outer do { ... } while (inprogress); loop, __synchronize_hardirq() intentionally spin-waits without holding desc->lock:

Mechanism & Missing Synchronization Annotation

__synchronize_hardirq() is deliberately designed to poll IRQD_IRQ_INPROGRESS without taking desc->lock first (as noted in the comment at kernel/irq/manage.c:57-60), and then immediately acquire guard(raw_spinlock_irqsave)(&desc->lock) (kernel/irq/manage.c:65) to re-check irqd_irq_inprogress(&desc->irq_data) under the lock. (Note that irq_wait_on_inprogress() in kernel/irq/chip.c:470 uses the same lockless polling pattern.)

Because neither the lockless spin-wait read in irqd_irq_inprogress() / __synchronize_hardirq() nor the state updates in irqd_clear() / irqd_set() use READ_ONCE()/WRITE_ONCE() (or data_race() for the unlocked polling read), the concurrent access is unmarked and triggers KCSAN. Using READ_ONCE() in irqd_irq_inprogress() (or data_race(irqd_irq_inprogress(...)) in the unlocked spin-wait loops) and WRITE_ONCE() in the irqd_* mutators in kernel/irq/internals.h (which are already serialized by desc->lock) would resolve the data race for KCSAN and prevent any compiler load/store tearing.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
09beecde assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in __synchronize_irq / handle_irq_event 2026/11/19 17:36 2026/11/19 17:36 2026/11/19 17:49 229865fb
126ca2ab assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in __synchronize_irq / handle_irq_event 2026/11/19 17:35 2026/11/19 17:35 2026/11/19 17:37 229865fb

Sample crash report:
==================================================================
BUG: KCSAN: data-race in __synchronize_irq / handle_irq_event

read-write to 0xffff8881000cca00 of 4 bytes by interrupt on cpu 0:
 irqd_set kernel/irq/internals.h:258 [inline]
 handle_irq_event+0x4a/0xf0 kernel/irq/handle.c:260
 handle_edge_irq+0x155/0x440 kernel/irq/chip.c:859
 generic_handle_irq_desc include/linux/irqdesc.h:188 [inline]
 handle_irq arch/x86/kernel/irq.c:209 [inline]
 call_irq_handler arch/x86/kernel/irq.c:-1 [inline]
 __common_interrupt+0x60/0xb0 arch/x86/kernel/irq.c:280
 common_interrupt+0x7e/0x90 arch/x86/kernel/irq.c:273
 asm_common_interrupt+0x26/0x40 arch/x86/include/asm/idtentry.h:665
 get_current arch/x86/include/asm/current.h:25 [inline]
 get_ctx kernel/kcsan/core.c:206 [inline]
 check_access kernel/kcsan/core.c:759 [inline]
 __tsan_read_write8+0x115/0x190 kernel/kcsan/core.c:1034
 mas_wr_node_store lib/maple_tree.c:3238 [inline]
 mas_wr_store_entry+0x3a20/0x5b90 lib/maple_tree.c:3569
 mas_store_gfp+0x493/0x580 lib/maple_tree.c:5022
 vma_iter_clear_gfp include/linux/mm.h:1839 [inline]
 do_vmi_align_munmap+0x2d2/0x4e0 mm/vma.c:1715
 do_vmi_munmap+0x1fe/0x240 mm/vma.c:1771
 __vm_munmap+0x192/0x2c0 mm/vma.c:3628
 __do_sys_munmap mm/mmap.c:1094 [inline]
 __se_sys_munmap mm/mmap.c:1091 [inline]
 __x64_sys_munmap+0x36/0x50 mm/mmap.c:1091
 x64_sys_call+0x23df/0x2550 arch/x86/include/generated/asm/syscalls_64.h:12
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

read to 0xffff8881000cca00 of 4 bytes by task 12103 on cpu 1:
 irqd_irq_inprogress include/linux/irq.h:353 [inline]
 __synchronize_hardirq kernel/irq/manage.c:61 [inline]
 __synchronize_irq+0x71/0x2c0 kernel/irq/manage.c:122
 synchronize_irq+0x28/0x40 kernel/irq/manage.c:151
 serial8250_do_shutdown+0x174/0x7f0 drivers/tty/serial/8250/8250_port.c:2453
 serial8250_shutdown+0x41/0x50 drivers/tty/serial/8250/8250_port.c:2500
 uart_port_shutdown drivers/tty/serial/serial_core.c:1892 [inline]
 uart_tty_port_shutdown+0x183/0x7b0 drivers/tty/serial/serial_core.c:1760
 tty_port_shutdown_locked drivers/tty/tty_port.c:362 [inline]
 tty_port_shutdown drivers/tty/tty_port.c:379 [inline]
 tty_port_close+0x191/0x250 drivers/tty/tty_port.c:734
 uart_close+0x48/0xe0 drivers/tty/serial/serial_core.c:1741
 tty_release+0x1e7/0xaf0 drivers/tty/tty_io.c:1720
 __fput+0x292/0x660 fs/file_table.c:512
 fput_close_sync+0xd5/0x1d0 fs/file_table.c:618
 filp_close_sync+0x27/0x40 fs/open.c:1574
 __range_close fs/file.c:919 [inline]
 __do_sys_close_range fs/file.c:1003 [inline]
 __se_sys_close_range+0x765/0x880 fs/file.c:954
 __x64_sys_close_range+0x43/0x50 fs/file.c:954
 x64_sys_call+0x2198/0x2550 arch/x86/include/generated/asm/syscalls_64.h:437
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

value changed: 0x1d400200 -> 0x1d440200

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 12103 Comm: syz.6.1724 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/19 21:51 upstream 8dac6df92a2e 229865fb .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __synchronize_irq / handle_irq_event
2026/11/19 07:37 upstream 4405c18c95d2 f138241c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __synchronize_irq / handle_irq_event
2026/11/19 07:34 upstream 4405c18c95d2 f138241c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __synchronize_irq / handle_irq_event
2026/11/19 07:34 upstream 4405c18c95d2 f138241c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __synchronize_irq / handle_irq_event
2026/11/19 03:03 upstream 4405c18c95d2 2006bdcc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __synchronize_irq / handle_irq_event
2026/11/19 03:01 upstream 4405c18c95d2 2006bdcc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __synchronize_irq / handle_irq_event
2026/11/17 22:45 upstream 63fdb511c27a 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __synchronize_irq / handle_irq_event
2026/11/17 07:05 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __synchronize_irq / handle_irq_event
2026/11/17 07:05 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in __synchronize_irq / handle_irq_event
* Struck through repros no longer work on HEAD.