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
-
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:
-
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.