mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: duoming@zju.edu.cn
To: "Jijie Shao" <shaojijie@huawei.com>
Cc: netdev@vger.kernel.org, linux-atm-general@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, 3chas3@gmail.com
Subject: Re: [PATCH net] atm: fore200e: fix use-after-free in tasklets during device removal
Date: Fri, 6 Feb 2026 17:24:23 +0800 (GMT+08:00)	[thread overview]
Message-ID: <2ea159e7.6ea9a.19c3244507b.Coremail.duoming@zju.edu.cn> (raw)
In-Reply-To: <b68a6d51-a416-4252-848e-0f3a8a3216bd@huawei.com>

On Fri, 6 Feb 2026 11:48:49 +0800 Jijie Shao wrote:
> > When the PCA-200E or SBA-200E adapters is being detached, the fore200e
> > is deallocated. However, the tx_tasklet or rx_tasklet may still be running
> > or pending, leading to use-after-free bug when the already freed fore200e
> > is accessed again in fore200e_tx_tasklet() or fore200e_rx_tasklet().
> >
> > One of the race conditions can occur as follows:
> >
> > CPU 0 (cleanup)           | CPU 1 (tasklet)
> > fore200e_pca_remove_one() | fore200e_interrupt()
> >    fore200e_shutdown()     |   tasklet_schedule()
> >      kfree(fore200e)       | fore200e_tx_tasklet()
> >                            |   fore200e-> // UAF
> >
> > Fix this by ensuring tx_tasklet or rx_tasklet is properly canceled before
> > the fore200e is released. Add tasklet_kill() in fore200e_shutdown() to
> > synchronize with any pending or running tasklets.
> >
> > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> > Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
> > ---
> >   drivers/atm/fore200e.c | 7 ++++++-
> >   1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
> > index f62e3857144..7470daf9469 100644
> > --- a/drivers/atm/fore200e.c
> > +++ b/drivers/atm/fore200e.c
> > @@ -358,7 +358,12 @@ fore200e_shutdown(struct fore200e* fore200e)
> >       printk(FORE200E "removing device %s at 0x%lx, IRQ %s\n",
> >   	   fore200e->name, fore200e->phys_base,
> >   	   fore200e_irq_itoa(fore200e->irq));
> > -
> > +
> > +#ifdef FORE200E_USE_TASKLET
> > +	tasklet_kill(&fore200e->tx_tasklet);
> > +	tasklet_kill(&fore200e->rx_tasklet);
> > +#endif
> > +
> >       if (fore200e->state > FORE200E_STATE_RESET) {
> >   	/* first, reset the board to prevent further interrupts or data transfers */
> >   	fore200e_reset(fore200e, 0);
> 
> Hi,
> 
> I personally think that tasklet_kill() should be moved here.
> According to the code comments, there will be no data transfers or interrupts after fore200e_reset(),
> otherwise fore200e->tx_tasklet may be rescheduled again in fore200e_interrupt().

Thank you for your suggestions! I think you are right. I will send the v2 patch
and move the tasklet_kill() after fore200e_reset().

Best regards,
Duoming Zhou

      reply	other threads:[~2026-02-06  9:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05  3:03 Duoming Zhou
2026-02-06  3:48 ` Jijie Shao
2026-02-06  9:24   ` duoming [this message]

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=2ea159e7.6ea9a.19c3244507b.Coremail.duoming@zju.edu.cn \
    --to=duoming@zju.edu.cn \
    --cc=3chas3@gmail.com \
    --cc=linux-atm-general@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shaojijie@huawei.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

all inboxes | Powered by JetHome®