[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260206094811.23431-1-duoming@zju.edu.cn>
Date: Fri, 6 Feb 2026 17:48:11 +0800
From: Duoming Zhou <duoming@....edu.cn>
To: netdev@...r.kernel.org
Cc: linux-atm-general@...ts.sourceforge.net,
linux-kernel@...r.kernel.org,
3chas3@...il.com,
shaojijie@...wei.com,
Duoming Zhou <duoming@....edu.cn>
Subject: [PATCH net v2] atm: fore200e: fix use-after-free in tasklets during device removal
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().
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Duoming Zhou <duoming@....edu.cn>
---
Changes in v2:
- Move tasklet_kill() after fore200e_reset().
drivers/atm/fore200e.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index f62e3857144..de04c407921 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -362,6 +362,10 @@ fore200e_shutdown(struct fore200e* fore200e)
if (fore200e->state > FORE200E_STATE_RESET) {
/* first, reset the board to prevent further interrupts or data transfers */
fore200e_reset(fore200e, 0);
+#ifdef FORE200E_USE_TASKLET
+ tasklet_kill(&fore200e->tx_tasklet);
+ tasklet_kill(&fore200e->rx_tasklet);
+#endif
}
/* then, release all allocated resources */
--
2.34.1
Powered by blists - more mailing lists