[PATCH] parisc: fix race in iosapic_unmask_irq() missing spinlock

From: zhangjiao2

Date: Fri Dec 04 2026 - 04:57:35 EST


From: zhang jiao <zhangjiao2@xxxxxxxxxxxxxxxxxxxx>

iosapic_unmask_irq() performs an IRDT entry write via
iosapic_set_irt_data() + iosapic_wr_irt_entry() without holding
iosapic_lock, while both iosapic_mask_irq() and
iosapic_set_affinity_irq() correctly hold the lock during similar
read-modify-write operations on the same hardware register.

This creates a race condition where iosapic_unmask_irq() can interleave
its two 32-bit writes to the IRDT entry with writes from a concurrent
set_affinity call, producing a corrupted hardware entry.

Add the missing spin_lock_irqsave/spin_unlock_irqrestore pair around
the IRDT write, matching the pattern used by the mask and set_affinity
callbacks.

Signed-off-by: zhang jiao <zhangjiao2@xxxxxxxxxxxxxxxxxxxx>
---
drivers/parisc/iosapic.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 035c996e3ca9..7a44e198f299 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -606,14 +606,17 @@ static void iosapic_mask_irq(struct irq_data *d)

static void iosapic_unmask_irq(struct irq_data *d)
{
+ unsigned long flags;
struct vector_info *vi = irq_data_get_irq_chip_data(d);
u32 d0, d1;

/* data is initialized by fixup_irq */
WARN_ON(vi->txn_irq == 0);

+ spin_lock_irqsave(&iosapic_lock, flags);
iosapic_set_irt_data(vi, &d0, &d1);
iosapic_wr_irt_entry(vi, d0, d1);
+ spin_unlock_irqrestore(&iosapic_lock, flags);

#ifdef DEBUG_IOSAPIC_IRT
{
--
2.33.0