syzbot


KASAN: use-after-free Read in posix_lock_inode

Status: public: reported syz repro on 2019/04/14 09:28
Reported-by: syzbot+53af0cb9ed2481452616@syzkaller.appspotmail.com
First crash: 2096d, last: 2096d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in posix_lock_inode fs syz 5 2150d 2150d 11/28 fixed on 2019/01/15 20:25

Sample crash report:
audit: type=1400 audit(1551089092.023:5): avc:  denied  { associate } for  pid=2066 comm="syz-executor.0" name="syz0" scontext=unconfined_u:object_r:unlabeled_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=filesystem permissive=1
==================================================================
BUG: KASAN: use-after-free in perf_trace_filelock_lock+0x901/0x960 include/trace/events/filelock.h:61
Read of size 8 at addr ffff8801d8321a00 by task syz-executor.0/2934

CPU: 0 PID: 2934 Comm: syz-executor.0 Not tainted 4.9.155+ #27
 ffff8801d71a7968 ffffffff81b47871 0000000000000000 ffffea000760c840
 ffff8801d8321a00 0000000000000008 ffffffff81606c21 ffff8801d71a79a0
 ffffffff81502825 0000000000000000 ffff8801d8321a00 ffff8801d8321a00
Call Trace:
 [<ffffffff81b47871>] __dump_stack lib/dump_stack.c:15 [inline]
 [<ffffffff81b47871>] dump_stack+0xc1/0x120 lib/dump_stack.c:51
 [<ffffffff81502825>] print_address_description+0x6f/0x238 mm/kasan/report.c:256
 [<ffffffff81502a7a>] kasan_report_error mm/kasan/report.c:355 [inline]
 [<ffffffff81502a7a>] kasan_report mm/kasan/report.c:412 [inline]
 [<ffffffff81502a7a>] kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:397
 [<ffffffff814f4c74>] __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 [<ffffffff81606c21>] perf_trace_filelock_lock+0x901/0x960 include/trace/events/filelock.h:61
 [<ffffffff81610281>] trace_posix_lock_inode include/trace/events/filelock.h:102 [inline]
 [<ffffffff81610281>] posix_lock_inode+0x1161/0x1aa0 fs/locks.c:1197
 [<ffffffff816112cf>] posix_lock_file fs/locks.c:1219 [inline]
 [<ffffffff816112cf>] vfs_lock_file fs/locks.c:2173 [inline]
 [<ffffffff816112cf>] vfs_lock_file+0x14f/0x1a0 fs/locks.c:2168
 [<ffffffff81611f24>] do_lock_file_wait.part.0+0xb4/0x1e0 fs/locks.c:2187
 [<ffffffff8161642b>] do_lock_file_wait fs/locks.c:2183 [inline]
 [<ffffffff8161642b>] fcntl_setlk+0x2cb/0xc30 fs/locks.c:2284
 [<ffffffff815470c9>] do_fcntl fs/fcntl.c:288 [inline]
 [<ffffffff815470c9>] SYSC_fcntl fs/fcntl.c:376 [inline]
 [<ffffffff815470c9>] SyS_fcntl+0x579/0xb50 fs/fcntl.c:361
 [<ffffffff810056bd>] do_syscall_64+0x1ad/0x570 arch/x86/entry/common.c:285
 [<ffffffff82816a93>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Allocated by task 2934:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack mm/kasan/kasan.c:505 [inline]
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_kmalloc.part.0+0x62/0xf0 mm/kasan/kasan.c:609
 kasan_kmalloc+0xb7/0xd0 mm/kasan/kasan.c:594
 kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:547
 slab_post_alloc_hook mm/slab.h:417 [inline]
 slab_alloc_node mm/slub.c:2715 [inline]
 slab_alloc mm/slub.c:2723 [inline]
 kmem_cache_alloc+0xd5/0x2b0 mm/slub.c:2728
 kmem_cache_zalloc include/linux/slab.h:626 [inline]
 locks_alloc_lock+0x1d/0x170 fs/locks.c:295
 posix_lock_inode+0x48c/0x1aa0 fs/locks.c:1012
 posix_lock_file fs/locks.c:1219 [inline]
 vfs_lock_file fs/locks.c:2173 [inline]
 vfs_lock_file+0x14f/0x1a0 fs/locks.c:2168
 do_lock_file_wait.part.0+0xb4/0x1e0 fs/locks.c:2187
 do_lock_file_wait fs/locks.c:2183 [inline]
 fcntl_setlk+0x2cb/0xc30 fs/locks.c:2284
 do_fcntl fs/fcntl.c:288 [inline]
 SYSC_fcntl fs/fcntl.c:376 [inline]
 SyS_fcntl+0x579/0xb50 fs/fcntl.c:361
 do_syscall_64+0x1ad/0x570 arch/x86/entry/common.c:285
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 2933:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack mm/kasan/kasan.c:505 [inline]
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_slab_free+0xb0/0x190 mm/kasan/kasan.c:582
 slab_free_hook mm/slub.c:1355 [inline]
 slab_free_freelist_hook mm/slub.c:1377 [inline]
 slab_free mm/slub.c:2958 [inline]
 kmem_cache_free+0xbe/0x310 mm/slub.c:2980
 locks_free_lock+0xea/0x140 fs/locks.c:331
 locks_dispose_list+0x117/0x1e0 fs/locks.c:343
 posix_lock_inode+0x369/0x1aa0 fs/locks.c:1196
 posix_lock_file fs/locks.c:1219 [inline]
 vfs_lock_file fs/locks.c:2173 [inline]
 vfs_lock_file+0x14f/0x1a0 fs/locks.c:2168
 locks_remove_posix+0x1e4/0x500 fs/locks.c:2490
 filp_close+0xf4/0x140 fs/open.c:1133
 __close_fd+0x15d/0x240 fs/file.c:651
 SYSC_close fs/open.c:1148 [inline]
 SyS_close+0x46/0xa0 fs/open.c:1146
 do_syscall_64+0x1ad/0x570 arch/x86/entry/common.c:285
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

The buggy address belongs to the object at ffff8801d8321a00
 which belongs to the cache file_lock_cache of size 256
The buggy address is located 0 bytes inside of
 256-byte region [ffff8801d8321a00, ffff8801d8321b00)
The buggy address belongs to the page:
page:ffffea000760c840 count:1 mapcount:0 mapping:          (null) index:0x0
flags: 0x4000000000000080(slab)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d8321900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8321980: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8801d8321a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8801d8321a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8321b00: fc fc fc fc fc fc fc fc 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
2019/02/25 10:08 https://android.googlesource.com/kernel/common android-4.9 1597fdfe52ba a70141bf .config console log report syz ci-android-49-kasan-gce-root
2019/02/25 09:32 https://android.googlesource.com/kernel/common android-4.9 1597fdfe52ba a70141bf .config console log report ci-android-49-kasan-gce-root
* Struck through repros no longer work on HEAD.