syzbot


KASAN: use-after-free Read in xlog_alloc_log

Status: fixed on 2019/08/05 13:45
Subsystems: xfs
[Documentation on labels]
Reported-by: syzbot+b75afdbe271a0d7ac4f6@syzkaller.appspotmail.com
Fix commit: 89b171acb222 xfs: fix iclog allocation size
First crash: 1818d, last: 1798d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in xlog_alloc_log 2 (3) 2019/06/27 13:52
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in xlog_alloc_log (2) xfs 55 1654d 1662d 15/27 fixed on 2020/01/08 01:06

Sample crash report:
XFS (loop4): log mount failed
XFS (loop4): Mounting V4 Filesystem
==================================================================
BUG: KASAN: use-after-free in xlog_alloc_log+0x126a/0x1390 fs/xfs/xfs_log.c:1471
Read of size 8 at addr ffff8880958f7750 by task syz-executor.4/11895

CPU: 0 PID: 11895 Comm: syz-executor.4 Not tainted 5.2.0+ #66
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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0xd4/0x306 mm/kasan/report.c:351
 __kasan_report.cold+0x1b/0x36 mm/kasan/report.c:482
 kasan_report+0x12/0x20 mm/kasan/common.c:612
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
 xlog_alloc_log+0x126a/0x1390 fs/xfs/xfs_log.c:1471
 xfs_log_mount+0xdc/0x780 fs/xfs/xfs_log.c:576
 xfs_mountfs+0xdb9/0x1be0 fs/xfs/xfs_mount.c:811
 xfs_fs_fill_super+0xcca/0x16e0 fs/xfs/xfs_super.c:1729
 mount_bdev+0x304/0x3c0 fs/super.c:1346
 xfs_fs_mount+0x35/0x40 fs/xfs/xfs_super.c:1803
 legacy_get_tree+0x108/0x220 fs/fs_context.c:661
 vfs_get_tree+0x8e/0x390 fs/super.c:1476
 do_new_mount fs/namespace.c:2792 [inline]
 do_mount+0x138c/0x1c00 fs/namespace.c:3112
 ksys_mount+0xdb/0x150 fs/namespace.c:3321
 __do_sys_mount fs/namespace.c:3335 [inline]
 __se_sys_mount fs/namespace.c:3332 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3332
 do_syscall_64+0xfd/0x6a0 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45c26a
Code: b8 a6 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 9d 8d fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 7a 8d fb ff c3 66 0f 1f 84 00 00 00 00 00
RSP: 002b:00007fbba560ca88 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fbba560cb40 RCX: 000000000045c26a
RDX: 00007fbba560cae0 RSI: 0000000020000000 RDI: 00007fbba560cb00
RBP: 0000000000000001 R08: 00007fbba560cb40 R09: 00007fbba560cae0
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000003
R13: 00000000004c8925 R14: 00000000004df5b0 R15: 00000000ffffffff

