syzbot


KASAN: use-after-free Write in smsc95xx_mdio_read

Status: fixed on 2020/07/09 11:56
Reported-by: syzbot+29dc7d4ae19b703ff947@syzkaller.appspotmail.com
Fix commit: ab9ee18f4646 usbnet: smsc95xx: Fix use-after-free after removal
First crash: 1625d, last: 1625d
Discussions (11)
Title Replies (including bot) Last reply
[PATCH AUTOSEL 5.7 01/53] soc: ti: omap-prm: use atomic iopoll instead of sleeping one 61 (61) 2020/07/09 23:49
[PATCH 5.4 00/65] 5.4.51-rc1 review 78 (78) 2020/07/09 09:30
[PATCH 5.7 000/112] 5.7.8-rc1 review 121 (121) 2020/07/09 09:29
[PATCH 4.19 00/36] 4.19.132-rc1 review 49 (49) 2020/07/08 17:52
[PATCH 4.14 00/27] 4.14.188-rc1 review 32 (32) 2020/07/08 17:52
[PATCH 4.9 00/24] 4.9.230-rc1 review 29 (29) 2020/07/08 17:51
[PATCH AUTOSEL 4.9 01/13] gpu: host1x: Detach driver on unregister 13 (13) 2020/07/02 01:27
[PATCH AUTOSEL 4.14 01/17] ARM: dts: omap4-droid4: Fix spi configuration and increase rate 17 (17) 2020/07/02 01:26
[PATCH AUTOSEL 4.19 01/27] regmap: fix alignment issue 27 (27) 2020/07/02 01:26
[PATCH AUTOSEL 5.4 01/40] regmap: fix alignment issue 40 (40) 2020/07/02 01:24
[PATCH] usbnet: smsc95xx: Fix use-after-free after removal 2 (2) 2020/06/22 23:34

Sample crash report:
smsc95xx 6-1:1.0 eth6 (unregistering): MII is busy in smsc95xx_mdio_read
==================================================================
BUG: KASAN: use-after-free in atomic64_cmpxchg include/asm-generic/atomic-instrumented.h:1463 [inline]
BUG: KASAN: use-after-free in atomic_long_cmpxchg_release include/asm-generic/atomic-long.h:424 [inline]
BUG: KASAN: use-after-free in __mutex_unlock_fast kernel/locking/mutex.c:181 [inline]
BUG: KASAN: use-after-free in mutex_unlock+0x19/0x40 kernel/locking/mutex.c:737
Write of size 8 at addr ffff8881d4152940 by task kworker/0:2/216

CPU: 0 PID: 216 Comm: kworker/0:2 Not tainted 5.4.46-syzkaller-00106-ga191332e9e93 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events check_carrier
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x14a/0x1ce lib/dump_stack.c:118
 print_address_description+0x93/0x620 mm/kasan/report.c:374
 __kasan_report+0x16d/0x1e0 mm/kasan/report.c:506
 kasan_report+0x34/0x60 mm/kasan/common.c:634
 check_memory_region_inline mm/kasan/generic.c:181 [inline]
 check_memory_region+0x2b5/0x2f0 mm/kasan/generic.c:191
 atomic64_cmpxchg include/asm-generic/atomic-instrumented.h:1463 [inline]
 atomic_long_cmpxchg_release include/asm-generic/atomic-long.h:424 [inline]
 __mutex_unlock_fast kernel/locking/mutex.c:181 [inline]
 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
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

