Patch "xirc2ps_cs: Fix use after free bug in xirc2ps_detach" has been added to the 6.2-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

    xirc2ps_cs: Fix use after free bug in xirc2ps_detach

to the 6.2-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:
     xirc2ps_cs-fix-use-after-free-bug-in-xirc2ps_detach.patch
and it can be found in the queue-6.2 subdirectory.

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



commit a7b5d414db93dd4632961ee25c99038a7a6eb9de
Author: Zheng Wang <zyytlz.wz@xxxxxxx>
Date:   Fri Mar 17 00:15:26 2023 +0800

    xirc2ps_cs: Fix use after free bug in xirc2ps_detach
    
    [ Upstream commit e8d20c3ded59a092532513c9bd030d1ea66f5f44 ]
    
    In xirc2ps_probe, the local->tx_timeout_task was bounded
    with xirc2ps_tx_timeout_task. When timeout occurs,
    it will call xirc_tx_timeout->schedule_work to start the
    work.
    
    When we call xirc2ps_detach to remove the driver, there
    may be a sequence as follows:
    
    Stop responding to timeout tasks and complete scheduled
    tasks before cleanup in xirc2ps_detach, which will fix
    the problem.
    
    CPU0                  CPU1
    
                        |xirc2ps_tx_timeout_task
    xirc2ps_detach      |
      free_netdev       |
        kfree(dev);     |
                        |
                        | do_reset
                        |   //use dev
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Zheng Wang <zyytlz.wz@xxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/xircom/xirc2ps_cs.c b/drivers/net/ethernet/xircom/xirc2ps_cs.c
index 894e92ef415b9..9f505cf02d965 100644
--- a/drivers/net/ethernet/xircom/xirc2ps_cs.c
+++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c
@@ -503,6 +503,11 @@ static void
 xirc2ps_detach(struct pcmcia_device *link)
 {
     struct net_device *dev = link->priv;
+    struct local_info *local = netdev_priv(dev);
+
+    netif_carrier_off(dev);
+    netif_tx_disable(dev);
+    cancel_work_sync(&local->tx_timeout_task);
 
     dev_dbg(&link->dev, "detach\n");
 



[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