Commit 9a87edeb authored by Krishna Kumar's avatar Krishna Kumar Committed by Zeng Heng
Browse files

pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv

stable inclusion
from stable-v6.6.51
commit b82d4d5c736f4fd2ed224c35f554f50d1953d21e
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IARWMF
CVE: CVE-2024-46761

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b82d4d5c736f4fd2ed224c35f554f50d1953d21e



--------------------------------

[ Upstream commit 335e35b748527f0c06ded9eebb65387f60647fda ]

The hotplug driver for powerpc (pci/hotplug/pnv_php.c) causes a kernel
crash when we try to hot-unplug/disable the PCIe switch/bridge from
the PHB.

The crash occurs because although the MSI data structure has been
released during disable/hot-unplug path and it has been assigned
with NULL, still during unregistration the code was again trying to
explicitly disable the MSI which causes the NULL pointer dereference and
kernel crash.

The patch fixes the check during unregistration path to prevent invoking
pci_disable_msi/msix() since its data structure is already freed.

Reported-by: default avatarTimothy Pearson <tpearson@raptorengineering.com>
Closes: https://lore.kernel.org/all/1981605666.2142272.1703742465927.JavaMail.zimbra@raptorengineeringinc.com/


Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Tested-by: default avatarShawn Anastasio <sanastasio@raptorengineering.com>
Signed-off-by: default avatarKrishna Kumar <krishnak@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240701074513.94873-2-krishnak@linux.ibm.com


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
parent 2e95e7ba
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ static void pnv_php_disable_irq(struct pnv_php_slot *php_slot,
				bool disable_device)
{
	struct pci_dev *pdev = php_slot->pdev;
	int irq = php_slot->irq;
	u16 ctrl;

	if (php_slot->irq > 0) {
@@ -58,7 +57,7 @@ static void pnv_php_disable_irq(struct pnv_php_slot *php_slot,
		php_slot->wq = NULL;
	}

	if (disable_device || irq > 0) {
	if (disable_device) {
		if (pdev->msix_enabled)
			pci_disable_msix(pdev);
		else if (pdev->msi_enabled)