syzbot


KASAN: use-after-free Read in locks_delete_block

Status: fixed on 2021/10/12 13:38
Reported-by: syzbot+df3080e48a69330f7ae3@syzkaller.appspotmail.com
Fix commit: 384e15fc4226 locks: fix a potential use-after-free problem when wakeup a waiter
First crash: 1777d, last: 1724d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in locks_delete_block fs syz 4 2179d 2202d 11/28 fixed on 2019/01/15 20:25

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __wake_up_common+0x6c/0x450 kernel/sched/wait.c:81
Read of size 8 at addr ffff8881d42e1180 by task syz-executor332/22865

CPU: 0 PID: 22865 Comm: syz-executor332 Not tainted 5.4.10-syzkaller-00217-gf5f770e495ba #0
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+0x1b0/0x228 lib/dump_stack.c:118
 print_address_description+0x96/0x5d0 mm/kasan/report.c:374
 __kasan_report+0x14b/0x1c0 mm/kasan/report.c:506
 kasan_report+0x26/0x50 mm/kasan/common.c:634
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
 __wake_up_common+0x6c/0x450 kernel/sched/wait.c:81
 __wake_up_common_lock kernel/sched/wait.c:123 [inline]
 __wake_up+0x145/0x210 kernel/sched/wait.c:142
 __locks_wake_up_blocks fs/locks.c:742 [inline]
 locks_delete_block+0x30d/0x560 fs/locks.c:773
 locks_lock_inode_wait+0x364/0x3f0 fs/locks.c:2140
 locks_lock_file_wait include/linux/fs.h:1328 [inline]
 __do_sys_flock fs/locks.c:2225 [inline]
 __se_sys_flock+0x45b/0x560 fs/locks.c:2188
 __x64_sys_flock+0x5b/0x70 fs/locks.c:2188
 do_syscall_64+0xc0/0x100 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x446e49
Code: e8 dc e6 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 2b 06 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fa0afdf8db8 EFLAGS: 00000246 ORIG_RAX: 0000000000000049
RAX: ffffffffffffffda RBX: 00000000006dcc48 RCX: 0000000000446e49
RDX: 0000000000446e49 RSI: 0000000000000001 RDI: 0000000000000003
RBP: 00000000006dcc40 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dcc4c
R13: 00007fffbbd8081f R14: 00007fa0afdf99c0 R15: 20c49ba5e353f7cf

Allocated by task 22870:
 save_stack mm/kasan/common.c:69 [inline]
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc+0x117/0x1b0 mm/kasan/common.c:510
 kasan_slab_alloc+0xe/0x10 mm/kasan/common.c:518
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc_node mm/slub.c:2758 [inline]
 slab_alloc mm/slub.c:2766 [inline]
 kmem_cache_alloc+0x120/0x2b0 mm/slub.c:2771
 kmem_cache_zalloc include/linux/slab.h:680 [inline]
 locks_alloc_lock fs/locks.c:346 [inline]
 flock_make_lock fs/locks.c:487 [inline]
 __do_sys_flock fs/locks.c:2207 [inline]
 __se_sys_flock+0x156/0x560 fs/locks.c:2188
 __x64_sys_flock+0x5b/0x70 fs/locks.c:2188
 do_syscall_64+0xc0/0x100 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 22870:
 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+0x168/0x220 mm/kasan/common.c:471
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:480
 slab_free_hook mm/slub.c:1424 [inline]
 slab_free_freelist_hook mm/slub.c:1457 [inline]
 slab_free mm/slub.c:3004 [inline]
 kmem_cache_free+0x181/0x7a0 mm/slub.c:3020
 locks_free_lock fs/locks.c:383 [inline]
 __do_sys_flock fs/locks.c:2228 [inline]
 __se_sys_flock+0x478/0x560 fs/locks.c:2188
 __x64_sys_flock+0x5b/0x70 fs/locks.c:2188
 do_syscall_64+0xc0/0x100 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff8881d42e1118
 which belongs to the cache file_lock_cache of size 216
The buggy address is located 104 bytes inside of
 216-byte region [ffff8881d42e1118, ffff8881d42e11f0)
The buggy address belongs to the page:
page:ffffea000750b840 refcount:1 mapcount:0 mapping:ffff8881da8eca00 index:0x0
raw: 8000000000000200 0000000000000000 0000000c00000001 ffff8881da8eca00
raw: 0000000000000000 00000000000e000e 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881d42e1080: fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc
 ffff8881d42e1100: fc fc fc fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881d42e1180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
                   ^
 ffff8881d42e1200: fc fc fc fc fc fc fb fb fb fb fb fb fb fb fb fb
 ffff8881d42e1280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/01/11 12:43 https://android.googlesource.com/kernel/common android-5.4 f5f770e495ba 4c04afaa .config console log report syz C ci2-android-5-4-kasan
2020/03/04 21:38 https://android.googlesource.com/kernel/common android-5.4 04f7ce5d3dca 712198ac .config console log report ci2-android-5-4-kasan
2020/01/28 16:43 https://android.googlesource.com/kernel/common android-5.4 b2b96d09ef40 c8e81ce4 .config console log report ci2-android-5-4-kasan
* Struck through repros no longer work on HEAD.