syzbot


KASAN: use-after-free Read in usb_free_coherent

Status: fixed on 2019/09/06 20:45
Subsystems: usb
[Documentation on labels]
Reported-by: syzbot+d1fedb1c1fdb07fca507@syzkaller.appspotmail.com
Fix commit: fc05481b2fca usb: yurex: Fix use-after-free in yurex_delete
First crash: 1757d, last: 1745d
Discussions (8)
Title Replies (including bot) Last reply
[PATCH 3.16 00/83] 3.16.78-rc1 review 88 (88) 2019/11/21 21:42
[PATCH 4.4 00/78] 4.4.190-stable review 91 (91) 2019/08/24 18:14
[PATCH 4.9 000/103] 4.9.190-stable review 109 (109) 2019/08/24 17:59
[PATCH 5.2 000/144] 5.2.9-stable review 153 (153) 2019/08/16 07:15
[PATCH 4.14 00/69] 4.14.139-stable review 76 (76) 2019/08/16 07:15
[PATCH 4.19 00/91] 4.19.67-stable review 106 (106) 2019/08/16 06:53
[PATCH] usb: yurex: Fix use-after-free in yurex_delete 1 (1) 2019/08/05 11:15
KASAN: use-after-free Read in usb_free_coherent 2 (3) 2019/08/05 09:44

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in usb_free_coherent+0x79/0x80 drivers/usb/core/usb.c:928
Read of size 8 at addr ffff8881d59b9148 by task syz-executor.1/3392

CPU: 0 PID: 3392 Comm: syz-executor.1 Not tainted 5.3.0-rc2+ #25
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0xca/0x13e lib/dump_stack.c:113
 print_address_description+0x6a/0x32c mm/kasan/report.c:351
 __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482
 kasan_report+0xe/0x12 mm/kasan/common.c:612
 usb_free_coherent+0x79/0x80 drivers/usb/core/usb.c:928
 yurex_delete+0x138/0x330 drivers/usb/misc/yurex.c:100
 kref_put include/linux/kref.h:65 [inline]
 yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392
 __fput+0x2d7/0x840 fs/file_table.c:280
 task_work_run+0x13f/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x8ef/0x2c50 kernel/exit.c:878
 do_group_exit+0x125/0x340 kernel/exit.c:982
 get_signal+0x466/0x23d0 kernel/signal.c:2728
 do_signal+0x88/0x14e0 arch/x86/kernel/signal.c:815
 exit_to_usermode_loop+0x1a2/0x200 arch/x86/entry/common.c:159
 prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:274 [inline]
 do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457cf1
Code: Bad RIP value.
RSP: 002b:00007fff8471e2f0 EFLAGS: 00000293 ORIG_RAX: 0000000000000023
RAX: fffffffffffffdfc RBX: 0000000000016788 RCX: 0000000000457cf1
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00007fff8471e300
RBP: 0000000000000001 R08: 00000000c109b3a0 R09: 00000000c109b3a4
R10: 00007fff8471e3f0 R11: 0000000000000293 R12: 000000000075bf20
R13: 000000000075c9a0 R14: 00000000007617b0 R15: ffffffffffffffff

Allocated by task 17:
 save_stack+0x1b/0x80 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:487 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:460
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:748 [inline]
 usb_alloc_dev+0x51/0xf95 drivers/usb/core/usb.c:583
 hub_port_connect drivers/usb/core/hub.c:5004 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5213 [inline]
 port_event drivers/usb/core/hub.c:5359 [inline]
 hub_event+0x15c0/0x3640 drivers/usb/core/hub.c:5441
 process_one_work+0x92b/0x1530 kernel/workqueue.c:2269
 worker_thread+0x96/0xe20 kernel/workqueue.c:2415
 kthread+0x318/0x420 kernel/kthread.c:255
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

