Skip to content

Commit 7e4fd7a

Browse files
author
Marc Zyngier
committed
irqchip/loongarch: Fix irq_domain_alloc_fwnode() abuse
The recently merged LoongArch drivers paper over the lack of topology information by creating a bunch of fwnodes for the irqchips. So far, so good. However, irq_domain_alloc_fwnode() is supposed to take a PA, and not a kernel VA blindly cast as a PA, potentially disclosing kernel VAs to userspace. In some other cases, even NULL is used as the PA, which is entertaining. Fix this by using the actual PA of the block when available, and switch to a named fwnode in the other cases. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Jianmin Lv <lvjianmin@loongson.cn> Link: https://lore.kernel.org/r/20220808105020.2689757-1-maz@kernel.org
1 parent fda7409 commit 7e4fd7a

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

drivers/irqchip/irq-loongarch-cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int __init cpuintc_acpi_init(union acpi_subtable_headers *header,
129129
clear_csr_ecfg(ECFG0_IM);
130130
clear_csr_estat(ESTATF_IP);
131131

132-
cpuintc_handle = irq_domain_alloc_fwnode(NULL);
132+
cpuintc_handle = irq_domain_alloc_named_fwnode("CPUINTC");
133133
irq_domain = irq_domain_create_linear(cpuintc_handle, EXCCODE_INT_NUM,
134134
&loongarch_cpu_intc_irq_domain_ops, NULL);
135135

drivers/irqchip/irq-loongson-eiointc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ int __init eiointc_acpi_init(struct irq_domain *parent,
348348
if (!priv)
349349
return -ENOMEM;
350350

351-
priv->domain_handle = irq_domain_alloc_fwnode((phys_addr_t *)acpi_eiointc);
351+
priv->domain_handle = irq_domain_alloc_named_id_fwnode("EIOPIC",
352+
acpi_eiointc->node);
352353
if (!priv->domain_handle) {
353354
pr_err("Unable to allocate domain handle\n");
354355
goto out_free_priv;

drivers/irqchip/irq-loongson-liointc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ int __init liointc_acpi_init(struct irq_domain *parent, struct acpi_madt_lio_pic
360360
parent_irq[0] = irq_create_mapping(parent, acpi_liointc->cascade[0]);
361361
parent_irq[1] = irq_create_mapping(parent, acpi_liointc->cascade[1]);
362362

363-
domain_handle = irq_domain_alloc_fwnode((phys_addr_t *)acpi_liointc);
363+
domain_handle = irq_domain_alloc_fwnode(&acpi_liointc->address);
364364
if (!domain_handle) {
365365
pr_err("Unable to allocate domain handle\n");
366366
return -ENOMEM;

drivers/irqchip/irq-loongson-pch-msi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ int __init pch_msi_acpi_init(struct irq_domain *parent,
282282
int ret;
283283
struct fwnode_handle *domain_handle;
284284

285-
domain_handle = irq_domain_alloc_fwnode((phys_addr_t *)acpi_pchmsi);
285+
domain_handle = irq_domain_alloc_fwnode(&acpi_pchmsi->msg_address);
286286
ret = pch_msi_init(acpi_pchmsi->msg_address, acpi_pchmsi->start,
287287
acpi_pchmsi->count, parent, domain_handle);
288288
if (ret < 0)

drivers/irqchip/irq-loongson-pch-pic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ int __init pch_pic_acpi_init(struct irq_domain *parent,
349349

350350
vec_base = acpi_pchpic->gsi_base - GSI_MIN_PCH_IRQ;
351351

352-
domain_handle = irq_domain_alloc_fwnode((phys_addr_t *)acpi_pchpic);
352+
domain_handle = irq_domain_alloc_fwnode(&acpi_pchpic->address);
353353
if (!domain_handle) {
354354
pr_err("Unable to allocate domain handle\n");
355355
return -ENOMEM;

0 commit comments

Comments
 (0)