From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752802AbcAPVRV (ORCPT ); Sat, 16 Jan 2016 16:17:21 -0500 Received: from terminus.zytor.com ([198.137.202.10]:56528 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752672AbcAPVRS (ORCPT ); Sat, 16 Jan 2016 16:17:18 -0500 Date: Sat, 16 Jan 2016 13:15:54 -0800 From: tip-bot for Thomas Gleixner Message-ID: Cc: hpa@zytor.com, joe.lawrence@stratus.com, mingo@kernel.org, jmmahler@gmail.com, tglx@linutronix.de, linux@roeck-us.net, bp@alien8.de, linux-kernel@vger.kernel.org, jiang.liu@linux.intel.com Reply-To: linux-kernel@vger.kernel.org, jiang.liu@linux.intel.com, bp@alien8.de, linux@roeck-us.net, mingo@kernel.org, jmmahler@gmail.com, tglx@linutronix.de, joe.lawrence@stratus.com, hpa@zytor.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/irq: Call chip-> irq_set_affinity in proper context Git-Commit-ID: e23b257c293ce4bcc8cabb2aa3097b6ed8a8261a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: e23b257c293ce4bcc8cabb2aa3097b6ed8a8261a Gitweb: http://git.kernel.org/tip/e23b257c293ce4bcc8cabb2aa3097b6ed8a8261a Author: Thomas Gleixner AuthorDate: Thu, 14 Jan 2016 08:43:38 +0100 Committer: Thomas Gleixner CommitDate: Fri, 15 Jan 2016 13:43:58 +0100 x86/irq: Call chip->irq_set_affinity in proper context 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 Signed-off-by: Thomas Gleixner Cc: Jiang Liu Cc: Jeremiah Mahler Cc: andy.shevchenko@gmail.com Cc: Guenter Roeck Cc: Joe Lawrence Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1601140919420.3575@nanos Signed-off-by: Thomas Gleixner --- 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 f253218..fdb0fbf 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2521,6 +2521,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; struct irq_chip *chip; @@ -2536,7 +2537,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 @@ -2550,6 +2553,7 @@ void __init setup_ioapic_dest(void) /* Might be lapic_chip for irq 0 */ if (chip->irq_set_affinity) chip->irq_set_affinity(idata, mask, false); + raw_spin_unlock_irq(&desc->lock); } } #endif