From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932684AbcIBQNj (ORCPT ); Fri, 2 Sep 2016 12:13:39 -0400 Received: from terminus.zytor.com ([198.137.202.10]:54386 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932373AbcIBQNi (ORCPT ); Fri, 2 Sep 2016 12:13:38 -0400 Date: Fri, 2 Sep 2016 09:13:17 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: hpa@zytor.com, mark.rutland@arm.com, marc.zyngier@arm.com, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, majun258@huawei.com Reply-To: majun258@huawei.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, mark.rutland@arm.com, marc.zyngier@arm.com, hpa@zytor.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] genirq: Robustify handle_percpu_devid_irq() Git-Commit-ID: fc590c22f9f056ab50190b797f6cacead29f9b75 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: fc590c22f9f056ab50190b797f6cacead29f9b75 Gitweb: http://git.kernel.org/tip/fc590c22f9f056ab50190b797f6cacead29f9b75 Author: Thomas Gleixner AuthorDate: Fri, 2 Sep 2016 14:45:19 +0200 Committer: Thomas Gleixner CommitDate: Fri, 2 Sep 2016 18:06:49 +0200 genirq: Robustify handle_percpu_devid_irq() The percpu_devid handler is not robust against spurious interrupts. If a spurious interrupt happens and no action is installed then the handler crashes with a NULL pointer dereference. Add a sanity check for this and log the wreckage once in dmesg. Reported-by: Majun Signed-off-by: Thomas Gleixner Cc: Mark Rutland Cc: Marc Zyngier Cc: guohanjun@huawei.com Cc: dingtianhong@huawei.com Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1609021436160.5647@nanos --- kernel/irq/chip.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index b4c1bc7..93c373a 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -756,7 +756,6 @@ void handle_percpu_devid_irq(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); struct irqaction *action = desc->action; - void *dev_id = raw_cpu_ptr(action->percpu_dev_id); unsigned int irq = irq_desc_get_irq(desc); irqreturn_t res; @@ -765,9 +764,20 @@ void handle_percpu_devid_irq(struct irq_desc *desc) if (chip->irq_ack) chip->irq_ack(&desc->irq_data); - trace_irq_handler_entry(irq, action); - res = action->handler(irq, dev_id); - trace_irq_handler_exit(irq, action, res); + if (likely(action)) { + trace_irq_handler_entry(irq, action); + res = action->handler(irq, raw_cpu_ptr(action->percpu_dev_id)); + trace_irq_handler_exit(irq, action, res); + } else { + unsigned int cpu = smp_processor_id(); + bool enabled = cpumask_test_cpu(cpu, desc->percpu_enabled); + + if (enabled) + irq_percpu_disable(desc, cpu); + + pr_err_once("Spurious%s percpu IRQ%u on CPU%u\n", + enabled ? " and unmasked" : "", irq, cpu); + } if (chip->irq_eoi) chip->irq_eoi(&desc->irq_data);