Skip to content

Commit 175302f

Browse files
stonezdmdavem330
authored andcommitted
mISDN: hfcpci: Fix use-after-free bug in hfcpci_softirq
The function hfcpci_softirq() is a timer handler. If it is running, the timer_pending() will return 0 and the del_timer_sync() in HFC_cleanup() will not be executed. As a result, the use-after-free bug will happen. The process is shown below: (cleanup routine) | (timer handler) HFC_cleanup() | hfcpci_softirq() if (timer_pending(&hfc_tl)) | del_timer_sync() | ... | ... pci_unregister_driver(hc) | driver_unregister | driver_for_each_device bus_remove_driver | _hfcpci_softirq driver_detach | ... put_device(dev) //[1]FREE | | dev_get_drvdata(dev) //[2]USE The device is deallocated is position [1] and used in position [2]. Fix by removing the "timer_pending" check in HFC_cleanup(), which makes sure that the hfcpci_softirq() have finished before the resource is deallocated. Fixes: 009fc85 ("mISDN: fix possible use-after-free in HFC_cleanup()") Signed-off-by: Duoming Zhou <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent aabf615 commit 175302f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/isdn/hardware/mISDN/hfcpci.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,8 +2345,7 @@ HFC_init(void)
23452345
static void __exit
23462346
HFC_cleanup(void)
23472347
{
2348-
if (timer_pending(&hfc_tl))
2349-
del_timer_sync(&hfc_tl);
2348+
del_timer_sync(&hfc_tl);
23502349

23512350
pci_unregister_driver(&hfc_driver);
23522351
}

0 commit comments

Comments
 (0)