Patch "can: c_can_pci: c_can_pci_remove(): fix use-after-free" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    can: c_can_pci: c_can_pci_remove(): fix use-after-free

to the 5.4-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:
     can-c_can_pci-c_can_pci_remove-fix-use-after-free.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 7e20a8bd39676cf1a8e33d3c502470f78743cef5
Author: Tong Zhang <ztong0001@xxxxxxxxx>
Date:   Sun Feb 28 21:45:11 2021 -0500

    can: c_can_pci: c_can_pci_remove(): fix use-after-free
    
    [ Upstream commit 0429d6d89f97ebff4f17f13f5b5069c66bde8138 ]
    
    There is a UAF in c_can_pci_remove(). dev is released by
    free_c_can_dev() and is used by pci_iounmap(pdev, priv->base) later.
    To fix this issue, save the mmio address before releasing dev.
    
    Fixes: 5b92da0443c2 ("c_can_pci: generic module for C_CAN/D_CAN on PCI")
    Link: https://lore.kernel.org/r/20210301024512.539039-1-ztong0001@xxxxxxxxx
    Signed-off-by: Tong Zhang <ztong0001@xxxxxxxxx>
    Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/can/c_can/c_can_pci.c b/drivers/net/can/c_can/c_can_pci.c
index 406b4847e5dc..7efb60b50876 100644
--- a/drivers/net/can/c_can/c_can_pci.c
+++ b/drivers/net/can/c_can/c_can_pci.c
@@ -239,12 +239,13 @@ static void c_can_pci_remove(struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
 	struct c_can_priv *priv = netdev_priv(dev);
+	void __iomem *addr = priv->base;
 
 	unregister_c_can_dev(dev);
 
 	free_c_can_dev(dev);
 
-	pci_iounmap(pdev, priv->base);
+	pci_iounmap(pdev, addr);
 	pci_disable_msi(pdev);
 	pci_clear_master(pdev);
 	pci_release_regions(pdev);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux