syzbot


KASAN: use-after-free Read in em28xx_close_extension
Status: upstream: reported C repro on 2021/07/14 14:27
Reported-by: syzbot+005037419ebdf14e1d87@syzkaller.appspotmail.com
First crash: 314d, last: 109d

Cause bisection: introduced by (bisect log) :
commit ac5688637144644f06ed1f3c6d4dd8bb7db96020
Author: Igor Matheus Andrade Torrente <igormtorrente@gmail.com>
Date: Tue May 4 18:32:49 2021 +0000

  media: em28xx: Fix possible memory leak of em28xx struct

Crash: KASAN: use-after-free Read in em28xx_close_extension (log)
Repro: C syz .config

Fix bisection: fixed by (bisect log) :
commit 0766ec82e5fb26fc5dc6d592bc61865608bdc651
Author: Stephen Brennan <stephen.s.brennan@oracle.com>
Date: Wed Sep 1 17:51:41 2021 +0000

  namei: Fix use after free in kern_path_locked

Patch testing requests:
Created Duration User Patch Repo Result
2021/07/15 10:05 18m mudongliangabcd@gmail.com patch upstream OK

Sample crash report:
usb 1-1: bad CDC descriptors
usb 1-1: USB disconnect, device number 2
em28xx 1-1:64.138: Disconnecting em28xx
em28xx 1-1:64.138: Closing input extension
em28xx 1-1:64.138: Freeing device
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0xcc/0xf0 lib/list_debug.c:42
Read of size 8 at addr ffff88802a160258 by task kworker/1:2/2959

CPU: 1 PID: 2959 Comm: kworker/1:2 Not tainted 5.14.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: usb_hub_wq hub_event
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
 print_address_description.constprop.0.cold+0x6c/0x309 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:436
 __list_del_entry_valid+0xcc/0xf0 lib/list_debug.c:42
 __list_del_entry include/linux/list.h:132 [inline]
 list_del include/linux/list.h:146 [inline]
 em28xx_close_extension+0x10b/0x2a0 drivers/media/usb/em28xx/em28xx-core.c:1146
 em28xx_usb_disconnect.cold+0x14b/0x237 drivers/media/usb/em28xx/em28xx-cards.c:4140
 usb_unbind_interface+0x1d8/0x8d0 drivers/usb/core/driver.c:458
 __device_release_driver+0x3bd/0x6f0 drivers/base/dd.c:1201
 device_release_driver_internal drivers/base/dd.c:1232 [inline]
 device_release_driver+0x26/0x40 drivers/base/dd.c:1255
 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:529
 device_del+0x502/0xd40 drivers/base/core.c:3543
 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1419
 usb_disconnect.cold+0x27a/0x78e drivers/usb/core/hub.c:2225
 hub_port_connect drivers/usb/core/hub.c:5199 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5488 [inline]
 port_event drivers/usb/core/hub.c:5634 [inline]
 hub_event+0x1c9c/0x4330 drivers/usb/core/hub.c:5716
 process_one_work+0x98d/0x1630 kernel/workqueue.c:2276
 process_scheduled_works kernel/workqueue.c:2338 [inline]
 worker_thread+0x85c/0x11f0 kernel/workqueue.c:2424
 kthread+0x3e5/0x4d0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the page:
