|
Lee, Chun-Yi |
cab17d |
From: Zheng Wang <zyytlz.wz@163.com>
|
|
Lee, Chun-Yi |
cab17d |
Date: Fri, 17 Mar 2023 00:15:26 +0800
|
|
Lee, Chun-Yi |
cab17d |
Subject: xirc2ps_cs: Fix use after free bug in xirc2ps_detach
|
|
Lee, Chun-Yi |
cab17d |
Patch-mainline: v6.3-rc4
|
|
Lee, Chun-Yi |
cab17d |
Git-commit: e8d20c3ded59a092532513c9bd030d1ea66f5f44
|
|
Lee, Chun-Yi |
cab17d |
References: bsc#1209871 CVE-2023-1670
|
|
Lee, Chun-Yi |
cab17d |
|
|
Lee, Chun-Yi |
cab17d |
In xirc2ps_probe, the local->tx_timeout_task was bounded
|
|
Lee, Chun-Yi |
cab17d |
with xirc2ps_tx_timeout_task. When timeout occurs,
|
|
Lee, Chun-Yi |
cab17d |
it will call xirc_tx_timeout->schedule_work to start the
|
|
Lee, Chun-Yi |
cab17d |
work.
|
|
Lee, Chun-Yi |
cab17d |
|
|
Lee, Chun-Yi |
cab17d |
When we call xirc2ps_detach to remove the driver, there
|
|
Lee, Chun-Yi |
cab17d |
may be a sequence as follows:
|
|
Lee, Chun-Yi |
cab17d |
|
|
Lee, Chun-Yi |
cab17d |
Stop responding to timeout tasks and complete scheduled
|
|
Lee, Chun-Yi |
cab17d |
tasks before cleanup in xirc2ps_detach, which will fix
|
|
Lee, Chun-Yi |
cab17d |
the problem.
|
|
Lee, Chun-Yi |
cab17d |
|
|
Lee, Chun-Yi |
cab17d |
CPU0 CPU1
|
|
Lee, Chun-Yi |
cab17d |
|
|
Lee, Chun-Yi |
cab17d |
|xirc2ps_tx_timeout_task
|
|
Lee, Chun-Yi |
cab17d |
xirc2ps_detach |
|
|
Lee, Chun-Yi |
cab17d |
free_netdev |
|
|
Lee, Chun-Yi |
cab17d |
kfree(dev); |
|
|
Lee, Chun-Yi |
cab17d |
|
|
|
Lee, Chun-Yi |
cab17d |
| do_reset
|
|
Lee, Chun-Yi |
cab17d |
| //use dev
|
|
Lee, Chun-Yi |
cab17d |
|
|
Lee, Chun-Yi |
cab17d |
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
|
|
Lee, Chun-Yi |
cab17d |
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
|
|
Lee, Chun-Yi |
cab17d |
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
Lee, Chun-Yi |
cab17d |
Acked-by: Lee, Chun-Yi <jlee@suse.com>
|
|
Lee, Chun-Yi |
cab17d |
---
|
|
Lee, Chun-Yi |
cab17d |
drivers/net/ethernet/xircom/xirc2ps_cs.c | 5 +++++
|
|
Lee, Chun-Yi |
cab17d |
1 file changed, 5 insertions(+)
|
|
Lee, Chun-Yi |
cab17d |
|
|
Lee, Chun-Yi |
cab17d |
--- a/drivers/net/ethernet/xircom/xirc2ps_cs.c
|
|
Lee, Chun-Yi |
cab17d |
+++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c
|
|
Lee, Chun-Yi |
cab17d |
@@ -503,6 +503,11 @@ static void
|
|
Lee, Chun-Yi |
cab17d |
xirc2ps_detach(struct pcmcia_device *link)
|
|
Lee, Chun-Yi |
cab17d |
{
|
|
Lee, Chun-Yi |
cab17d |
struct net_device *dev = link->priv;
|
|
Lee, Chun-Yi |
cab17d |
+ struct local_info *local = netdev_priv(dev);
|
|
Lee, Chun-Yi |
cab17d |
+
|
|
Lee, Chun-Yi |
cab17d |
+ netif_carrier_off(dev);
|
|
Lee, Chun-Yi |
cab17d |
+ netif_tx_disable(dev);
|
|
Lee, Chun-Yi |
cab17d |
+ cancel_work_sync(&local->tx_timeout_task);
|
|
Lee, Chun-Yi |
cab17d |
|
|
Lee, Chun-Yi |
cab17d |
dev_dbg(&link->dev, "detach\n");
|
|
Lee, Chun-Yi |
cab17d |
|