All of
 help / color / mirror / Atom feed
From: Zheng Wang <>
	Zheng Wang <>
Subject: [PATCH net v5] xirc2ps_cs: Fix use after free bug in xirc2ps_detach
Date: Fri, 17 Mar 2023 00:15:26 +0800	[thread overview]
Message-ID: <> (raw)

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

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_detach      |
  free_netdev       |
    kfree(dev);     |
                    | do_reset
                    |   //use dev

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Zheng Wang <>
- mov patch to patch net

- fix indentation error again

- fix indentation error suggested by Jakub Kicinski

- fix indentation error suggested by Simon Horman,
and stop the timeout tasks  suggested by Yunsheng Lin
 drivers/net/ethernet/xircom/xirc2ps_cs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/xircom/xirc2ps_cs.c b/drivers/net/ethernet/xircom/xirc2ps_cs.c
index 894e92ef415b..e04b3f7f2179 100644
--- a/drivers/net/ethernet/xircom/xirc2ps_cs.c
+++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c
@@ -503,7 +503,12 @@ 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");

                 reply	other threads:[~2023-03-16 16:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.