[3.19.y-ckt stable] Patch "x86/irq: Call chip->irq_set_affinity in proper context" has been added to the 3.19.y-ckt tree

Kamal Mostafa kamal at canonical.com
Tue Feb 9 22:41:46 UTC 2016


This is a note to let you know that I have just added a patch titled

    x86/irq: Call chip->irq_set_affinity in proper context

to the linux-3.19.y-queue branch of the 3.19.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.19.y-queue

This patch is scheduled to be released in version 3.19.8-ckt15.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.19.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

---8<------------------------------------------------------------

>From c2137ea97f9146787ad2a99c7b58ff095e21beda Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx at linutronix.de>
Date: Thu, 14 Jan 2016 08:43:38 +0100
Subject: x86/irq: Call chip->irq_set_affinity in proper context

commit e23b257c293ce4bcc8cabb2aa3097b6ed8a8261a upstream.

setup_ioapic_dest() calls irqchip->irq_set_affinity() completely
unprotected. That's wrong in several aspects:

 - it opens a race window where irq_set_affinity() can be interrupted and the
   irq chip left in unconsistent state.

 - it triggers a lockdep splat when we fix the vector race for 4.3+ because
   vector lock is taken with interrupts enabled.

The proper calling convention is irq descriptor lock held and interrupts
disabled.

Reported-and-tested-by: Borislav Petkov <bp at alien8.de>
Signed-off-by: Thomas Gleixner <tglx at linutronix.de>
Cc: Jiang Liu <jiang.liu at linux.intel.com>
Cc: Jeremiah Mahler <jmmahler at gmail.com>
Cc: andy.shevchenko at gmail.com
Cc: Guenter Roeck <linux at roeck-us.net>
Cc: Joe Lawrence <joe.lawrence at stratus.com>
Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1601140919420.3575@nanos
Signed-off-by: Thomas Gleixner <tglx at linutronix.de>
[ kamal: backport to 3.19-stable: context ]
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 arch/x86/kernel/apic/io_apic.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 3f5f604..43a541e 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2665,6 +2665,7 @@ void __init setup_ioapic_dest(void)
 {
 	int pin, ioapic, irq, irq_entry;
 	const struct cpumask *mask;
+	struct irq_desc *desc;
 	struct irq_data *idata;

 	if (skip_ioapic_setup == 1)
@@ -2679,7 +2680,9 @@ void __init setup_ioapic_dest(void)
 		if (irq < 0 || !mp_init_irq_at_boot(ioapic, irq))
 			continue;

-		idata = irq_get_irq_data(irq);
+		desc = irq_to_desc(irq);
+		raw_spin_lock_irq(&desc->lock);
+		idata = irq_desc_get_irq_data(desc);

 		/*
 		 * Honour affinities which have been set in early boot
@@ -2690,6 +2693,7 @@ void __init setup_ioapic_dest(void)
 			mask = apic->target_cpus();

 		x86_io_apic_ops.set_affinity(idata, mask, false);
+		raw_spin_unlock_irq(&desc->lock);
 	}

 }
--
1.9.1





More information about the kernel-team mailing list