This is a note to let you know that I've just added the patch titled PCI/MSI: Destroy sysfs before freeing entries to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: pci-msi-destroy-sysfs-before-freeing-entries.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 3735459037114d31e5acd9894fad9aed104231a0 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Date: Tue, 9 Nov 2021 14:53:57 +0100 Subject: PCI/MSI: Destroy sysfs before freeing entries From: Thomas Gleixner <tglx@xxxxxxxxxxxxx> commit 3735459037114d31e5acd9894fad9aed104231a0 upstream. free_msi_irqs() frees the MSI entries before destroying the sysfs entries which are exposing them. Nothing prevents a concurrent free while a sysfs file is read and accesses the possibly freed entry. Move the sysfs release ahead of freeing the entries. Fixes: 1c51b50c2995 ("PCI/MSI: Export MSI mode using attributes, not kobjects") Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Bjorn Helgaas <helgaas@xxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Link: https://lore.kernel.org/r/87sfw5305m.ffs@tglx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/pci/msi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -368,6 +368,11 @@ static void free_msi_irqs(struct pci_dev for (i = 0; i < entry->nvec_used; i++) BUG_ON(irq_has_action(entry->irq + i)); + if (dev->msi_irq_groups) { + msi_destroy_sysfs(&dev->dev, dev->msi_irq_groups); + dev->msi_irq_groups = NULL; + } + pci_msi_teardown_msi_irqs(dev); list_for_each_entry_safe(entry, tmp, msi_list, list) { @@ -379,11 +384,6 @@ static void free_msi_irqs(struct pci_dev list_del(&entry->list); free_msi_entry(entry); } - - if (dev->msi_irq_groups) { - msi_destroy_sysfs(&dev->dev, dev->msi_irq_groups); - dev->msi_irq_groups = NULL; - } } static void pci_intx_for_msi(struct pci_dev *dev, int enable) Patches currently in stable-queue which might be from tglx@xxxxxxxxxxxxx are queue-5.15/pci-msi-move-non-mask-check-back-into-low-level-accessors.patch queue-5.15/ia64-kprobes-fix-to-pass-correct-trampoline-address-to-the-handler.patch queue-5.15/pci-msi-destroy-sysfs-before-freeing-entries.patch queue-5.15/rcu-always-inline-rcu_dynticks_task-_-enter-exit.patch queue-5.15/ftrace-do-cpu-checking-after-preemption-disabled.patch queue-5.15/irq-mips-avoid-nested-irq_enter.patch queue-5.15/rcu-fix-rcu_dynticks_curr_cpu_in_eqs-vs-noinstr.patch queue-5.15/x86-iopl-fake-iopl-3-cli-sti-usage.patch