FAILED: patch "[PATCH] PCI: hv: Fix a use-after-free bug in hv_eject_device_work()" failed to apply to 4.14-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4df591b20b80cb77920953812d894db259d85bd7 Mon Sep 17 00:00:00 2001
From: Dexuan Cui <[email protected]>
Date: Fri, 21 Jun 2019 23:45:23 +0000
Subject: [PATCH] PCI: hv: Fix a use-after-free bug in hv_eject_device_work()
Fix a use-after-free in hv_eject_device_work().
drivers/pci/controller/pci-hyperv.c +9 -6
@@ -1875,6 +1875,7 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus,static void hv_eject_device_work (struct work_struct *work) {struct pci_eject_response *ejct_pkt; +struct hv_pcibus_device *hbus;struct hv_pci_dev *hpdev;struct pci_dev *pdev;unsigned long flags;
@@ -1885,6 +1886,7 @@ static void hv_eject_device_work(struct work_struct *work) } ctxt; hpdev = container_of(work, struct hv_pci_dev, wrk); + hbus = hpdev->hbus;WARN_ON (hpdev->state != hv_pcichild_ejecting);
@@ -1895,8 +1897,7 @@ static void hv_eject_device_work(struct work_struct *work)* because hbus->pci_bus may not exist yet. */ wslot =wslot_to_devfn (hpdev->desc.win_slot.slot); - pdev =pci_get_domain_bus_and_slot (hpdev->hbus->sysdata.domain,0 , - wslot); + pdev =pci_get_domain_bus_and_slot (hbus->sysdata.domain,0 , wslot);if (pdev) {pci_lock_rescan_remove ();pci_stop_and_remove_bus_device (pdev);
@@ -1904,9 +1905,9 @@ static void hv_eject_device_work(struct work_struct *work)pci_unlock_rescan_remove (); } -spin_lock_irqsave (&hpdev->hbus->device_list_lock, flags); +spin_lock_irqsave (&hbus->device_list_lock, flags);list_del (&hpdev->list_entry); -spin_unlock_irqrestore (&hpdev->hbus->device_list_lock, flags); +spin_unlock_irqrestore (&hbus->device_list_lock, flags);if (hpdev->pci_slot)pci_destroy_slot (hpdev->pci_slot);
@@ -1915,7 +1916,7 @@ static void hv_eject_device_work(struct work_struct *work) ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message; ejct_pkt->message_type.type =PCI_EJECTION_COMPLETE ; ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; -vmbus_sendpacket (hpdev->hbus->hdev->channel, ejct_pkt, +vmbus_sendpacket (hbus->hdev->channel, ejct_pkt,sizeof (*ejct_pkt), (unsigned long )&ctxt.pkt,VM_PKT_DATA_INBAND ,0 );
@@ -1924,7 +1925,9 @@ static void hv_eject_device_work(struct work_struct *work)/* For the two refs got in new_pcichild_device() */ put_pcichild (hpdev);put_pcichild (hpdev); -put_hvpcibus (hpdev->hbus); +/* hpdev has been freed. Do not use it any more. */ + +put_hvpcibus (hbus); }/**
Quoted 26 lines
From: [email protected] <[email protected]>
Sent: Tuesday, July 23, 2019 4:59 AM
To: Dexuan Cui <[email protected]>; [email protected]; Michael Kelley <[email protected]>
Cc: [email protected]
Subject: FAILED: patch "[PATCH] PCI: hv: Fix a use-after-free bug inhv_eject_device_work()" failed to apply to 4.14-stable treeThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
4df591b20b80cb77920953812d894db259d85bd7Mon Sep 17 00:00:00 2001
From: Dexuan Cui <[email protected]>
Date: Fri, 21 Jun 2019 23:45:23 +0000
Subject: [PATCH] PCI: hv: Fix a use-after-free bug inhv_eject_device_work()
Quoted 7 lines
Fix a use-after-free in
hv_eject_device_work().Fixes 05f151a73ec2 ("PCI: hv: Fix a memory leak in hv_eject_device_work()")Signed-off-by Dexuan Cui <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Reviewed-by Michael Kelley <[email protected]>
Hi,
I backported this commit for v4.14.134.
Please see the attachment.
Thanks,
-- Dexuan
From 109cb4f465b0335cb32f897769293defcf1c2d0f Mon Sep 17 00:00:00 2001
From: Dexuan Cui <[email protected]>
Date: Tue, 23 Jul 2019 17:00:24 -0700
Subject: [PATCH for-4.14.134] PCI: hv: Fix a use-after-free bug in
hv_eject_device_work()
Reply-To: [email protected]
[ Upstream commit 4df591b20b80cb77920953812d894db259d85bd7 ]
Fix a use-after-free in hv_eject_device_work().
--- drivers/pci/host/pci-hyperv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/pci/host/pci-hyperv.c +9 -6
@@ -1912,6 +1912,7 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus,static void hv_eject_device_work (struct work_struct *work) {struct pci_eject_response *ejct_pkt; +struct hv_pcibus_device *hbus;struct hv_pci_dev *hpdev;struct pci_dev *pdev;unsigned long flags;
@@ -1922,6 +1923,7 @@ static void hv_eject_device_work(struct work_struct *work) } ctxt; hpdev = container_of(work, struct hv_pci_dev, wrk); + hbus = hpdev->hbus;if (hpdev->state != hv_pcichild_ejecting) {put_pcichild (hpdev, hv_pcidev_ref_pnp);
@@ -1935,8 +1937,7 @@ static void hv_eject_device_work(struct work_struct *work)* because hbus->pci_bus may not exist yet. */ wslot =wslot_to_devfn (hpdev->desc.win_slot.slot); - pdev =pci_get_domain_bus_and_slot (hpdev->hbus->sysdata.domain,0 , - wslot); + pdev =pci_get_domain_bus_and_slot (hbus->sysdata.domain,0 , wslot);if (pdev) {pci_lock_rescan_remove ();pci_stop_and_remove_bus_device (pdev);
@@ -1944,9 +1945,9 @@ static void hv_eject_device_work(struct work_struct *work)pci_unlock_rescan_remove (); } -spin_lock_irqsave (&hpdev->hbus->device_list_lock, flags); +spin_lock_irqsave (&hbus->device_list_lock, flags);list_del (&hpdev->list_entry); -spin_unlock_irqrestore (&hpdev->hbus->device_list_lock, flags); +spin_unlock_irqrestore (&hbus->device_list_lock, flags);if (hpdev->pci_slot)pci_destroy_slot (hpdev->pci_slot);
@@ -1955,14 +1956,16 @@ static void hv_eject_device_work(struct work_struct *work) ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message; ejct_pkt->message_type.type =PCI_EJECTION_COMPLETE ; ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; -vmbus_sendpacket (hpdev->hbus->hdev->channel, ejct_pkt, +vmbus_sendpacket (hbus->hdev->channel, ejct_pkt,sizeof (*ejct_pkt), (unsigned long )&ctxt.pkt,VM_PKT_DATA_INBAND ,0 );put_pcichild (hpdev, hv_pcidev_ref_childlist);put_pcichild (hpdev, hv_pcidev_ref_initial);put_pcichild (hpdev, hv_pcidev_ref_pnp); -put_hvpcibus (hpdev->hbus); + +/* hpdev has been freed. Do not use it any more. */ +put_hvpcibus (hbus); }/**
Signature · 1 line
1.8.3.1
[email protected]
maintainerQuoted 34 lines · Dexuan Cui
Quoted 26 lines
From: [email protected] <[email protected]>
Sent: Tuesday, July 23, 2019 4:59 AM
To: Dexuan Cui <[email protected]>; [email protected]; Michael Kelley <[email protected]>
Cc: [email protected]
Subject: FAILED: patch "[PATCH] PCI: hv: Fix a use-after-free bug inhv_eject_device_work()" failed to apply to 4.14-stable treeThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
4df591b20b80cb77920953812d894db259d85bd7Mon Sep 17 00:00:00 2001
From: Dexuan Cui <[email protected]>
Date: Fri, 21 Jun 2019 23:45:23 +0000
Subject: [PATCH] PCI: hv: Fix a use-after-free bug inhv_eject_device_work()Quoted 7 lines
Fix a use-after-free in
hv_eject_device_work().Fixes 05f151a73ec2 ("PCI: hv: Fix a memory leak in hv_eject_device_work()")Signed-off-by Dexuan Cui <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Reviewed-by Michael Kelley <[email protected]>
Quoted 3 lines
Hi,
I backported this commit for v4.14.134.
Please see the attachment.
Now applied, thanks.
greg k-h