Skip to contentSkip to conversation

irqdomain: fix regression for Xen guests

PATCH Applied Juergen Gross 3 participants 3 messages Feb 23, 2023 – Feb 24, 2023

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

PATCH 1/1 irqdomain: fix regression for Xen guests

The recent switch to per-domain locking caused a NULL dereference in irq_domain_create_hierarchy(), as Xen code is calling msi_create_irq_domain() with a NULL parent pointer.

Fix that by testing parent to be set before dereferencing it. For a non-existing parent the irq-domain's root will stay to point to itself.

Fixes 9dbb8e3452ab ("irqdomain: Switch to per-domain locking")
---
 kernel/irq/irqdomain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/irq/irqdomain.c +2 -1
index aa5b7eeeceb8..6522dfb2e49c 100644
@@ -1172,7 +1172,8 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
 		domain = __irq_domain_create(fwnode, 0, ~0, 0, ops, host_data);
 
 	if (domain) {
-		domain->root = parent->root;
+		if (parent)
+			domain->root = parent->root;
 		domain->parent = parent;
 		domain->flags |= flags;
 
Signature · 1 line
2.35.3
merge bot Applied
#1 lore raw

[tip: irq/urgent] irqdomain: Add missing NULL pointer check in irq_domain_create_hierarchy()

The following commit has been merged into the irq/urgent branch of tip:

The following commit has been merged into the irq/urgent branch of tip:

Commit-ID:     ad32ab9604f29827494024828f527228e84fbd2c
Gitweb:        https://git.kernel.org/tip/ad32ab9604f29827494024828f527228e84fbd2c
Author:        Juergen Gross <[email protected]>
AuthorDate:    Thu, 23 Feb 2023 09:38:00 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Thu, 23 Feb 2023 15:52:28 +01:00

irqdomain: Add missing NULL pointer check in irq_domain_create_hierarchy()

The recent switch to per-domain locking caused a NULL dereference in irq_domain_create_hierarchy(), as Xen code is calling msi_create_irq_domain() with a NULL parent pointer.

Fix that by testing parent to be set before dereferencing it. For a non-existing parent the irqdomain's root will stay to point to itself.

Fixes 9dbb8e3452ab ("irqdomain: Switch to per-domain locking")
---
 kernel/irq/irqdomain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/irq/irqdomain.c +2 -1
index aa5b7ee..6522dfb 100644
@@ -1172,7 +1172,8 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
 		domain = __irq_domain_create(fwnode, 0, ~0, 0, ops, host_data);
 
 	if (domain) {
-		domain->root = parent->root;
+		if (parent)
+			domain->root = parent->root;
 		domain->parent = parent;
 		domain->flags |= flags;
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Juergen Gross
Quoted 3 lines · Juergen Gross

The recent switch to per-domain locking caused a NULL dereference in irq_domain_create_hierarchy(), as Xen code is calling msi_create_irq_domain() with a NULL parent pointer.

This was unexpected. Apparently the Intel VMD driver also does this (see vmd_enable_domain()).

Quoted 3 lines

Fix that by testing parent to be set before dereferencing it. For a non-existing parent the irq-domain's root will stay to point to itself.

An alternative could be to have msi_create_irq_domain() handle the no-parent case explicitly, but this looks the right fix for now (e.g. as irq_domain_create_tree() does not take a flag parameter).

Quoted 11 lines
Fixes 9dbb8e3452ab ("irqdomain: Switch to per-domain locking")
---
 kernel/irq/irqdomain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/irq/irqdomain.c +0 -0
index aa5b7eeeceb8..6522dfb2e49c 100644

kernel/irq/irqdomain.c struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent, · line 1178

Quoted 8 lines
kernel/irq/irqdomain.c +2 -1
@@ -1172,7 +1172,8 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
 		domain = __irq_domain_create(fwnode, 0, ~0, 0, ops, host_data);
 
 	if (domain) {
-		domain->root = parent->root;
+		if (parent)
+			domain->root = parent->root;
 		domain->parent = parent;
 		domain->flags |= flags;

Johan