In the Linux kernel, the following vulnerability has been resolved: net: wan: farsync: Fix use-after-free bugs caused by unfinished tasklets When the FarSync T-series card is being detached, the fstcardinfo is deallocated in fstremoveone(). However, the fsttxtask or fstinttask may still be running or pending, leading to use-after-free bugs when the already freed fstcardinfo is accessed in fstprocesstxworkq() or fstprocessintworkq(). A typical race condition is depicted below: CPU 0 (cleanup) | CPU 1 (tasklet) | fststartxmit() fstremoveone() | taskletschedule() unregisterhdlcdevice()| | fstprocesstxworkq() //handler kfree(card) //free | dobottomhalftx() | card-> //use The following KASAN trace was captured: ================================================================== BUG: KASAN: slab-use-after-free in dobottomhalftx+0xb88/0xd00 Read of size 4 at addr ffff88800aad101c by task ksoftirqd/3/32 ... Call Trace: <IRQ> dumpstacklvl+0x55/0x70 printreport+0xcb/0x5d0 ? dobottomhalftx+0xb88/0xd00 kasanreport+0xb8/0xf0 ? dobottomhalftx+0xb88/0xd00 dobottomhalftx+0xb88/0xd00 ? rawspinlockirqsave+0x85/0xe0 ? pfxrawspinlockirqsave+0x10/0x10 ? pfxhrtimerrunqueues+0x10/0x10 fstprocesstxworkq+0x67/0x90 taskletactioncommon+0x1fa/0x720 ? hrtimerinterrupt+0x31f/0x780 handlesoftirqs+0x176/0x530 __irqexitrcu+0xab/0xe0 sysvec_apictimerinterrupt+0x70/0x80 ... Allocated by task 41 on cpu 3 at 72.330843s: kasansavestack+0x24/0x50 kasansavetrack+0x17/0x60 __kasankmalloc+0x7f/0x90 fstaddone+0x1a5/0x1cd0 localpciprobe+0xdd/0x190 pcideviceprobe+0x341/0x480 reallyprobe+0x1c6/0x6a0 __driverprobedevice+0x248/0x310 driverprobedevice+0x48/0x210 __deviceattachdriver+0x160/0x320 bus_foreachdrv+0x101/0x190 __deviceattach+0x198/0x3a0 deviceinitialprobe+0x78/0xa0 pcibusadddevice+0x81/0xc0 pcibusadddevices+0x7e/0x190 enableslot+0x9b9/0x1130 acpiphpcheckbridge.part.0+0x2e1/0x460 acpiphphotplugnotify+0x36c/0x3c0 acpidevicehotplug+0x203/0xb10 acpihotplugworkfn+0x59/0x80 ... Freed by task 41 on cpu 1 at 75.138639s: kasansavestack+0x24/0x50 kasansavetrack+0x17/0x60 kasansavefreeinfo+0x3b/0x60 _kasanslabfree+0x43/0x70 kfree+0x135/0x410 fstremoveone+0x2ca/0x540 pcideviceremove+0xa6/0x1d0 devicereleasedriverinternal+0x364/0x530 pcistopbusdevice+0x105/0x150 pcistopandremovebusdevice+0xd/0x20 disableslot+0x116/0x260 acpiphpdisableandejectslot+0x4b/0x190 acpiphphotplugnotify+0x230/0x3c0 acpidevicehotplug+0x203/0xb10 acpihotplugworkfn+0x59/0x80 ... The buggy address belongs to the object at ffff88800aad1000 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 28 bytes inside of freed 1024-byte region The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xaad0 head: order:3 mapcount:0 entiremapcount:0 nrpagesmapped:0 pincount:0 flags: 0x100000000000040(head|node=0|zone=1) pagetype: f5(slab) raw: 0100000000000040 ffff888007042dc0 dead000000000122 0000000000000000 raw: 0000000000000000 0000000080100010 00000000f5000000 0000000000000000 head: 0100000000000040 ffff888007042dc0 dead000000000122 0000000000000000 head: 0000000000000000 0000000080100010 00000000f5000000 0000000000000000 head: 0100000000000003 ffffea00002ab401 00000000ffffffff 00000000ffffffff head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88800aad0f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88800aad0f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88800aad1000: fa fb ---truncated---