Freed by task 3392:
 save_stack+0x1b/0x80 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_slab_free+0x130/0x180 mm/kasan/common.c:449
 slab_free_hook mm/slub.c:1423 [inline]
 slab_free_freelist_hook mm/slub.c:1470 [inline]
 slab_free mm/slub.c:3012 [inline]
 kfree+0xe4/0x2f0 mm/slub.c:3953
 device_release+0x71/0x200 drivers/base/core.c:1064
 kobject_cleanup lib/kobject.c:693 [inline]
 kobject_release lib/kobject.c:722 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x171/0x280 lib/kobject.c:739
 put_device+0x1b/0x30 drivers/base/core.c:2213
 usb_put_dev+0x1f/0x30 drivers/usb/core/usb.c:725
 yurex_delete+0x40/0x330 drivers/usb/misc/yurex.c:95
 kref_put include/linux/kref.h:65 [inline]
 yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392
 __fput+0x2d7/0x840 fs/file_table.c:280
 task_work_run+0x13f/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x8ef/0x2c50 kernel/exit.c:878
 do_group_exit+0x125/0x340 kernel/exit.c:982
 get_signal+0x466/0x23d0 kernel/signal.c:2728
 do_signal+0x88/0x14e0 arch/x86/kernel/signal.c:815
 exit_to_usermode_loop+0x1a2/0x200 arch/x86/entry/common.c:159
 prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:274 [inline]
 do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8881d59b9100
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 72 bytes inside of
 2048-byte region [ffff8881d59b9100, ffff8881d59b9900)
The buggy address belongs to the page:
page:ffffea0007566e00 refcount:1 mapcount:0 mapping:ffff8881da00c000 index:0x0 compound_mapcount: 0
flags: 0x200000000010200(slab|head)
raw: 0200000000010200 ffffea0007561600 0000000200000002 ffff8881da00c000
raw: 0000000000000000 00000000000f000f 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881d59b9000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881d59b9080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881d59b9100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff8881d59b9180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881d59b9200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (310):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/08/12 12:02 https://github.com/google/kasan.git usb-fuzzer e96407b49762 8620c2c2 .config console log report ci2-upstream-usb
2019/08/12 08:58 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/12 07:46 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/12 05:03 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/12 04:50 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/12 03:24 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/12 02:06 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/12 00:52 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 23:51 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 22:22 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 21:14 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 20:00 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 18:30 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 15:45 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 12:00 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 09:31 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 07:52 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 07:27 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 03:43 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/11 01:57 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 21:49 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 20:47 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 19:28 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 18:21 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 16:34 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 15:24 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 14:07 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 12:50 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 11:49 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 09:35 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 07:46 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 06:22 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 05:13 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 04:05 https://github.com/google/kasan.git usb-fuzzer e96407b49762 acb51638 .config console log report ci2-upstream-usb
2019/08/10 01:29 https://github.com/google/kasan.git usb-fuzzer e96407b49762 aff9e255 .config console log report ci2-upstream-usb
2019/08/10 01:13 https://github.com/google/kasan.git usb-fuzzer e96407b49762 aff9e255 .config console log report ci2-upstream-usb
2019/08/10 00:09 https://github.com/google/kasan.git usb-fuzzer e96407b49762 aff9e255 .config console log report ci2-upstream-usb
2019/08/09 13:20 https://github.com/google/kasan.git usb-fuzzer e96407b49762 ede31a9b .config console log report ci2-upstream-usb
2019/08/09 11:05 https://github.com/google/kasan.git usb-fuzzer e96407b49762 ede31a9b .config console log report ci2-upstream-usb
2019/08/09 10:04 https://github.com/google/kasan.git usb-fuzzer e96407b49762 ede31a9b .config console log report ci2-upstream-usb
2019/08/09 08:15 https://github.com/google/kasan.git usb-fuzzer e96407b49762 ede31a9b .config console log report ci2-upstream-usb
2019/08/09 06:59 https://github.com/google/kasan.git usb-fuzzer e96407b49762 ede31a9b .config console log report ci2-upstream-usb
2019/08/09 04:03 https://github.com/google/kasan.git usb-fuzzer e96407b49762 ede31a9b .config console log report ci2-upstream-usb
2019/08/09 02:34 https://github.com/google/kasan.git usb-fuzzer e96407b49762 ede31a9b .config console log report ci2-upstream-usb
2019/08/01 00:46 https://github.com/google/kasan.git usb-fuzzer 7f7867ff95bf c692b5bd .config console log report ci2-upstream-usb
* Struck through repros no longer work on HEAD.