syzbot


KASAN: use-after-free Read in radix_tree_next_chunk

Status: fixed on 2018/06/07 13:52
Subsystems: xfs
[Documentation on labels]
Reported-by: syzbot+040b31ac96753fd7eb46@syzkaller.appspotmail.com
Fix commit: 79f546a696bf fs: don't scan the inode cache before SB_BORN is set
First crash: 2382d, last: 2329d
Discussions (2)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in radix_tree_next_chunk 1 (2) 2018/04/04 07:14
KASAN: use-after-free Read in radix_tree_next_chunk 0 (1) 2018/03/31 20:47
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in radix_tree_next_chunk C 465 600d 1735d 0/1 upstream: reported C repro on 2020/01/06 15:45

Sample crash report:
XFS (loop5): Invalid superblock magic number
XFS (loop6): Invalid superblock magic number
XFS (loop4): Invalid superblock magic number
XFS (loop7): Invalid superblock magic number
==================================================================
BUG: KASAN: use-after-free in radix_tree_next_chunk+0xf9f/0xfb0 lib/radix-tree.c:1718
Read of size 4 at addr ffff8801d8d92588 by task syz-executor042/8776

CPU: 0 PID: 8776 Comm: syz-executor042 Not tainted 4.17.0-rc5+ #60
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+0x1b9/0x294 lib/dump_stack.c:113
 print_address_description+0x6c/0x20b mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 radix_tree_next_chunk+0xf9f/0xfb0 lib/radix-tree.c:1718
 radix_tree_gang_lookup_tag+0x3d4/0x5f0 lib/radix-tree.c:1916
XFS (loop3): Invalid superblock magic number
 xfs_perag_get_tag+0x12d/0x7c0 fs/xfs/libxfs/xfs_sb.c:88
 xfs_reclaim_inodes_count+0x82/0xb0 fs/xfs/xfs_icache.c:1383
XFS (loop0): Invalid superblock magic number
 xfs_fs_nr_cached_objects+0x37/0x50 fs/xfs/xfs_super.c:1809
 super_cache_count+0x98/0x280 fs/super.c:132
 do_shrink_slab mm/vmscan.c:374 [inline]
 shrink_slab.part.39+0x330/0xf90 mm/vmscan.c:531
 shrink_slab+0xa1/0xc0 mm/vmscan.c:506
 shrink_node+0x4f2/0x1740 mm/vmscan.c:2561
 shrink_zones mm/vmscan.c:2794 [inline]
 do_try_to_free_pages+0x3c9/0x1240 mm/vmscan.c:2856
 try_to_free_mem_cgroup_pages+0x475/0xc50 mm/vmscan.c:3146
 memory_high_write+0x26e/0x2f0 mm/memcontrol.c:5124
 cgroup_file_write+0x317/0x820 kernel/cgroup/cgroup.c:3429
 kernfs_fop_write+0x2ba/0x480 fs/kernfs/file.c:316
 __vfs_write+0x10b/0x960 fs/read_write.c:485
 vfs_write+0x1f8/0x560 fs/read_write.c:549
 ksys_write+0xf9/0x250 fs/read_write.c:598
 __do_sys_write fs/read_write.c:610 [inline]
 __se_sys_write fs/read_write.c:607 [inline]
 __x64_sys_write+0x73/0xb0 fs/read_write.c:607
 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x441d29
RSP: 002b:00007ffd74c58c38 EFLAGS: 00000217 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441d29
RDX: 0000000000000001 RSI: 0000000020000000 RDI: 0000000000000004
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000217 R12: 0000000000000030
R13: 000000000000a9b8 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 8739:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
 kmem_cache_alloc_trace+0x152/0x780 mm/slab.c:3620
 kmalloc include/linux/slab.h:512 [inline]
 kzalloc include/linux/slab.h:701 [inline]
 xfs_mount_alloc fs/xfs/xfs_super.c:1587 [inline]
 xfs_fs_fill_super+0xda/0x1560 fs/xfs/xfs_super.c:1620
 mount_bdev+0x30c/0x3e0 fs/super.c:1164
 xfs_fs_mount+0x34/0x40 fs/xfs/xfs_super.c:1801
 mount_fs+0xae/0x328 fs/super.c:1267
 vfs_kern_mount.part.34+0xd4/0x4d0 fs/namespace.c:1037
 vfs_kern_mount fs/namespace.c:1027 [inline]
 do_new_mount fs/namespace.c:2518 [inline]
 do_mount+0x564/0x3070 fs/namespace.c:2848
 ksys_mount+0x12d/0x140 fs/namespace.c:3064
 __do_sys_mount fs/namespace.c:3078 [inline]
 __se_sys_mount fs/namespace.c:3075 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3075
 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8739:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xd9/0x260 mm/slab.c:3813
 xfs_fs_fill_super+0x66a/0x1560 fs/xfs/xfs_super.c:1765
 mount_bdev+0x30c/0x3e0 fs/super.c:1164
 xfs_fs_mount+0x34/0x40 fs/xfs/xfs_super.c:1801
 mount_fs+0xae/0x328 fs/super.c:1267
 vfs_kern_mount.part.34+0xd4/0x4d0 fs/namespace.c:1037
 vfs_kern_mount fs/namespace.c:1027 [inline]
 do_new_mount fs/namespace.c:2518 [inline]
 do_mount+0x564/0x3070 fs/namespace.c:2848
 ksys_mount+0x12d/0x140 fs/namespace.c:3064
 __do_sys_mount fs/namespace.c:3078 [inline]
 __se_sys_mount fs/namespace.c:3075 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3075
 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801d8d92180
 which belongs to the cache kmalloc-4096 of size 4096
