mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] parisc: fix race in iosapic_unmask_irq() missing spinlock
@ 2026-12-04  9:57 zhangjiao2
  2026-12-04 19:14 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: zhangjiao2 @ 2026-12-04  9:57 UTC (permalink / raw)
  To: deller; +Cc: James.Bottomley, linux-parisc, linux-kernel, zhang jiao

From: zhang jiao <zhangjiao2@cmss.chinamobile.com>

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@cmss.chinamobile.com>
---
 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] parisc: fix race in iosapic_unmask_irq() missing spinlock
  2026-12-04  9:57 [PATCH] parisc: fix race in iosapic_unmask_irq() missing spinlock zhangjiao2
@ 2026-12-04 19:14 ` Helge Deller
  0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2026-12-04 19:14 UTC (permalink / raw)
  To: zhangjiao2; +Cc: James.Bottomley, linux-parisc, linux-kernel

On 12/4/26 10:57, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> 
> 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@cmss.chinamobile.com>
> ---
>   drivers/parisc/iosapic.c | 3 +++
>   1 file changed, 3 insertions(+)
Thanks for the patches, zhang jiao!
I've applied all 4 patches.

Thanks!
Helge

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04 19:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04  9:57 [PATCH] parisc: fix race in iosapic_unmask_irq() missing spinlock zhangjiao2
2026-12-04 19:14 ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®