Skip to content

Commit 62f7306

Browse files
committed
Merge: PCI/MSI: Fix UAF in msi_capability_init
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4927 # Merge Request Required Information ## Summary of Changes PCI/MSI: Fix UAF in msi_capability_init ## Approved Development Ticket JIRA: https://issues.redhat.com/browse/RHEL-51436 CVE: CVE-2024-41096 Signed-off-by: John W. Linville <linville@redhat.com> Approved-by: Myron Stowe <mstowe@redhat.com> Approved-by: Charles Mirabile <cmirabil@redhat.com> Approved-by: Desnes Nunes <desnesn@redhat.com> Approved-by: Daniel Horak <dhorak@redhat.com> Approved-by: Lenny Szubowicz <lszubowi@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents b5e018f + 6bd68b7 commit 62f7306

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/pci/msi/msi.c

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

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

378384
/* Configure MSI capability structure */
379385
ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI);
@@ -393,7 +399,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,
393399
goto unlock;
394400

395401
err:
396-
pci_msi_unmask(entry, msi_multi_mask(entry));
402+
pci_msi_unmask(&desc, msi_multi_mask(&desc));
397403
pci_free_msi_irqs(dev);
398404
fail:
399405
dev->msi_enabled = 0;

0 commit comments

Comments
 (0)