Skip to content

Commit b835a71

Browse files
dezgegdavem330
authored andcommitted
usbnet: smsc95xx: Fix use-after-free after removal
Syzbot reports an use-after-free in workqueue context: BUG: KASAN: use-after-free in mutex_unlock+0x19/0x40 kernel/locking/mutex.c:737 mutex_unlock+0x19/0x40 kernel/locking/mutex.c:737 __smsc95xx_mdio_read drivers/net/usb/smsc95xx.c:217 [inline] smsc95xx_mdio_read+0x583/0x870 drivers/net/usb/smsc95xx.c:278 check_carrier+0xd1/0x2e0 drivers/net/usb/smsc95xx.c:644 process_one_work+0x777/0xf90 kernel/workqueue.c:2274 worker_thread+0xa8f/0x1430 kernel/workqueue.c:2420 kthread+0x2df/0x300 kernel/kthread.c:255 It looks like that smsc95xx_unbind() is freeing the structures that are still in use by the concurrently running workqueue callback. Thus switch to using cancel_delayed_work_sync() to ensure the work callback really is no longer active. Reported-by: [email protected] Signed-off-by: Tuomas Tynkkynen <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f3fe412 commit b835a71

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/usb/smsc95xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf)
13241324
struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
13251325

13261326
if (pdata) {
1327-
cancel_delayed_work(&pdata->carrier_check);
1327+
cancel_delayed_work_sync(&pdata->carrier_check);
13281328
netif_dbg(dev, ifdown, dev->net, "free pdata\n");
13291329
kfree(pdata);
13301330
pdata = NULL;

0 commit comments

Comments
 (0)