syzbot


KASAN: use-after-free Read in seq_release_private

Status: fixed on 2020/10/08 10:22
Reported-by: syzbot+2bb88e2b557beda336da@syzkaller.appspotmail.com
Fix commit: 37d933e8b41b fix regression in "epoll: Keep a reference on files added to the check list"
First crash: 1324d, last: 1324d
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"

  
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in seq_release_private syz done 1 1325d 1325d 1/1 fixed on 2020/10/08 10:30

Sample crash report:
Bluetooth: hci0: command 0x041b tx timeout
Bluetooth: hci0: command 0x040f tx timeout
Bluetooth: hci0: command 0x0419 tx timeout
==================================================================
BUG: KASAN: use-after-free in seq_release_private+0x117/0x120 fs/seq_file.c:606
Read of size 8 at addr ffff88809e9321f8 by task syz-executor.0/9416

CPU: 0 PID: 9416 Comm: syz-executor.0 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
 seq_release_private+0x117/0x120 fs/seq_file.c:606
 __fput+0x2ce/0x890 fs/file_table.c:278
 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:0x45d5b9
Code: 5d b4 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 2b b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f0c9e4a6c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000e9
RAX: 0000000000000000 RBX: 0000000000002ac0 RCX: 000000000045d5b9
RDX: 0000000000000005 RSI: 0000000000000001 RDI: 0000000000000006
RBP: 000000000118cf88 R08: 0000000000000000 R09: 0000000000000000
R10: 000000002050aff4 R11: 0000000000000246 R12: 000000000118cf4c
R13: 00007ffc8ebcf2cf R14: 00007f0c9e4a79c0 R15: 000000000118cf4c

Allocated by task 9416:
 kmem_cache_alloc+0x122/0x370 mm/slab.c:3559
 kmem_cache_zalloc include/linux/slab.h:699 [inline]
 seq_open+0x57/0x1a0 fs/seq_file.c:57
 __seq_open_private+0x37/0xd0 fs/seq_file.c:623
 seq_open_private+0x21/0x40 fs/seq_file.c:641
 mounts_open_common+0x21e/0x520 fs/proc_namespace.c:271
 do_dentry_open+0x4aa/0x1160 fs/open.c:796
 do_last fs/namei.c:3421 [inline]
 path_openat+0x793/0x2df0 fs/namei.c:3537
 do_filp_open+0x18c/0x3f0 fs/namei.c:3567
 do_sys_open+0x3b3/0x520 fs/open.c:1085
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9415:
 __cache_free mm/slab.c:3503 [inline]
 kmem_cache_free+0x7f/0x260 mm/slab.c:3765
 seq_release fs/seq_file.c:360 [inline]
 seq_release_private+0xd8/0x120 fs/seq_file.c:608
 __fput+0x2ce/0x890 fs/file_table.c:278
 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 ffff88809e932120
 which belongs to the cache seq_file of size 224
The buggy address is located 216 bytes inside of
 224-byte region [ffff88809e932120, ffff88809e932200)
The buggy address belongs to the page:
page:ffffea00027a4c80 count:1 mapcount:0 mapping:ffff8880aa00a6c0 index:0xffff88809e932000
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea00027cac88 ffffea00027abe08 ffff8880aa00a6c0
raw: ffff88809e932000 ffff88809e932000 0000000100000008 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809e932080: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88809e932100: fc fc fc fc fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809e932180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff88809e932200: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff88809e932280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/09/08 00:33 linux-4.19.y c37da90efff5 abf9ba4f .config console log report syz ci2-linux-4-19
* Struck through repros no longer work on HEAD.