Skip to content

Commit 9ea2b81

Browse files
songmuchunKAGA-KOKO
authored andcommitted
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@bytedance.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://patch.msgid.link/20251028090408.76331-1-songmuchun@bytedance.com
1 parent 68c4c15 commit 9ea2b81

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

kernel/irq/proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ static int show_irq_affinity(int type, struct seq_file *m)
4848
struct irq_desc *desc = irq_to_desc((long)m->private);
4949
const struct cpumask *mask;
5050

51+
guard(raw_spinlock_irq)(&desc->lock);
52+
5153
switch (type) {
5254
case AFFINITY:
5355
case AFFINITY_LIST:

0 commit comments

Comments
 (0)