syzbot


KASAN: use-after-free Read in locks_remove_file

Status: fixed on 2020/10/04 08:47
Reported-by: syzbot+c584305f4382b089f77d@syzkaller.appspotmail.com
Fix commit: 37d933e8b41b fix regression in "epoll: Keep a reference on files added to the check list"
First crash: 1547d, last: 1539d
Fix bisection: fixed by (bisect log) :
commit 37d933e8b41b83bb8278815e366aec5a542b7e31
Author: Al Viro <viro@zeniv.linux.org.uk>
Date: Wed Sep 2 15:30:48 2020 +0000

  fix regression in "epoll: Keep a reference on files added to the check list"

  

Sample crash report:
Bluetooth: hci2: command 0x0419 tx timeout
Bluetooth: hci4: command 0x0419 tx timeout
Bluetooth: hci3: command 0x0419 tx timeout
Bluetooth: hci5: command 0x0419 tx timeout
==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:193 [inline]
BUG: KASAN: use-after-free in locks_remove_file+0x40b/0x450 fs/locks.c:2552
Read of size 8 at addr ffff888076350b30 by task syz-executor.1/8358

CPU: 1 PID: 8358 Comm: syz-executor.1 Not tainted 4.19.143-syzkaller #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+0x1fc/0x2fe lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1c7 mm/kasan/report.c:354
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
 __read_once_size include/linux/compiler.h:193 [inline]
 locks_remove_file+0x40b/0x450 fs/locks.c:2552
 __fput+0x220/0x890 fs/file_table.c:270
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
 do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x416f01
Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
RSP: 002b:00007ffe519f2b90 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000005 RCX: 0000000000416f01
RDX: 0000000000000000 RSI: 0000000000000081 RDI: 0000000000000004
RBP: 0000000000000000 R08: 0000000001190390 R09: 0000000000000000
R10: 00007ffe519f2c70 R11: 0000000000000293 R12: 0000000001190398
R13: 0000000000000000 R14: ffffffffffffffff R15: 000000000118cf4c

Allocated by task 8362:
 kmem_cache_alloc+0x122/0x370 mm/slab.c:3559
 sock_alloc_inode+0x19/0x250 net/socket.c:244
 alloc_inode+0x5d/0x180 fs/inode.c:211
 new_inode_pseudo+0x14/0xe0 fs/inode.c:911
 sock_alloc+0x3c/0x260 net/socket.c:547
 __sock_create+0xba/0x740 net/socket.c:1240
 sock_create net/socket.c:1316 [inline]
 __sys_socketpair+0x242/0x570 net/socket.c:1408
 __do_sys_socketpair net/socket.c:1457 [inline]
 __se_sys_socketpair net/socket.c:1454 [inline]
 __x64_sys_socketpair+0x93/0xf0 net/socket.c:1454
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8362:
 __cache_free mm/slab.c:3503 [inline]
 kmem_cache_free+0x7f/0x260 mm/slab.c:3765
 destroy_inode+0xb9/0x110 fs/inode.c:268
 iput_final fs/inode.c:1555 [inline]
 iput+0x4f1/0x860 fs/inode.c:1581
 dentry_unlink_inode+0x265/0x320 fs/dcache.c:374
 __dentry_kill+0x3c0/0x640 fs/dcache.c:566
 dentry_kill+0xc4/0x510 fs/dcache.c:685
 dput+0x55f/0x640 fs/dcache.c:846
 __fput+0x415/0x890 fs/file_table.c:291
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
 do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888076350900
 which belongs to the cache sock_inode_cache of size 992
The buggy address is located 560 bytes inside of
 992-byte region [ffff888076350900, ffff888076350ce0)
The buggy address belongs to the page:
page:ffffea0001d8d400 count:1 mapcount:0 mapping:ffff88821b718000 index:0xffff888076350ffd
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea0001d8e408 ffffea0001d8e488 ffff88821b718000
raw: ffff888076350ffd ffff888076350000 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888076350a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888076350a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888076350b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff888076350b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888076350c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/09/04 05:11 linux-4.19.y c37da90efff5 abf9ba4f .config console log report syz ci2-linux-4-19
2020/08/30 08:45 linux-4.19.y f6d5cb9e2c06 d5a3ae1f .config console log report syz ci2-linux-4-19
2020/08/27 01:57 linux-4.19.y f6d5cb9e2c06 318430cb .config console log report syz ci2-linux-4-19
2020/08/30 08:24 linux-4.19.y f6d5cb9e2c06 d5a3ae1f .config console log report ci2-linux-4-19
* Struck through repros no longer work on HEAD.