Allocated by task 12:
 save_stack mm/kasan/common.c:69 [inline]
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc+0x12c/0x1c0 mm/kasan/common.c:510
 __kmalloc+0xf7/0x2d0 mm/slub.c:3821
 __kmalloc_node include/linux/slab.h:422 [inline]
 kmalloc_node include/linux/slab.h:599 [inline]
 kvmalloc_node+0xc2/0x120 mm/util.c:564
 kvmalloc include/linux/mm.h:678 [inline]
 kvzalloc include/linux/mm.h:686 [inline]
 alloc_netdev_mqs+0x85/0xc60 net/core/dev.c:9498
 usbnet_probe+0x1ae/0x2770 drivers/net/usb/usbnet.c:1686
 usb_probe_interface+0x631/0xad0 drivers/usb/core/driver.c:361
 really_probe+0x764/0xf70 drivers/base/dd.c:560
 driver_probe_device+0xe6/0x230 drivers/base/dd.c:729
 bus_for_each_drv+0x17a/0x200 drivers/base/bus.c:430
 __device_attach+0x27b/0x420 drivers/base/dd.c:902
 bus_probe_device+0xbb/0x200 drivers/base/bus.c:490
 device_add+0x13db/0x17c0 drivers/base/core.c:2644
 usb_set_configuration+0x197f/0x1f00 drivers/usb/core/message.c:2030
 generic_probe+0x82/0x140 drivers/usb/core/generic.c:210
 really_probe+0x764/0xf70 drivers/base/dd.c:560
 driver_probe_device+0xe6/0x230 drivers/base/dd.c:729
 bus_for_each_drv+0x17a/0x200 drivers/base/bus.c:430
 __device_attach+0x27b/0x420 drivers/base/dd.c:902
 bus_probe_device+0xbb/0x200 drivers/base/bus.c:490
 device_add+0x13db/0x17c0 drivers/base/core.c:2644
 usb_new_device+0xda7/0x1710 drivers/usb/core/hub.c:2554
 hub_port_connect drivers/usb/core/hub.c:5123 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5238 [inline]
 port_event drivers/usb/core/hub.c:5384 [inline]
 hub_event+0x2963/0x4fa0 drivers/usb/core/hub.c:5466
 process_one_work+0x777/0xf90 kernel/workqueue.c:2274
 worker_thread+0xa8f/0x1430 kernel/workqueue.c:2420
 kthread+0x2df/0x300 kernel/kthread.c:255
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

Freed by task 175:
 save_stack mm/kasan/common.c:69 [inline]
 set_track mm/kasan/common.c:77 [inline]
 kasan_set_free_info mm/kasan/common.c:332 [inline]
 __kasan_slab_free+0x181/0x230 mm/kasan/common.c:471
 slab_free_hook mm/slub.c:1424 [inline]
 slab_free_freelist_hook+0xd0/0x150 mm/slub.c:1457
 slab_free mm/slub.c:3014 [inline]
 kfree+0x12b/0x600 mm/slub.c:3975
 device_release+0x70/0x1a0 drivers/base/core.c:1519
 kobject_cleanup lib/kobject.c:693 [inline]
 kobject_release lib/kobject.c:722 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x1a9/0x250 lib/kobject.c:739
 usb_unbind_interface+0x1d8/0x850 drivers/usb/core/driver.c:423
 __device_release_driver drivers/base/dd.c:1142 [inline]
 device_release_driver_internal+0x515/0x7b0 drivers/base/dd.c:1173
 bus_remove_device+0x2e7/0x350 drivers/base/bus.c:532
 device_del+0x7bc/0x1200 drivers/base/core.c:2821
 usb_disable_device+0x3fe/0xc90 drivers/usb/core/message.c:1244
 usb_disconnect+0x341/0x880 drivers/usb/core/hub.c:2217
 hub_port_connect drivers/usb/core/hub.c:4974 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5238 [inline]
 port_event drivers/usb/core/hub.c:5384 [inline]
 hub_event+0x1c6c/0x4fa0 drivers/usb/core/hub.c:5466
 process_one_work+0x777/0xf90 kernel/workqueue.c:2274
 worker_thread+0xa8f/0x1430 kernel/workqueue.c:2420
 kthread+0x2df/0x300 kernel/kthread.c:255
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8881d4152000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 2368 bytes inside of
 4096-byte region [ffff8881d4152000, ffff8881d4153000)
The buggy address belongs to the page:
page:ffffea0007505400 refcount:1 mapcount:0 mapping:ffff8881da80c280 index:0x0 compound_mapcount: 0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 ffffea0007506c00 0000000200000002 ffff8881da80c280
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881d4152800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881d4152880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881d4152900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff8881d4152980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881d4152a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/06/12 07:33 https://android.googlesource.com/kernel/common android-5.4 a191332e9e93 819b58b0 .config console log report syz ci2-android-5-4-kasan
2020/06/12 07:14 https://android.googlesource.com/kernel/common android-5.4 a191332e9e93 819b58b0 .config console log report ci2-android-5-4-kasan
* Struck through repros no longer work on HEAD.