Skip to contentSkip to conversation

irqchip/gic: Check interrupt type validity

PATCH In review Florian Fainelli 2 participants 4 messages Oct 23, 2019 – Dec 10, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/gic: Check interrupt type validity

In case the interrupt property specifies a type parameter that is not GIC_SPI (0) or GIC_PPIC (1), do not attempt to translate the interrupt and return -EINVAL instead.

Fixes f833f57ff254 ("irqchip: Convert all alloc/xlate users from of_node to fwnode")

---
Marc,

Regardless of whether my attempt to use SGI moves any further, this seems appropriate to do since we should not be trying to translate incorrectly specified interrupts. Thanks!

 drivers/irqchip/irq-gic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/irqchip/irq-gic.c +3 -0
index 30ab623343d3..fc47e655618d 100644
@@ -1005,6 +1005,9 @@ static int gic_irq_domain_translate(struct irq_domain *d,
 		if (fwspec->param_count < 3)
 			return -EINVAL;
 
+		if (fwspec->param[0] > 1)
+			return -EINVAL;
+
 		/* Get the interrupt number and add 16 to skip over SGIs */
 		*hwirq = fwspec->param[1] + 16;
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Florian Fainelli

In case the interrupt property specifies a type parameter that is not GIC_SPI (0) or GIC_PPIC (1), do not attempt to translate the interrupt and return -EINVAL instead.

Quoted 8 lines
Fixes f833f57ff254 ("irqchip: Convert all alloc/xlate users from of_node to fwnode")

---
Marc,

Regardless of whether my attempt to use SGI moves any further, this seems appropriate to do since we should not be trying to translate incorrectly specified interrupts. Thanks!

Ping?

Quoted 19 lines
 drivers/irqchip/irq-gic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/irqchip/irq-gic.c +3 -0
index 30ab623343d3..fc47e655618d 100644
@@ -1005,6 +1005,9 @@ static int gic_irq_domain_translate(struct irq_domain *d,
 		if (fwspec->param_count < 3)
 			return -EINVAL;
 
+		if (fwspec->param[0] > 1)
+			return -EINVAL;
+
 		/* Get the interrupt number and add 16 to skip over SGIs */
 		*hwirq = fwspec->param[1] + 16;
 
Signature · 1 line
Florian
maintainer
#2 lore raw
In reply to Florian Fainelli
Quoted 21 lines · On Wed, 23 Oct 2019 12:56:19 -0700 Florian Fainelli <[email protected]>…

In case the interrupt property specifies a type parameter that is not GIC_SPI (0) or GIC_PPIC (1), do not attempt to translate the interrupt and return -EINVAL instead.

Fixes f833f57ff254 ("irqchip: Convert all alloc/xlate users from of_node to fwnode")

---
Marc,

Regardless of whether my attempt to use SGI moves any further, this seems appropriate to do since we should not be trying to translate incorrectly specified interrupts. Thanks!

 drivers/irqchip/irq-gic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/irqchip/irq-gic.c +0 -0
index 30ab623343d3..fc47e655618d 100644

drivers/irqchip/irq-gic.c static int gic_irq_domain_translate(struct irq_domain *d, · line 1013

Quoted 9 lines
drivers/irqchip/irq-gic.c +3 -0
@@ -1005,6 +1005,9 @@ static int gic_irq_domain_translate(struct irq_domain *d,
 		if (fwspec->param_count < 3)
 			return -EINVAL;
 
+		if (fwspec->param[0] > 1)
+			return -EINVAL;
+
 		/* Get the interrupt number and add 16 to skip over SGIs */
 		*hwirq = fwspec->param[1] + 16;
 

I'm in two minds about this.

The usual stance is that the kernel is not a validation suite for DT files, but on the other hand we already do some of that two lines above (a consequence of kernel and DT binding lockstep development...). Do we really want to add more of this? Or should we put more effort in static validation of DT files and actually remove these checks?

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#3 lore raw
Quoted 36 lines · Marc Zyngier
Quoted 21 lines · On Wed, 23 Oct 2019 12:56:19 -0700 Florian Fainelli <[email protected]>…

In case the interrupt property specifies a type parameter that is not GIC_SPI (0) or GIC_PPIC (1), do not attempt to translate the interrupt and return -EINVAL instead.

Fixes f833f57ff254 ("irqchip: Convert all alloc/xlate users from of_node to fwnode")

---
Marc,

Regardless of whether my attempt to use SGI moves any further, this seems appropriate to do since we should not be trying to translate incorrectly specified interrupts. Thanks!

 drivers/irqchip/irq-gic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/irqchip/irq-gic.c +0 -0
index 30ab623343d3..fc47e655618d 100644

drivers/irqchip/irq-gic.c static int gic_irq_domain_translate(struct irq_domain *d, · line 1013

Quoted 9 lines
drivers/irqchip/irq-gic.c +3 -0
@@ -1005,6 +1005,9 @@ static int gic_irq_domain_translate(struct irq_domain *d,
 		if (fwspec->param_count < 3)
 			return -EINVAL;
 
+		if (fwspec->param[0] > 1)
+			return -EINVAL;
+
 		/* Get the interrupt number and add 16 to skip over SGIs */
 		*hwirq = fwspec->param[1] + 16;
 

I'm in two minds about this.

Quoted 5 lines

The usual stance is that the kernel is not a validation suite for DT files, but on the other hand we already do some of that two lines above (a consequence of kernel and DT binding lockstep development...). Do we really want to add more of this? Or should we put more effort in static validation of DT files and actually remove these checks?

Static validation is nice for DTS that live in the tree, if you have a platform that provides the FDT via firmware, and that firmware is handed over to a variety of people, who knows what they can do. My inclination would be to perform that check which is not costly and guarantees we don't feed garbage to the GIC driver.

Signature · 1 line
Florian