syzbot


KASAN: use-after-free Write in __sock_release

Status: fixed on 2020/10/04 08:47
Reported-by: syzbot+f82c872cc6989b92e005@syzkaller.appspotmail.com
Fix commit: 37d933e8b41b fix regression in "epoll: Keep a reference on files added to the check list"
First crash: 1320d, last: 1320d
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:
batman_adv: batadv0: Interface activated: batadv_slave_1
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_to_batadv: link becomes ready
Bluetooth: hci0: command 0x0409 tx timeout
Bluetooth: hci0: command 0x041b tx timeout
==================================================================
BUG: KASAN: use-after-free in __sock_release+0x25b/0x2a0 net/socket.c:583
Write of size 8 at addr ffff888080002aa8 by task syz-executor.0/7490

CPU: 1 PID: 7490 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_store8_noabort+0x88/0x90 mm/kasan/report.c:438
 __sock_release+0x25b/0x2a0 net/socket.c:583
 sock_close+0x15/0x20 net/socket.c:1140
 __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:00007f380b916c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000e9
RAX: 0000000000000000 RBX: 0000000000002ac0 RCX: 000000000045d5b9
RDX: 0000000000000004 RSI: 0000000000000001 RDI: 0000000000000007
RBP: 000000000118cf88 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000020c7f000 R11: 0000000000000246 R12: 000000000118cf4c
R13: 00007ffd9ad5c88f R14: 00007f380b9179c0 R15: 000000000118cf4c

Allocated by task 7490:
 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_socket+0xef/0x200 net/socket.c:1346
 __do_sys_socket net/socket.c:1355 [inline]
 __se_sys_socket net/socket.c:1353 [inline]
 __x64_sys_socket+0x6f/0xb0 net/socket.c:1353
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 7489:
 __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 ffff888080002a80
 which belongs to the cache sock_inode_cache of size 992
The buggy address is located 40 bytes inside of
 992-byte region [ffff888080002a80, ffff888080002e60)
The buggy address belongs to the page:
page:ffffea0002000080 count:1 mapcount:0 mapping:ffff88821b6c3000 index:0xffff888080002ffd
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea00020bf708 ffffea00020000c8 ffff88821b6c3000
raw: ffff888080002ffd ffff888080002180 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888080002980: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff888080002a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888080002a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
 ffff888080002b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888080002b80: 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/03 16:53 linux-4.19.y c37da90efff5 abf9ba4f .config console log report syz ci2-linux-4-19
* Struck through repros no longer work on HEAD.