The buggy address is located 1032 bytes inside of
 4096-byte region [ffff8801d8d92180, ffff8801d8d93180)
The buggy address belongs to the page:
page:ffffea0007636480 count:1 mapcount:0 mapping:ffff8801d8d92180 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffff8801d8d92180 0000000000000000 0000000100000001
raw: ffffea0006eac020 ffffea0007633c20 ffff8801da800dc0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d8d92480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8d92500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801d8d92580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff8801d8d92600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8d92680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2749):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/05/20 20:56 upstream 203ec2fed17a f48c20b8 .config console log report syz C ci-upstream-kasan-gce-root
2018/04/16 06:50 upstream 71b8ebbf3d7b 7a67784c .config console log report syz C ci-upstream-kasan-gce-root
2018/04/11 07:16 upstream c18bb396d3d2 8b8de427 .config console log report syz C ci-upstream-kasan-gce-root
2018/04/01 10:06 upstream 10b84daddbec 0174c6c8 .config console log report syz C ci-upstream-kasan-gce-root
2018/03/30 23:02 upstream 9dd2326890d8 8fbce0e4 .config console log report syz C ci-upstream-kasan-gce-root
2018/05/22 06:22 upstream 6741c4bb389d f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/21 21:44 upstream 6741c4bb389d f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/21 20:30 upstream 6741c4bb389d f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/21 13:47 upstream 771c577c23ba f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/21 07:45 upstream 771c577c23ba f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/21 06:25 upstream 771c577c23ba f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/21 05:17 upstream 771c577c23ba f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/21 03:53 upstream 771c577c23ba f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/21 02:25 upstream 771c577c23ba f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/21 00:48 upstream 771c577c23ba f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/20 20:09 upstream 203ec2fed17a f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/20 19:02 upstream 203ec2fed17a f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/20 17:41 upstream 203ec2fed17a f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/20 14:18 upstream 203ec2fed17a f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/20 10:28 upstream 203ec2fed17a f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/20 06:24 upstream 0b449a441dac f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/20 02:32 upstream 0b449a441dac f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/19 21:13 upstream 0b449a441dac f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/19 19:22 upstream 73fcb1a370c7 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/19 17:37 upstream 73fcb1a370c7 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/19 16:21 upstream 73fcb1a370c7 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/19 14:27 upstream 73fcb1a370c7 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/19 12:56 upstream 73fcb1a370c7 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/19 11:11 upstream 73fcb1a370c7 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/19 09:53 upstream 73fcb1a370c7 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/18 20:36 upstream 2c71d338bef2 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/18 19:28 upstream 3acf4e395260 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/18 16:58 upstream 3acf4e395260 c992b767 .config console log report ci-upstream-kasan-gce-root
2018/05/18 11:52 upstream 3acf4e395260 c992b767 .config console log report ci-upstream-kasan-gce-root
2018/05/18 10:43 upstream 3acf4e395260 c992b767 .config console log report ci-upstream-kasan-gce-root
2018/05/18 04:20 upstream 305bb5521282 738d58ad .config console log report ci-upstream-kasan-gce-root
2018/05/18 02:27 upstream 305bb5521282 738d58ad .config console log report ci-upstream-kasan-gce-root
2018/05/17 22:59 upstream 305bb5521282 738d58ad .config console log report ci-upstream-kasan-gce-root
2018/05/17 21:12 upstream 305bb5521282 738d58ad .config console log report ci-upstream-kasan-gce-root
2018/05/17 18:30 upstream 305bb5521282 738d58ad .config console log report ci-upstream-kasan-gce-root
2018/05/17 17:21 upstream e6506eb24187 90c54c49 .config console log report ci-upstream-kasan-gce-root
2018/05/17 16:10 upstream e6506eb24187 90c54c49 .config console log report ci-upstream-kasan-gce-root
2018/05/17 13:35 upstream e6506eb24187 90c54c49 .config console log report ci-upstream-kasan-gce-root
2018/05/17 10:41 upstream e6506eb24187 90c54c49 .config console log report ci-upstream-kasan-gce-root
2018/05/17 09:03 upstream e6506eb24187 a367c1d7 .config console log report ci-upstream-kasan-gce-root
2018/05/17 08:00 upstream e6506eb24187 a367c1d7 .config console log report ci-upstream-kasan-gce-root
2018/05/17 05:51 upstream e6506eb24187 a367c1d7 .config console log report ci-upstream-kasan-gce-root
2018/05/17 03:08 upstream e6506eb24187 a367c1d7 .config console log report ci-upstream-kasan-gce-root
2018/05/17 01:47 upstream e6506eb24187 a367c1d7 .config console log report ci-upstream-kasan-gce-root
2018/05/17 00:25 upstream 21b9f1c7e319 a367c1d7 .config console log report ci-upstream-kasan-gce-root
2018/05/16 21:54 upstream 21b9f1c7e319 a367c1d7 .config console log report ci-upstream-kasan-gce-root
2018/05/16 18:04 upstream 21b9f1c7e319 75b2448a .config console log report ci-upstream-kasan-gce-root
2018/05/16 15:07 upstream 21b9f1c7e319 75b2448a .config console log report ci-upstream-kasan-gce-root
2018/05/16 12:59 upstream 21b9f1c7e319 75b2448a .config console log report ci-upstream-kasan-gce-root
2018/05/16 09:15 upstream 21b9f1c7e319 75b2448a .config console log report ci-upstream-kasan-gce-root
2018/03/30 19:43 upstream 9dd2326890d8 8fbce0e4 .config console log report ci-upstream-kasan-gce-root
* Struck through repros no longer work on HEAD.