syzbot


KASAN: slab-out-of-bounds Read in do_wait_for_common

Status: fixed on 2021/11/10 00:50
Reported-by: syzbot+cc699626e48a6ebaf295@syzkaller.appspotmail.com
Fix commit: e9e6aa51b273 staging: rtl8712: error handling refactoring
First crash: 396d, last: 373d

Cause bisection: failed (bisect log)
Patch testing requests:
Created Duration User Patch Repo Result
2021/07/21 09:57 20m paskripkin@gmail.com patch upstream OK
2021/07/20 19:14 21m paskripkin@gmail.com patch upstream report log
2021/07/20 11:10 32m paskripkin@gmail.com patch upstream report log

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in debug_spin_lock_before kernel/locking/spinlock_debug.c:83 [inline]
BUG: KASAN: slab-out-of-bounds in do_raw_spin_lock+0x4f5/0x8e0 kernel/locking/spinlock_debug.c:112
Read of size 4 at addr ffff88802b46ce14 by task kworker/0:6/8471

CPU: 0 PID: 8471 Comm: kworker/0:6 Tainted: G        W         5.14.0-rc1-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+0x1ae/0x29f lib/dump_stack.c:105
 print_address_description+0x66/0x3b0 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report+0x163/0x210 mm/kasan/report.c:436
 debug_spin_lock_before kernel/locking/spinlock_debug.c:83 [inline]
 do_raw_spin_lock+0x4f5/0x8e0 kernel/locking/spinlock_debug.c:112
 __raw_spin_lock_irq include/linux/spinlock_api_smp.h:129 [inline]
 _raw_spin_lock_irq+0xba/0xf0 kernel/locking/spinlock.c:167
 do_wait_for_common+0x2e5/0x480 kernel/sched/completion.c:86
 __wait_for_common kernel/sched/completion.c:106 [inline]
 wait_for_common kernel/sched/completion.c:117 [inline]
 wait_for_completion+0x48/0x60 kernel/sched/completion.c:138
 r871xu_dev_remove+0x83/0x460 drivers/staging/rtl8712/usb_intf.c:599
 usb_unbind_interface+0x1f2/0x860 drivers/usb/core/driver.c:458
 __device_release_driver drivers/base/dd.c:1201 [inline]
 device_release_driver_internal+0x51e/0x7b0 drivers/base/dd.c:1232
 bus_remove_device+0x2fd/0x410 drivers/base/bus.c:529
 device_del+0x6e1/0xc10 drivers/base/core.c:3540
 usb_disable_device+0x407/0x800 drivers/usb/core/message.c:1419
 usb_disconnect+0x33a/0x8a0 drivers/usb/core/hub.c:2221
 hub_port_connect+0x297/0x27a0 drivers/usb/core/hub.c:5151
 hub_port_connect_change+0x5d0/0xbf0 drivers/usb/core/hub.c:5440
 port_event+0xaee/0x1140 drivers/usb/core/hub.c:5586
 hub_event+0x48d/0xd80 drivers/usb/core/hub.c:5668
 process_one_work+0x833/0x10c0 kernel/workqueue.c:2276
 worker_thread+0xac1/0x1320 kernel/workqueue.c:2422
 kthread+0x453/0x480 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Allocated by task 10:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x96/0xd0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:253 [inline]
 slab_post_alloc_hook mm/slab.h:512 [inline]
 slab_alloc_node mm/slub.c:2981 [inline]
 kmem_cache_alloc_node+0x200/0x370 mm/slub.c:3017
 alloc_task_struct_node kernel/fork.c:171 [inline]
 dup_task_struct+0x52/0x980 kernel/fork.c:871
 copy_process+0x615/0x5b00 kernel/fork.c:1952
 kernel_clone+0x21a/0x7d0 kernel/fork.c:2509
 kernel_thread+0x146/0x1c0 kernel/fork.c:2561
 call_usermodehelper_exec_work+0x57/0x220 kernel/umh.c:174
 process_one_work+0x833/0x10c0 kernel/workqueue.c:2276
 worker_thread+0xac1/0x1320 kernel/workqueue.c:2422
 kthread+0x453/0x480 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Last potentially related work creation:
 kasan_save_stack+0x27/0x50 mm/kasan/common.c:38
 kasan_record_aux_stack+0xee/0x120 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:3029 [inline]
 call_rcu+0x1a0/0xa20 kernel/rcu/tree.c:3109
 schedule_tail+0xc/0xb0 kernel/sched/core.c:4619
 ret_from_fork+0x8/0x30 arch/x86/entry/entry_64.S:280

