lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170409195918.20864-1-hdegoede@redhat.com>
Date:   Sun,  9 Apr 2017 21:59:18 +0200
From:   Hans de Goede <hdegoede@...hat.com>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     Hans de Goede <hdegoede@...hat.com>, linux-acpi@...r.kernel.org,
        x86@...nel.org, linux-kernel@...r.kernel.org
Subject: [RFC] Fix shared irq trigger-flags conflict when old irqaction uses IRQF_TRIGGER_NONE

While writing a driver for the INT0002 ACPI device found on Intel
Bay and Cherry Trail devices I hit the following error:

"genirq: Flags mismatch irq 9. 00000084 (INT0002) vs. 00000080 (acpi)"

This is caused by drivers/acpi/osl.c first doing:

request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)

While the irqdata for the irq contains no trigger flags, resulting
in an irqaction with IRQF_TRIGGER_NONE.

And then the INT0002 driver I'm working on calling platform_get_irq
which does: irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);

And then request_irq(irq, ..., IRQF_SHARED, ...) on the irq returned
by platform_get_irq causes the error quoted above.

Arguably the genirq code should not hit the shared irq trigger-flags
mismatch code if the old irqaction has IRQF_TRIGGER_NONE as flags.

This patch is an attempt at fixing this, but I'm not sure it is the
right fix, hence it RFC status.

Signed-off-by: Hans de Goede <hdegoede@...hat.com>
---
 kernel/irq/manage.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index a4afe5c..24e5eef 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1212,8 +1212,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
 		 * set the trigger type must match. Also all must
 		 * agree on ONESHOT.
 		 */
+		unsigned int old_msk = old->flags & IRQF_TRIGGER_MASK;
+
+		if (!old_msk)
+			old_msk = irqd_get_trigger_type(&desc->irq_data);
+
 		if (!((old->flags & new->flags) & IRQF_SHARED) ||
-		    ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) ||
+		    ((old_msk ^ new->flags) & IRQF_TRIGGER_MASK) ||
 		    ((old->flags ^ new->flags) & IRQF_ONESHOT))
 			goto mismatch;
 
-- 
2.9.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