page:ffffea0000a85800 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2a160
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0000b34d08 ffff8880b9d57350 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), pid 2959, ts 70777878849, free_ts 71393667615
 prep_new_page mm/page_alloc.c:2436 [inline]
 get_page_from_freelist+0xa72/0x2f80 mm/page_alloc.c:4168
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5390
 alloc_pages+0x18c/0x2a0 mm/mempolicy.c:2244
 kmalloc_order+0x34/0xf0 mm/slab_common.c:955
 kmalloc_order_trace+0x14/0x120 mm/slab_common.c:971
 kmalloc_large include/linux/slab.h:520 [inline]
 kmalloc include/linux/slab.h:584 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 em28xx_usb_probe+0x1f7/0xd00 drivers/media/usb/em28xx/em28xx-cards.c:3855
 usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
 call_driver_probe drivers/base/dd.c:517 [inline]
 really_probe+0x23c/0xcd0 drivers/base/dd.c:595
 __driver_probe_device+0x338/0x4d0 drivers/base/dd.c:747
 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:777
 __device_attach_driver+0x20b/0x2f0 drivers/base/dd.c:894
 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:427
 __device_attach+0x228/0x4a0 drivers/base/dd.c:965
 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:487
 device_add+0xc2f/0x2180 drivers/base/core.c:3355
 usb_set_configuration+0x113f/0x1910 drivers/usb/core/message.c:2170
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1346 [inline]
 free_pcp_prepare+0x2c5/0x780 mm/page_alloc.c:1397
 free_unref_page_prepare mm/page_alloc.c:3332 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3411
 __refcount_sub_and_test include/linux/refcount.h:282 [inline]
 __refcount_dec_and_test include/linux/refcount.h:315 [inline]
 refcount_dec_and_test include/linux/refcount.h:333 [inline]
 kref_put.constprop.0.isra.0+0x3d/0x7e include/linux/kref.h:64
 em28xx_ir_fini.cold+0x7c/0x120 drivers/media/usb/em28xx/em28xx-input.c:875
 em28xx_close_extension+0xc9/0x2a0 drivers/media/usb/em28xx/em28xx-core.c:1143
 em28xx_usb_disconnect.cold+0x14b/0x237 drivers/media/usb/em28xx/em28xx-cards.c:4140
 usb_unbind_interface+0x1d8/0x8d0 drivers/usb/core/driver.c:458
 __device_release_driver+0x3bd/0x6f0 drivers/base/dd.c:1201
 device_release_driver_internal drivers/base/dd.c:1232 [inline]
 device_release_driver+0x26/0x40 drivers/base/dd.c:1255
 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:529
 device_del+0x502/0xd40 drivers/base/core.c:3543
 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1419
 usb_disconnect.cold+0x27a/0x78e drivers/usb/core/hub.c:2225
 hub_port_connect drivers/usb/core/hub.c:5199 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5488 [inline]
 port_event drivers/usb/core/hub.c:5634 [inline]
 hub_event+0x1c9c/0x4330 drivers/usb/core/hub.c:5716
 process_one_work+0x98d/0x1630 kernel/workqueue.c:2276
 process_scheduled_works kernel/workqueue.c:2338 [inline]
 worker_thread+0x85c/0x11f0 kernel/workqueue.c:2424

Memory state around the buggy address:
 ffff88802a160100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88802a160180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88802a160200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                    ^
 ffff88802a160280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88802a160300: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (20):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2021/08/21 10:15 upstream fa54d366a6e4 b599f2fc .config log report syz C KASAN: use-after-free Read in em28xx_close_extension
ci-upstream-kasan-gce-selinux-root 2021/07/28 07:45 upstream 7d549995d4e0 17d6ab15 .config log report syz C KASAN: use-after-free Read in em28xx_close_extension
ci-upstream-kasan-gce 2021/07/10 15:05 upstream 3dbdb38e2869 8f5a7b8c .config log report syz C KASAN: use-after-free Read in em28xx_close_extension
ci-upstream-kasan-gce 2021/07/10 14:22 upstream 3dbdb38e2869 8f5a7b8c .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2022/02/01 08:08 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 554237f2bb62 6b7c57fe .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2022/01/24 11:08 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing e783362eb54c 214351e1 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2022/01/09 05:38 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing cbb4f5f43599 2ca0d385 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/12/20 11:29 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 236c9ad1f870 021b36cb .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/12/20 06:55 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing f2b42379c576 44068e19 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/11/28 06:51 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing c4bc515d73b5 63eeac02 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/11/28 01:56 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing c4bc515d73b5 63eeac02 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/11/23 00:23 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 4616dddcfaf7 545ab074 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/11/12 11:43 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 5833291ab6de 75b04091 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/08/31 11:58 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 9c1587d99f93 8f58a0ef .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/08/28 16:40 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 9c1587d99f93 d5a29e53 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/08/05 02:11 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 64cd4271ea8e b97d64c9 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/07/26 04:32 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 8e6cb5d27e82 4d1b57d4 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/07/24 03:06 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 8e6cb5d27e82 bc5f1d88 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/07/19 13:11 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 97db1b081e12 e6a17580 .config log report info KASAN: use-after-free Read in em28xx_close_extension
ci2-upstream-usb 2021/07/13 20:16 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing 97db1b081e12 70168d5c .config log report info KASAN: use-after-free Read in em28xx_close_extension