[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <176194662566.2601451.1527641984431803773.tip-bot2@tip-bot2>
Date: Fri, 31 Oct 2025 21:37:05 -0000
From: "tip-bot2 for Muchun Song" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Muchun Song <songmuchun@...edance.com>,
Thomas Gleixner <tglx@...utronix.de>, x86@...nel.org,
linux-kernel@...r.kernel.org, maz@...nel.org
Subject: [tip: irq/core] genirq/proc: Fix race in show_irq_affinity()
The following commit has been merged into the irq/core branch of tip:
Commit-ID: 9ea2b810d51ae662cc5b5578f9395cb620a34a26
Gitweb: https://git.kernel.org/tip/9ea2b810d51ae662cc5b5578f9395cb620a34a26
Author: Muchun Song <songmuchun@...edance.com>
AuthorDate: Tue, 28 Oct 2025 17:04:08 +08:00
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitterDate: Fri, 31 Oct 2025 22:30:05 +01:00
genirq/proc: Fix race in show_irq_affinity()
Reading /proc/irq/N/smp_affinity* races with irq_set_affinity() and
irq_move_masked_irq(), leading to old or torn output for users.
After a user writes a new CPU mask to /proc/irq/N/affinity*, the syscall
returns success, yet a subsequent read of the same file immediately returns
a value different from what was just written.
That's due to a race between show_irq_affinity() and irq_move_masked_irq()
which lets the read observe a transient, inconsistent affinity mask.
Cure it by guarding the read with irq_desc::lock.
[ tglx: Massaged change log ]
Signed-off-by: Muchun Song <songmuchun@...edance.com>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Link: https://patch.msgid.link/20251028090408.76331-1-songmuchun@bytedance.com
---
kernel/irq/proc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 29c2404..77258ea 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -48,6 +48,8 @@ static int show_irq_affinity(int type, struct seq_file *m)
struct irq_desc *desc = irq_to_desc((long)m->private);
const struct cpumask *mask;
+ guard(raw_spinlock_irq)(&desc->lock);
+
switch (type) {
case AFFINITY:
case AFFINITY_LIST:
Powered by blists - more mailing lists