linux/drivers/atm
Duoming Zhou 8930878101 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(). 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. In a word, the tasklet_kill() should be placed in
the FORE200E_STATE_IRQ branch within the switch...case structure.

This bug was identified through static analysis.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable@kernel.org
Suggested-by: Jijie Shao <shaojijie@huawei.com>
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Reviewed-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260210094537.9767-1-duoming@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-02-12 18:57:02 -08:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
adummy.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
atmtcp.c atm: atmtcp: Prevent arbitrary write in atmtcp_recv_control(). 2025-08-22 17:23:15 -07:00
eni.c net: fill in MODULE_DESCRIPTION()s for ATM 2024-01-05 08:04:23 -08:00
eni.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fore200e.c atm: fore200e: fix use-after-free in tasklets during device removal 2026-02-12 18:57:02 -08:00
fore200e.h atm/fore200e: Delete unused 'fore200e_boards' 2024-05-06 18:26:47 -07:00
he.c atm: Fix dma_free_coherent() size 2026-01-08 08:47:32 -08:00
he.h atm: remove deprecated use of pci api 2015-01-18 00:28:41 -05:00
idt77105.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
idt77105.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
idt77252.c atm: idt77252: Use sb_pool_remove() 2026-01-06 18:04:59 -08:00
idt77252.h atm: idt77252: fix build broken on amd64 2021-02-15 12:36:27 -08:00
idt77252_tables.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
iphase.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
iphase.h atm: Replace custom isprint() with generic analogue 2021-05-10 14:51:01 -07:00
Kconfig net: atm: remove support for ZeitNet ZN122x ATM devices 2022-04-27 12:22:56 +01:00
lanai.c atm: lanai: fix "take a while" typo 2025-07-08 08:27:19 -07:00
Makefile net: atm: remove support for ZeitNet ZN122x ATM devices 2022-04-27 12:22:56 +01:00
midway.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nicstar.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
nicstar.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nicstarmac.c net: remove comments that mention obsolete __SLOW_DOWN_IO 2022-04-26 17:09:24 -07:00
nicstarmac.copyright
solos-attrlist.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
solos-pci.c atm: solos-pci: Fix potential deadlock on &tx_queue_lock 2023-12-09 21:17:45 +00:00
suni.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
suni.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tonga.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
zeprom.h atm: Fix typo 2021-05-21 13:55:32 -07:00