The buggy address belongs to the object at ffff88802b46b880
 which belongs to the cache task_struct of size 6976
The buggy address is located 5524 bytes inside of
 6976-byte region [ffff88802b46b880, ffff88802b46d3c0)
The buggy address belongs to the page:
page:ffffea0000ad1a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2b468
head:ffffea0000ad1a00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888140006280
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 10, ts 43802781641, free_ts 43793596145
 prep_new_page mm/page_alloc.c:2433 [inline]
 get_page_from_freelist+0x779/0xa30 mm/page_alloc.c:4166
 __alloc_pages+0x26c/0x5f0 mm/page_alloc.c:5374
 alloc_slab_page mm/slub.c:1713 [inline]
 allocate_slab+0xf1/0x540 mm/slub.c:1853
 new_slab mm/slub.c:1916 [inline]
 new_slab_objects mm/slub.c:2662 [inline]
 ___slab_alloc+0x1cf/0x350 mm/slub.c:2825
 __slab_alloc mm/slub.c:2865 [inline]
 slab_alloc_node mm/slub.c:2947 [inline]
 kmem_cache_alloc_node+0x2ca/0x370 mm/slub.c:3017
 alloc_task_struct_node kernel/fork.c:171 [inline]
 dup_task_struct+0x52/0x980 kernel/fork.c:871
 copy_process+0x615/0x5b00 kernel/fork.c:1952
 kernel_clone+0x21a/0x7d0 kernel/fork.c:2509
 kernel_thread+0x146/0x1c0 kernel/fork.c:2561
 call_usermodehelper_exec_work+0x57/0x220 kernel/umh.c:174
 process_one_work+0x833/0x10c0 kernel/workqueue.c:2276
 worker_thread+0xac1/0x1320 kernel/workqueue.c:2422
 kthread+0x453/0x480 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1343 [inline]
 free_pcp_prepare+0xc29/0xd20 mm/page_alloc.c:1394
 free_unref_page_prepare mm/page_alloc.c:3329 [inline]
 free_unref_page+0x7e/0x550 mm/page_alloc.c:3408
 kfree+0x287/0x2d0 mm/slub.c:4292
 request_firmware_work_func+0x175/0x250 drivers/base/firmware_loader/main.c:1081
 process_one_work+0x833/0x10c0 kernel/workqueue.c:2276
 worker_thread+0xac1/0x1320 kernel/workqueue.c:2422
 kthread+0x453/0x480 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff88802b46cd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88802b46cd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88802b46ce00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                         ^
 ffff88802b46ce80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88802b46cf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (5):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-smack-root 2021/07/15 13:32 upstream 8096acd7442e b9a2f64e .config log report syz C KASAN: slab-out-of-bounds Read in do_wait_for_common
ci-upstream-kasan-gce-smack-root 2021/08/08 00:31 upstream c9194f32bfd9 6972b106 .config log report info KASAN: use-after-free Read in do_wait_for_common
ci-upstream-kasan-gce-smack-root 2021/07/30 06:00 upstream 7e96bf476270 c585c7b0 .config log report info KASAN: use-after-free Read in do_wait_for_common
ci-upstream-kasan-gce-smack-root 2021/07/29 23:29 upstream 7e96bf476270 b44001ce .config log report info KASAN: use-after-free Read in do_wait_for_common
ci-upstream-kasan-gce-smack-root 2021/07/16 07:40 upstream dd9c7df94c1b f115ae98 .config log report info KASAN: use-after-free Read in do_wait_for_common