syzbot


KASAN: use-after-free Read in gfs2_log_flush

Status: fixed on 2018/11/12 21:25
Subsystems: gfs2
[Documentation on labels]
Reported-by: syzbot+dcb8b3587445007f5808@syzkaller.appspotmail.com
Fix commit: 4c62bd9cea7b gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd
First crash: 2089d, last: 2045d
Discussions (6)
Title Replies (including bot) Last reply
[PATCH 4.19 000/110] 4.19.6-stable review 142 (142) 2018/12/14 17:42
[PATCH 4.14 000/100] 4.14.85-stable review 116 (116) 2018/12/03 11:38
[PATCH 3.18 00/83] 3.18.128-stable review 97 (97) 2018/12/02 20:32
[PATCH 4.9 00/92] 4.9.142-stable review 102 (102) 2018/11/30 22:28
[PATCH 4.4 00/86] 4.4.166-stable review 92 (92) 2018/11/30 22:27
KASAN: use-after-free Read in gfs2_log_flush 0 (2) 2018/10/07 05:01

Sample crash report:
gfs2: not a GFS2 filesystem
gfs2: not a GFS2 filesystem
gfs2: not a GFS2 filesystem
gfs2: can't alloc struct gfs2_sbd
==================================================================
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
BUG: KASAN: use-after-free in gfs2_log_flush+0x1ec/0x29c0 fs/gfs2/log.c:779
Read of size 4 at addr ffff8801cd326ba8 by task syz-executor1/14034

CPU: 0 PID: 14034 Comm: syz-executor1 Not tainted 4.19.0-rc6+ #272
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+0x1c4/0x2b4 lib/dump_stack.c:113
 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
 kasan_check_read+0x11/0x20 mm/kasan/kasan.c:272
 atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
 gfs2_log_flush+0x1ec/0x29c0 fs/gfs2/log.c:779
 gfs2_kill_sb+0x5b/0x1a0 fs/gfs2/ops_fstype.c:1366
 deactivate_locked_super+0x97/0x100 fs/super.c:329
 gfs2_mount+0x568/0x712 fs/gfs2/ops_fstype.c:1316
 mount_fs+0xae/0x31d fs/super.c:1261
 vfs_kern_mount.part.35+0xdc/0x4f0 fs/namespace.c:961
 vfs_kern_mount fs/namespace.c:951 [inline]
 do_new_mount fs/namespace.c:2457 [inline]
 do_mount+0x581/0x31f0 fs/namespace.c:2787
 ksys_mount+0x12d/0x140 fs/namespace.c:3003
 __do_sys_mount fs/namespace.c:3017 [inline]
 __se_sys_mount fs/namespace.c:3014 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3014
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457579
Code: 1d 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 eb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fbd1a8c5c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 0000000000457579
RDX: 0000000020000300 RSI: 00000000200002c0 RDI: 0000000020000000
RBP: 000000000072bfa0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fbd1a8c66d4
R13: 00000000004c28af R14: 00000000004d3c78 R15: 00000000ffffffff

Allocated by task 14034:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
 kmalloc include/linux/slab.h:513 [inline]
 kzalloc include/linux/slab.h:707 [inline]
 init_sbd+0x13f/0xfa0 fs/gfs2/ops_fstype.c:71
 fill_super+0xab/0x1a10 fs/gfs2/ops_fstype.c:1041
 gfs2_mount+0x5e6/0x712 fs/gfs2/ops_fstype.c:1302
 mount_fs+0xae/0x31d fs/super.c:1261
 vfs_kern_mount.part.35+0xdc/0x4f0 fs/namespace.c:961
 vfs_kern_mount fs/namespace.c:951 [inline]
 do_new_mount fs/namespace.c:2457 [inline]
 do_mount+0x581/0x31f0 fs/namespace.c:2787
 ksys_mount+0x12d/0x140 fs/namespace.c:3003
 __do_sys_mount fs/namespace.c:3017 [inline]
 __se_sys_mount fs/namespace.c:3014 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3014
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 14034:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3813
 init_sbd+0xd80/0xfa0 fs/gfs2/ops_fstype.c:79
 fill_super+0xab/0x1a10 fs/gfs2/ops_fstype.c:1041
 gfs2_mount+0x5e6/0x712 fs/gfs2/ops_fstype.c:1302
 mount_fs+0xae/0x31d fs/super.c:1261
 vfs_kern_mount.part.35+0xdc/0x4f0 fs/namespace.c:961
 vfs_kern_mount fs/namespace.c:951 [inline]
 do_new_mount fs/namespace.c:2457 [inline]
 do_mount+0x581/0x31f0 fs/namespace.c:2787
 ksys_mount+0x12d/0x140 fs/namespace.c:3003
 __do_sys_mount fs/namespace.c:3017 [inline]
 __se_sys_mount fs/namespace.c:3014 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3014
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801cd325c00
 which belongs to the cache kmalloc-8192 of size 8192
The buggy address is located 4008 bytes inside of
 8192-byte region [ffff8801cd325c00, ffff8801cd327c00)
The buggy address belongs to the page:
page:ffffea000734c900 count:1 mapcount:0 mapping:ffff8801da802080 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffffea00071c4708 ffff8801da801b48 ffff8801da802080
raw: 0000000000000000 ffff8801cd325c00 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801cd326a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801cd326b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801cd326b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
 ffff8801cd326c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801cd326c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (14):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/10/07 15:16 upstream fb1c592cf4c9 8b311eaf .config console log report syz ci-upstream-kasan-gce-root
2018/10/07 06:02 upstream c1d84a1b42ef 8b311eaf .config console log report syz ci-upstream-kasan-gce-root
2018/10/07 14:52 linux-next 12ffaa1197f5 8b311eaf .config console log report syz ci-upstream-linux-next-kasan-gce-root
2018/10/07 05:00 linux-next 12ffaa1197f5 8b311eaf .config console log report syz ci-upstream-linux-next-kasan-gce-root
2018/10/22 12:23 upstream 467e050e9760 ecb386fe .config console log report ci-upstream-kasan-gce-selinux-root
2018/10/09 15:40 upstream 64c5e530ac2c 8b311eaf .config console log report ci-upstream-kasan-gce-smack-root
2018/10/09 13:48 upstream 64c5e530ac2c 8b311eaf .config console log report ci-upstream-kasan-gce-root
2018/10/06 20:03 upstream 091a1eaa0e30 8b311eaf .config console log report ci-upstream-kasan-gce-smack-root
2018/09/24 16:18 upstream 02214bfc89c7 2f485cdf .config console log report ci-upstream-kasan-gce-root
2018/10/07 14:11 linux-next 12ffaa1197f5 8b311eaf .config console log report ci-upstream-linux-next-kasan-gce-root
2018/10/07 12:49 linux-next 12ffaa1197f5 8b311eaf .config console log report ci-upstream-linux-next-kasan-gce-root
2018/10/07 04:34 linux-next 12ffaa1197f5 8b311eaf .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/22 17:46 linux-next 46c163a036b4 37079712 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/08 05:07 linux-next f2b6e66e9885 6b5120a4 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.