Skip to content

Commit 4e41216

Browse files
committed
Merge tag 'irq_urgent_for_v6.10_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull irq fixes from Borislav Petkov: - Make sure multi-bridge machines get all eiointc interrupt controllers initialized even if the number of CPUs has been limited by a cmdline param - Make sure interrupt lines on liointc hw are configured properly even when interrupt routing changes - Avoid use-after-free in the error path of the MSI init code * tag 'irq_urgent_for_v6.10_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: PCI/MSI: Fix UAF in msi_capability_init irqchip/loongson-liointc: Set different ISRs for different cores irqchip/loongson-eiointc: Use early_cpu_to_node() instead of cpu_to_node()
2 parents 03c8b0b + 9eee533 commit 4e41216

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

drivers/irqchip/irq-loongson-eiointc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/irqchip/chained_irq.h>
1616
#include <linux/kernel.h>
1717
#include <linux/syscore_ops.h>
18+
#include <asm/numa.h>
1819

1920
#define EIOINTC_REG_NODEMAP 0x14a0
2021
#define EIOINTC_REG_IPMAP 0x14c0
@@ -339,7 +340,7 @@ static int __init pch_msi_parse_madt(union acpi_subtable_headers *header,
339340
int node;
340341

341342
if (cpu_has_flatmode)
342-
node = cpu_to_node(eiointc_priv[nr_pics - 1]->node * CORES_PER_EIO_NODE);
343+
node = early_cpu_to_node(eiointc_priv[nr_pics - 1]->node * CORES_PER_EIO_NODE);
343344
else
344345
node = eiointc_priv[nr_pics - 1]->node;
345346

@@ -431,7 +432,7 @@ int __init eiointc_acpi_init(struct irq_domain *parent,
431432
goto out_free_handle;
432433

433434
if (cpu_has_flatmode)
434-
node = cpu_to_node(acpi_eiointc->node * CORES_PER_EIO_NODE);
435+
node = early_cpu_to_node(acpi_eiointc->node * CORES_PER_EIO_NODE);
435436
else
436437
node = acpi_eiointc->node;
437438
acpi_set_vec_parent(node, priv->eiointc_domain, pch_group);

drivers/irqchip/irq-loongson-liointc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#define LIOINTC_INTC_CHIP_START 0x20
3030

31-
#define LIOINTC_REG_INTC_STATUS (LIOINTC_INTC_CHIP_START + 0x20)
31+
#define LIOINTC_REG_INTC_STATUS(core) (LIOINTC_INTC_CHIP_START + 0x20 + (core) * 8)
3232
#define LIOINTC_REG_INTC_EN_STATUS (LIOINTC_INTC_CHIP_START + 0x04)
3333
#define LIOINTC_REG_INTC_ENABLE (LIOINTC_INTC_CHIP_START + 0x08)
3434
#define LIOINTC_REG_INTC_DISABLE (LIOINTC_INTC_CHIP_START + 0x0c)
@@ -217,7 +217,7 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision,
217217
goto out_free_priv;
218218

219219
for (i = 0; i < LIOINTC_NUM_CORES; i++)
220-
priv->core_isr[i] = base + LIOINTC_REG_INTC_STATUS;
220+
priv->core_isr[i] = base + LIOINTC_REG_INTC_STATUS(i);
221221

222222
for (i = 0; i < LIOINTC_NUM_PARENT; i++)
223223
priv->handler[i].parent_int_map = parent_int_map[i];

drivers/pci/msi/msi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,
352352
struct irq_affinity *affd)
353353
{
354354
struct irq_affinity_desc *masks = NULL;
355-
struct msi_desc *entry;
355+
struct msi_desc *entry, desc;
356356
int ret;
357357

358358
/* Reject multi-MSI early on irq domain enabled architectures */
@@ -377,6 +377,12 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,
377377
/* All MSIs are unmasked by default; mask them all */
378378
entry = msi_first_desc(&dev->dev, MSI_DESC_ALL);
379379
pci_msi_mask(entry, msi_multi_mask(entry));
380+
/*
381+
* Copy the MSI descriptor for the error path because
382+
* pci_msi_setup_msi_irqs() will free it for the hierarchical
383+
* interrupt domain case.
384+
*/
385+
memcpy(&desc, entry, sizeof(desc));
380386

381387
/* Configure MSI capability structure */
382388
ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI);
@@ -396,7 +402,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,
396402
goto unlock;
397403

398404
err:
399-
pci_msi_unmask(entry, msi_multi_mask(entry));
405+
pci_msi_unmask(&desc, msi_multi_mask(&desc));
400406
pci_free_msi_irqs(dev);
401407
fail:
402408
dev->msi_enabled = 0;

0 commit comments

Comments
 (0)