syzbot


KASAN: use-after-free Read in seq_release_private

Status: fixed on 2020/10/08 10:30
Reported-by: syzbot+f0f4280cb99f67d65a73@syzkaller.appspotmail.com
Fix commit: c5c6e00f6cc5 fix regression in "epoll: Keep a reference on files added to the check list"
First crash: 1536d, last: 1536d
Fix bisection: fixed by (bisect log) :
commit c5c6e00f6cc5d3ed0d6464b14e33f2f5c8505888
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.19 KASAN: use-after-free Read in seq_release_private syz done 1 1535d 1535d 1/1 fixed on 2020/10/08 10:22

Sample crash report:
batman_adv: batadv0: Interface activated: batadv_slave_1
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_to_batadv: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
Bluetooth: hci0 command 0x0409 tx timeout
==================================================================
BUG: KASAN: use-after-free in seq_release_private+0x10c/0x120 fs/seq_file.c:615
Read of size 8 at addr ffff8880a0101798 by task syz-executor.0/7153

CPU: 0 PID: 7153 Comm: syz-executor.0 Not tainted 4.14.196-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x283 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
 kasan_report_error.cold+0x8a/0x194 mm/kasan/report.c:351
 kasan_report mm/kasan/report.c:409 [inline]
 __asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
 seq_release_private+0x10c/0x120 fs/seq_file.c:615
 __fput+0x25f/0x7a0 fs/file_table.c:210
 task_work_run+0x11f/0x190 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
 do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x416f01
RSP: 002b:00007ffd05b98a50 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000004 RCX: 0000000000416f01
RDX: 00000000000f4240 RSI: 0000000000000081 RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000001190760 R09: 0000000000000000
R10: 00007ffd05b98b30 R11: 0000000000000293 R12: 0000000001190768
R13: 0000000000000000 R14: ffffffffffffffff R15: 000000000118cf4c

Allocated by task 7154:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 seq_open+0x7b/0x1f0 fs/seq_file.c:54
 __seq_open_private+0x37/0xc0 fs/seq_file.c:632
 seq_open_private+0x21/0x40 fs/seq_file.c:650
 mounts_open_common+0x1d8/0x470 fs/proc_namespace.c:271
 do_dentry_open+0x44b/0xec0 fs/open.c:777
 vfs_open+0x105/0x220 fs/open.c:888
 do_last fs/namei.c:3428 [inline]
 path_openat+0x628/0x2970 fs/namei.c:3569
 do_filp_open+0x179/0x3c0 fs/namei.c:3603
 do_sys_open+0x296/0x410 fs/open.c:1081
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 7154:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xc9/0x250 mm/slab.c:3815
 seq_release fs/seq_file.c:369 [inline]
 seq_release_private+0xcd/0x120 fs/seq_file.c:617
 __fput+0x25f/0x7a0 fs/file_table.c:210
 task_work_run+0x11f/0x190 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
 do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff8880a01016c0
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 216 bytes inside of
 256-byte region [ffff8880a01016c0, ffff8880a01017c0)
The buggy address belongs to the page:
page:ffffea0002804040 count:1 mapcount:0 mapping:ffff8880a0101080 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff8880a0101080 0000000000000000 000000010000000c
raw: ffffea0002413c60 ffffea00028044e0 ffff88812fe527c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a0101680: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8880a0101700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a0101780: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                            ^
 ffff8880a0101800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a0101880: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/09/06 20:25 linux-4.14.y 2f166cdcf8a9 abf9ba4f .config console log report syz ci2-linux-4-14
* Struck through repros no longer work on HEAD.