lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <60202c25.703d4.19c460eafca.Coremail.duoming@zju.edu.cn>
Date: Tue, 10 Feb 2026 13:38:13 +0800 (GMT+08:00)
From: duoming@....edu.cn
To: "Jijie Shao" <shaojijie@...wei.com>
Cc: netdev@...r.kernel.org, 3chas3@...il.com,
	linux-atm-general@...ts.sourceforge.net,
	linux-kernel@...r.kernel.org, stable@...nel.org
Subject: Re: [PATCH net v3] atm: fore200e: fix use-after-free in tasklets
 during device removal

On Tue, 10 Feb 2026 09:46:53 +0800 Jijie Shao wrote:
> > When the PCA-200E or SBA-200E adapter 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. Moreover, since
> > fore200e_reset() could prevent further interrupts or data transfers,
> > the tasklet_kill() should be placed after fore200e_reset() to prevent
> > the tasklet from being rescheduled in fore200e_interrupt(). Finally,
> > it only needs to do tasklet_kill() when the fore200e state is greater
> > than or equal to FORE200E_STATE_IRQ, since tasklets are uninitialized
> > in earlier states.
> >
> > This bug was identified through static analysis.
> >
> > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> > Cc: stable@...nel.org
> > Suggested-by: Jijie Shao <shaojijie@...wei.com>
> > Signed-off-by: Duoming Zhou <duoming@....edu.cn>
> > ---
> > Changes in v3:
> >    - Only do tasklet_kill() when state >= FORE200E_STATE_IRQ.
> >    - Make the commit messages clearer.
> >
> >   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..eb386ec6b5e 100644
> > --- a/drivers/atm/fore200e.c
> > +++ b/drivers/atm/fore200e.c
> > @@ -363,7 +363,12 @@ fore200e_shutdown(struct fore200e* fore200e)
> >   	/* first, reset the board to prevent further interrupts or data transfers */
> >   	fore200e_reset(fore200e, 0);
> >       }
> > -
> > +#ifdef FORE200E_USE_TASKLET
> > +	if (fore200e->state >= FORE200E_STATE_IRQ) {
> > +		tasklet_kill(&fore200e->tx_tasklet);
> > +		tasklet_kill(&fore200e->rx_tasklet);
> > +	}
> > +#endif
> 
> The code appears to be misaligned.
> I see that in the original driver code, the first level of indentation uses 4 spaces,
> and the second level uses a TAB (8-character width).
> In your code, the first level uses a TAB, and the second level uses two TABs.
> Of course, your code complies with the current coding standards.
> 
> Additionally, I think a better modification would be to do tasklet_kill()
> in the "switch(fore200e->state)-case FORE200E_STATE_IRQ" branch,
> because "fore200e->tx_tasklet" is initialized together with "fore200e->irq".

Thank you for your suggestions! I will adjust the tasklet_kill() into the
"case FORE200E_STATE_IRQ" branch. The details are as follows:

diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index f62e3857144..fec081db36d 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -373,6 +373,10 @@ fore200e_shutdown(struct fore200e* fore200e)
        fallthrough;
     case FORE200E_STATE_IRQ:
        free_irq(fore200e->irq, fore200e->atm_dev);
+#ifdef FORE200E_USE_TASKLET
+       tasklet_kill(&fore200e->tx_tasklet);
+       tasklet_kill(&fore200e->rx_tasklet);
+#endif

Best regards,
Duoming Zhou

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