Skip to contentSkip to conversation

ieee802154: atusb: fix use-after-free at disconnect

PATCH In review Johan Hovold 3 participants 3 messages Sep 19, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ieee802154: atusb: fix use-after-free at disconnect

The disconnect callback was accessing the hardware-descriptor private data after having having freed it.

Fixes 7490b008d123 ("ieee802154: add support for atusb transceiver")
Cc stable <[email protected]> # 4.2
Cc Alexander Aring <[email protected]>
Reported-by [email protected]

---

#syz test: https://github.com/google/kasan.git f0df5c1b

 drivers/net/ieee802154/atusb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ieee802154/atusb.c +2 -1
index ceddb424f887..0dd0ba915ab9 100644
@@ -1137,10 +1137,11 @@ static void atusb_disconnect(struct usb_interface *interface)
 
 	ieee802154_unregister_hw(atusb->hw);
 
+	usb_put_dev(atusb->usb_dev);
+
 	ieee802154_free_hw(atusb->hw);
 
 	usb_set_intfdata(interface, NULL);
-	usb_put_dev(atusb->usb_dev);
 
 	pr_debug("%s done\n", __func__);
 }
Signature · 1 line
2.23.0
syzbot
#1 lore raw

Re: KASAN: use-after-free Read in atusb_disconnect

syzbot has tested the proposed patch and the reproducer did not trigger crash:

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger crash:

Reported-and-tested-by [email protected]

Tested on:

commit:         f0df5c1b usb-fuzzer: main usb gadget fuzzer driver
git tree:       https://github.com/google/kasan.git
kernel config:  https://syzkaller.appspot.com/x/.config?x=5c6633fa4ed00be5
dashboard link: https://syzkaller.appspot.com/bug?extid=f4509a9138a1472e7e80
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
patch:          https://syzkaller.appspot.com/x/patch.diff?x=10f3ebb5600000

Note: testing is done by a robot and is best-effort only.

maintainer
#2 lore raw
In reply to Johan Hovold

Hello.

Quoted 23 lines · Johan Hovold

The disconnect callback was accessing the hardware-descriptor private data after having having freed it.

Fixes 7490b008d123 ("ieee802154: add support for atusb transceiver")
Cc stable <[email protected]> # 4.2
Cc Alexander Aring <[email protected]>
Reported-by [email protected]

---

#syz test: https://github.com/google/kasan.git f0df5c1b

 drivers/net/ieee802154/atusb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ieee802154/atusb.c +0 -0
index ceddb424f887..0dd0ba915ab9 100644
@@ -1137,10 +1137,11 @@ static void atusb_disconnect(struct usb_interface *interface)
 
 	ieee802154_unregister_hw(atusb->hw);

drivers/net/ieee802154/atusb.c static void atusb_disconnect(struct usb_interface *interface) · line 1147

Quoted 10 lines
drivers/net/ieee802154/atusb.c +2 -1
 
+	usb_put_dev(atusb->usb_dev);
+
 	ieee802154_free_hw(atusb->hw);
 
 	usb_set_intfdata(interface, NULL);
-	usb_put_dev(atusb->usb_dev);
 
 	pr_debug("%s done\n", __func__);
 }

This patch has been applied to the wpan tree and will be part of the next pull request to net.

Thanks a lot for having a look at this!

regards
Stefan Schmidt