From: Jakub Kicinski <kuba@kernel.org>
To: Zheng Wang <zyytlz.wz@163.com>
Cc: davem@davemloft.net, simon.horman@corigine.com,
edumazet@google.com, pabeni@redhat.com, petrm@nvidia.com,
thomas.lendacky@amd.com, wsa+renesas@sang-engineering.com,
leon@kernel.org, shayagr@amazon.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, hackerzheng666@gmail.com,
1395428693sheep@gmail.com, alex000young@gmail.com
Subject: Re: [PATCH v2] xirc2ps_cs: Fix use after free bug in xirc2ps_detach
Date: Mon, 13 Mar 2023 17:15:00 -0700 [thread overview]
Message-ID: <20230313171500.35400df5@kernel.org> (raw)
In-Reply-To: <20230311170836.3919005-1-zyytlz.wz@163.com>
On Sun, 12 Mar 2023 01:08:36 +0800 Zheng Wang wrote:
> 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>
> ---
> v2:
> - 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..c77ca11d9497 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");
>
Please fix the formatting and make sure you CC the maintainers when you
post v3.
next prev parent reply other threads:[~2023-03-14 0:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-11 17:08 [PATCH v2] xirc2ps_cs: Fix use after free bug in xirc2ps_detach Zheng Wang
2023-03-14 0:15 ` Jakub Kicinski [this message]
2023-03-14 2:12 ` Zheng Hacker
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230313171500.35400df5@kernel.org \
--to=kuba@kernel.org \
--cc=1395428693sheep@gmail.com \
--cc=alex000young@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hackerzheng666@gmail.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=shayagr@amazon.com \
--cc=simon.horman@corigine.com \
--cc=thomas.lendacky@amd.com \
--cc=wsa+renesas@sang-engineering.com \
--cc=zyytlz.wz@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox