syzbot


KASAN: use-after-free Read in posix_lock_inode

Status: fixed on 2019/01/15 20:25
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+239d99847eb49ecb3899@syzkaller.appspotmail.com
Fix commit: bf77ae4c98d7 locks: fix error in locks_move_blocks()
First crash: 2102d, last: 2102d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in posix_lock_inode 8 (9) 2019/01/03 01:59
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-49 KASAN: use-after-free Read in posix_lock_inode syz 2 2048d 2000d 0/3 public: reported syz repro on 2019/04/14 09:28

Sample crash report:
8021q: adding VLAN 0 to HW filter on device batadv0
==================================================================
BUG: KASAN: use-after-free in what_owner_is_waiting_for fs/locks.c:1000 [inline]
BUG: KASAN: use-after-free in posix_locks_deadlock fs/locks.c:1023 [inline]
BUG: KASAN: use-after-free in posix_lock_inode+0x1f9e/0x2750 fs/locks.c:1163
Read of size 8 at addr ffff88808eb46a40 by task syz-executor2/18627

CPU: 0 PID: 18627 Comm: syz-executor2 Not tainted 4.20.0+ #4
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+0x1db/0x2d0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
 what_owner_is_waiting_for fs/locks.c:1000 [inline]
 posix_locks_deadlock fs/locks.c:1023 [inline]
 posix_lock_inode+0x1f9e/0x2750 fs/locks.c:1163
 posix_lock_file fs/locks.c:1346 [inline]
 vfs_lock_file fs/locks.c:2314 [inline]
 vfs_lock_file+0xc7/0xf0 fs/locks.c:2309
 do_lock_file_wait.part.0+0xe5/0x260 fs/locks.c:2328
 do_lock_file_wait fs/locks.c:2324 [inline]
 fcntl_setlk+0x2f1/0xfe0 fs/locks.c:2413
 do_fcntl+0x843/0x12b0 fs/fcntl.c:370
 __do_sys_fcntl fs/fcntl.c:463 [inline]
 __se_sys_fcntl fs/fcntl.c:448 [inline]
 __x64_sys_fcntl+0x16d/0x1e0 fs/fcntl.c:448
 do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457ec9
Code: 6d b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 3b b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f3dab917c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000048
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000457ec9
RDX: 0000000020000140 RSI: 0000000000000007 RDI: 0000000000000003
RBP: 000000000073bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f3dab9186d4
R13: 00000000004be5f0 R14: 00000000004ceab0 R15: 00000000ffffffff

Allocated by task 18627:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 kasan_kmalloc mm/kasan/common.c:482 [inline]
 kasan_kmalloc+0xcf/0xe0 mm/kasan/common.c:455
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:397
 kmem_cache_alloc+0x12d/0x710 mm/slab.c:3541
 kmem_cache_zalloc include/linux/slab.h:730 [inline]
 locks_alloc_lock+0x8e/0x2f0 fs/locks.c:344
 fcntl_setlk+0xa9/0xfe0 fs/locks.c:2362
 do_fcntl+0x843/0x12b0 fs/fcntl.c:370
 __do_sys_fcntl fs/fcntl.c:463 [inline]
 __se_sys_fcntl fs/fcntl.c:448 [inline]
 __x64_sys_fcntl+0x16d/0x1e0 fs/fcntl.c:448
 do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 18627:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:444
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:452
 __cache_free mm/slab.c:3485 [inline]
 kmem_cache_free+0x86/0x260 mm/slab.c:3747
 locks_free_lock+0x27a/0x3f0 fs/locks.c:381
 fcntl_setlk+0x7b5/0xfe0 fs/locks.c:2439
 do_fcntl+0x843/0x12b0 fs/fcntl.c:370
 __do_sys_fcntl fs/fcntl.c:463 [inline]
 __se_sys_fcntl fs/fcntl.c:448 [inline]
 __x64_sys_fcntl+0x16d/0x1e0 fs/fcntl.c:448
 do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88808eb46a40
 which belongs to the cache file_lock_cache of size 264
The buggy address is located 0 bytes inside of
 264-byte region [ffff88808eb46a40, ffff88808eb46b48)
The buggy address belongs to the page:
page:ffffea00023ad180 count:1 mapcount:0 mapping:ffff88821bc48c80 index:0xffff88808eb46cd0
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea00022b2308 ffffea000297a788 ffff88821bc48c80
raw: ffff88808eb46cd0 ffff88808eb46000 000000010000000a 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88808eb46900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808eb46980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88808eb46a00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                           ^
 ffff88808eb46a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808eb46b00: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/01/02 04:01 upstream 28e8c4bc8eb4 3d85f48c .config console log report syz ci-upstream-kasan-gce-smack-root
2019/01/01 21:41 upstream e1ef035d272e 3d85f48c .config console log report syz ci-upstream-kasan-gce
2019/01/01 22:07 upstream e1ef035d272e 3d85f48c .config console log report syz ci-upstream-kasan-gce-386
2019/01/02 10:07 linux-next 4cd1b60def51 3d85f48c .config console log report syz ci-upstream-linux-next-kasan-gce-root
2019/01/01 20:46 upstream e1ef035d272e 3d85f48c .config console log report ci-upstream-kasan-gce
* Struck through repros no longer work on HEAD.