Allocated by task 11895:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:487 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:460
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:501
 __do_kmalloc mm/slab.c:3655 [inline]
 __kmalloc+0x163/0x780 mm/slab.c:3664
 kmalloc include/linux/slab.h:557 [inline]
 kmem_alloc+0xd2/0x200 fs/xfs/kmem.c:19
 kmem_zalloc fs/xfs/kmem.h:73 [inline]
 xlog_alloc_log+0xbf8/0x1390 fs/xfs/xfs_log.c:1413
 xfs_log_mount+0xdc/0x780 fs/xfs/xfs_log.c:576
 xfs_mountfs+0xdb9/0x1be0 fs/xfs/xfs_mount.c:811
 xfs_fs_fill_super+0xcca/0x16e0 fs/xfs/xfs_super.c:1729
 mount_bdev+0x304/0x3c0 fs/super.c:1346
 xfs_fs_mount+0x35/0x40 fs/xfs/xfs_super.c:1803
 legacy_get_tree+0x108/0x220 fs/fs_context.c:661
 vfs_get_tree+0x8e/0x390 fs/super.c:1476
 do_new_mount fs/namespace.c:2792 [inline]
 do_mount+0x138c/0x1c00 fs/namespace.c:3112
 ksys_mount+0xdb/0x150 fs/namespace.c:3321
 __do_sys_mount fs/namespace.c:3335 [inline]
 __se_sys_mount fs/namespace.c:3332 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3332
 do_syscall_64+0xfd/0x6a0 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 11895:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:449
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:457
 __cache_free mm/slab.c:3425 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3756
 kvfree+0x61/0x70 mm/util.c:413
 kmem_free fs/xfs/kmem.h:66 [inline]
 xlog_alloc_log+0xead/0x1390 fs/xfs/xfs_log.c:1473
 xfs_log_mount+0xdc/0x780 fs/xfs/xfs_log.c:576
 xfs_mountfs+0xdb9/0x1be0 fs/xfs/xfs_mount.c:811
 xfs_fs_fill_super+0xcca/0x16e0 fs/xfs/xfs_super.c:1729
 mount_bdev+0x304/0x3c0 fs/super.c:1346
 xfs_fs_mount+0x35/0x40 fs/xfs/xfs_super.c:1803
 legacy_get_tree+0x108/0x220 fs/fs_context.c:661
 vfs_get_tree+0x8e/0x390 fs/super.c:1476
 do_new_mount fs/namespace.c:2792 [inline]
 do_mount+0x138c/0x1c00 fs/namespace.c:3112
 ksys_mount+0xdb/0x150 fs/namespace.c:3321
 __do_sys_mount fs/namespace.c:3335 [inline]
 __se_sys_mount fs/namespace.c:3332 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3332
 do_syscall_64+0xfd/0x6a0 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880958f76c0
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 144 bytes inside of
 1024-byte region [ffff8880958f76c0, ffff8880958f7ac0)
The buggy address belongs to the page:
page:ffffea0002563d80 refcount:1 mapcount:0 mapping:ffff8880aa400c40 index:0xffff8880958f6940 compound_mapcount: 0
flags: 0x1fffc0000010200(slab|head)
raw: 01fffc0000010200 ffffea0002220c88 ffffea000298b908 ffff8880aa400c40
raw: ffff8880958f6940 ffff8880958f6040 0000000100000005 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880958f7600: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8880958f7680: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8880958f7700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff8880958f7780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880958f7800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (16):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/07/17 03:48 upstream 3eb514866f20 0d10349c .config console log report ci-upstream-kasan-gce-root
2019/07/16 00:25 upstream fec88ab0af97 6732e2c0 .config console log report ci-upstream-kasan-gce-selinux-root
2019/07/15 23:29 upstream fec88ab0af97 139ac68a .config console log report ci-upstream-kasan-gce-selinux-root
2019/07/15 00:39 upstream 192f0f8e9db7 2bbe2f05 .config console log report ci-upstream-kasan-gce-selinux-root
2019/07/15 00:38 upstream 192f0f8e9db7 2bbe2f05 .config console log report ci-upstream-kasan-gce-smack-root
2019/07/14 10:29 upstream 192f0f8e9db7 e6fb0f13 .config console log report ci-upstream-kasan-gce-smack-root
2019/07/14 10:00 upstream 192f0f8e9db7 e6fb0f13 .config console log report ci-upstream-kasan-gce-selinux-root
2019/07/08 14:49 linux-next d58b5ab90ee7 f62e1e85 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/07/02 08:46 linux-next 48a8a5f9a326 cccc4302 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/29 11:14 linux-next 48568d8c7f47 7509bf36 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/28 17:06 linux-next 48568d8c7f47 7509bf36 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/28 10:08 linux-next 8087b004bd09 7509bf36 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/27 22:53 linux-next 8087b004bd09 7509bf36 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/27 19:46 linux-next 8087b004bd09 7509bf36 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/27 12:28 linux-next 8087b004bd09 7509bf36 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/26 16:10 linux-next 1dd45f170b7e 4d342240 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.