]> git.itanic.dy.fi Git - linux-stable/commit
xirc2ps_cs: Fix use after free bug in xirc2ps_detach
authorZheng Wang <zyytlz.wz@163.com>
Thu, 16 Mar 2023 16:15:26 +0000 (00:15 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Apr 2023 09:14:15 +0000 (11:14 +0200)
commitfe7eebebca51d56b900331c3052a6342731f1117
treec0cf006d62b3a8256fec217a6026b3dc913055e1
parent7bd0037822fd04da13721f77a42ee5a077d4c5fb
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@163.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/xircom/xirc2ps_cs.c