syzbot


KASAN: use-after-free Read in __fput

Status: fixed on 2018/02/13 04:59
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+7f44246e4b515a3908f27c3ac65d68c7c6cb4544@syzkaller.appspotmail.com
Fix commit: a5739435b5a3 fix kcm_clone()
First crash: 2610d, last: 2504d
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in __fput (2) fs 1 2378d 2369d 0/28 auto-closed as invalid on 2019/02/22 10:26
linux-4.19 KASAN: use-after-free Read in __fput syz done 1 1503d 1503d 1/1 fixed on 2020/10/03 03:32
upstream KASAN: use-after-free Read in __fput (3) fs syz done unreliable 1 1508d 1504d 0/28 auto-obsoleted due to no activity on 2022/09/19 18:33

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __fput+0x6b1/0x7f0 fs/file_table.c:212
Read of size 2 at addr ffff8801aeb56630 by task syz-executor6/3235

CPU: 1 PID: 3235 Comm: syz-executor6 Not tainted 4.14.0+ #183
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+0x194/0x257 lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report+0x25b/0x340 mm/kasan/report.c:409
 __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
 __fput+0x6b1/0x7f0 fs/file_table.c:212
 ____fput+0x15/0x20 fs/file_table.c:244
 task_work_run+0x199/0x270 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x296/0x310 arch/x86/entry/common.c:162
 prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
 syscall_return_slowpath+0x490/0x550 arch/x86/entry/common.c:264
 entry_SYSCALL_64_fastpath+0x94/0x96
RIP: 0033:0x452879
RSP: 002b:00007f6c78319be8 EFLAGS: 00000212 ORIG_RAX: 0000000000000010
RAX: fffffffffffffff4 RBX: 0000000000758020 RCX: 0000000000452879
RDX: 000000002091b000 RSI: 00000000000089e2 RDI: 0000000000000013
RBP: 000000000000034a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000212 R12: 00000000006f1f90
R13: 0000000000000014 R14: 00007f6c7831a6d4 R15: ffffffffffffffff

Allocated by task 3235:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
 kmem_cache_alloc+0x12e/0x760 mm/slab.c:3547
 sock_alloc_inode+0x70/0x300 net/socket.c:250
 alloc_inode+0x65/0x180 fs/inode.c:208
 new_inode_pseudo+0x69/0x190 fs/inode.c:890
 sock_alloc+0x41/0x270 net/socket.c:565
 kcm_clone net/kcm/kcmsock.c:1637 [inline]
 kcm_ioctl+0x864/0x1610 net/kcm/kcmsock.c:1713
 sock_do_ioctl+0x65/0xb0 net/socket.c:960
 sock_ioctl+0x2c2/0x440 net/socket.c:1057
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1530 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 entry_SYSCALL_64_fastpath+0x1f/0x96

Freed by task 3235:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3491 [inline]
 kmem_cache_free+0x77/0x280 mm/slab.c:3749
 sock_destroy_inode+0x56/0x70 net/socket.c:280
 destroy_inode+0x15d/0x200 fs/inode.c:265
 evict+0x57e/0x920 fs/inode.c:570
 iput_final fs/inode.c:1515 [inline]
 iput+0x7b9/0xaf0 fs/inode.c:1542
 sock_release+0x168/0x1e0 net/socket.c:606
 sock_close+0x16/0x20 net/socket.c:1125
 __fput+0x333/0x7f0 fs/file_table.c:210
 ____fput+0x15/0x20 fs/file_table.c:244
 task_work_run+0x199/0x270 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x296/0x310 arch/x86/entry/common.c:162
 prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
 syscall_return_slowpath+0x490/0x550 arch/x86/entry/common.c:264
 entry_SYSCALL_64_fastpath+0x94/0x96

The buggy address belongs to the object at ffff8801aeb56600
 which belongs to the cache sock_inode_cache of size 1048
The buggy address is located 48 bytes inside of
 1048-byte region [ffff8801aeb56600, ffff8801aeb56a18)
The buggy address belongs to the page:
page:ffffea0006bad580 count:1 mapcount:0 mapping:ffff8801aeb56140 index:0xffff8801aeb56ffd
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801aeb56140 ffff8801aeb56ffd 0000000100000003
raw: ffffea00073ddea0 ffffea0006abe220 ffff8801d9c9c380 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801aeb56500: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
 ffff8801aeb56580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8801aeb56600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff8801aeb56680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801aeb56700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (23):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2017/11/18 06:26 net-next-old 1deab8ce2c91 84dd36ba .config console log report ci-upstream-kasan-gce
2017/11/02 09:26 upstream 3a99df9a3d14 dab7524e .config console log report ci-upstream-kasan-gce
2017/11/22 13:38 net-next-old 0c86a6bd85ff ddf7b3e0 .config console log report ci-upstream-kasan-gce-386
2017/10/29 20:14 upstream 19e12196da60 80c74880 .config console log report ci-upstream-kasan-gce-386
2017/10/01 07:40 upstream a8c964eacb21 c26ea367 .config console log report ci-upstream-kasan-gce-386
2017/09/30 17:05 upstream 74d83ec2b734 c26ea367 .config console log report ci-upstream-kasan-gce-386
2017/12/06 06:36 net-next-old b9f242047f21 0796857b .config console log report ci-upstream-net-kasan-gce
2017/10/23 20:17 net-next-old 058c8d591241 92f543f0 .config console log report ci-upstream-net-kasan-gce
2017/10/22 22:26 net-next-old f8ddadc4db6c ab829b1b .config console log report ci-upstream-net-kasan-gce
2017/10/18 15:00 net-next-old 833e0e2f24fd 441d64d9 .config console log report ci-upstream-net-kasan-gce
2017/09/29 06:27 net-next-old fa8fefaa678e c26ea367 .config console log report ci-upstream-net-kasan-gce
2017/08/21 16:31 net-next-old 0c45d7fe12c7 f238fbd4 .config console log report ci-upstream-net-kasan-gce
2017/11/27 16:21 mmots 1ea8d039f9ed afba0b55 .config console log report ci-upstream-mmots-kasan-gce
2017/11/22 15:05 mmots 1ea8d039f9ed deb5f6ae .config console log report ci-upstream-mmots-kasan-gce
2017/11/20 11:34 mmots 9390953851bb 84dd36ba .config console log report ci-upstream-mmots-kasan-gce
2017/11/17 20:09 mmots 97530111c84b 00f6ff58 .config console log report ci-upstream-mmots-kasan-gce
2017/11/10 05:58 linux-next d9e0e63d9a6f e0a2b195 .config console log report ci-upstream-next-kasan-gce
2017/11/01 09:01 mmots 0f611fb6dcc0 e0a2b195 .config console log report ci-upstream-mmots-kasan-gce
2017/10/27 22:58 linux-next 36ef71cae353 e511d9f8 .config console log report ci-upstream-next-kasan-gce
2017/10/19 22:02 mmots 3ac81ebcbbb3 355f57c5 .config console log report ci-upstream-mmots-kasan-gce
2017/09/26 05:58 linux-next d35adcbe86c1 c26ea367 .config console log report ci-upstream-next-kasan-gce
2017/09/23 04:18 mmots 720bbe532b7c c26ea367 .config console log report ci-upstream-mmots-kasan-gce
2017/08/29 10:00 linux-next 9458bf6edfa8 ed7f9598 .config console log report skylake-linux-next-kasan-qemu
* Struck through repros no longer work on HEAD.