syzbot


KASAN: slab-out-of-bounds Read in xfs_btree_lookup_get_block

Status: fixed on 2023/06/21 17:01
Bug presence: origin:lts-only
[Documentation on labels]
Reported-by: syzbot+243d578c4c2ac24d98fb@syzkaller.appspotmail.com
Fix commit: a2961463d74f xfs: verify buffer contents when we skip log replay
First crash: 371d, last: 371d
Fix bisection: fixed by (bisect log) :
commit a2961463d74f5c86a8dda3b41c484c28ccc4c289
Author: Darrick J. Wong <djwong@kernel.org>
Date: Wed Apr 12 05:49:23 2023 +0000

  xfs: verify buffer contents when we skip log replay

  
Bug presence (2)
Date Name Commit Repro Result
2023/05/21 linux-6.1.y (ToT) fa74641fb6b9 C [report] KASAN: slab-out-of-bounds Read in xfs_btree_lookup_get_block
2023/05/21 upstream (ToT) 0dd2a6fb1e34 C Didn't crash
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in xfs_btree_lookup_get_block xfs C error done 7 417d 514d 22/26 fixed on 2023/06/08 14:41
linux-5.15 UBSAN: array-index-out-of-bounds in xfs_btree_lookup_get_block origin:lts-only C error 1 370d 371d 0/3 upstream: reported C repro on 2023/05/21 13:02

Sample crash report:
XFS (loop0): Torn write (CRC failure) detected at log block 0x180. Truncating head block from 0x200.
XFS (loop0): Starting recovery (logdev: internal)
==================================================================
BUG: KASAN: slab-out-of-bounds in xfs_btree_lookup_get_block+0x180/0x66c fs/xfs/libxfs/xfs_btree.c:1813
Read of size 8 at addr ffff0000c3624128 by task syz-executor154/4217

CPU: 0 PID: 4217 Comm: syz-executor154 Not tainted 6.1.29-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x174/0x4c0 mm/kasan/report.c:395
 kasan_report+0xd4/0x130 mm/kasan/report.c:495
 __asan_report_load8_noabort+0x2c/0x38 mm/kasan/report_generic.c:351
 xfs_btree_lookup_get_block+0x180/0x66c fs/xfs/libxfs/xfs_btree.c:1813
 xfs_btree_lookup+0x388/0x117c fs/xfs/libxfs/xfs_btree.c:1913
 xfs_btree_simple_query_range+0xd4/0x5c4 fs/xfs/libxfs/xfs_btree.c:4713
 xfs_btree_query_range+0x2b4/0x348 fs/xfs/libxfs/xfs_btree.c:4953
 xfs_refcount_recover_cow_leftovers+0x2c4/0xbdc fs/xfs/libxfs/xfs_refcount.c:1832
 xfs_reflink_recover_cow+0x88/0x190 fs/xfs/xfs_reflink.c:930
 xlog_recover_finish+0x708/0x7ec fs/xfs/xfs_log_recover.c:3493
 xfs_log_mount_finish+0x1b8/0x3f4 fs/xfs/xfs_log.c:827
 xfs_mountfs+0x103c/0x18fc fs/xfs/xfs_mount.c:919
 xfs_fs_fill_super+0xd38/0xf50 fs/xfs/xfs_super.c:1666
 get_tree_bdev+0x360/0x54c fs/super.c:1346
 xfs_fs_get_tree+0x28/0x38 fs/xfs/xfs_super.c:1713
 vfs_get_tree+0x90/0x274 fs/super.c:1553
 do_new_mount+0x25c/0x8c8 fs/namespace.c:3040
 path_mount+0x590/0xe58 fs/namespace.c:3370
 do_mount fs/namespace.c:3383 [inline]
 __do_sys_mount fs/namespace.c:3591 [inline]
 __se_sys_mount fs/namespace.c:3568 [inline]
 __arm64_sys_mount+0x45c/0x594 fs/namespace.c:3568
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

The buggy address belongs to the object at ffff0000c3624108
 which belongs to the cache xfs_refcbt_cur of size 200
The buggy address is located 32 bytes inside of
 200-byte region [ffff0000c3624108, ffff0000c36241d0)

The buggy address belongs to the physical page:
page:00000000bb3715e9 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x103624
flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000200 0000000000000000 dead000000000122 ffff0000c4e94300
raw: 0000000000000000 00000000800f000f 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000c3624000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff0000c3624080: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
>ffff0000c3624100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                                  ^
 ffff0000c3624180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff0000c3624200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
XFS (loop0): Metadata corruption detected at xfs_btree_lookup_get_block+0x444/0x66c fs/xfs/libxfs/xfs_btree.c:1846, xfs_refcountbt block 0x18
XFS (loop0): Unmount and run xfs_repair
Unable to handle kernel paging request at virtual address e0c100530000024d
KASAN: maybe wild-memory-access in range [0x060c029800001268-0x060c02980000126f]
Mem abort info:
  ESR = 0x0000000096000004
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x04: level 0 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000004
  CM = 0, WnR = 0
[e0c100530000024d] address between user and kernel address ranges
Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 4217 Comm: syz-executor154 Tainted: G    B              6.1.29-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : xfs_trans_brelse+0x34/0x4e0 fs/xfs/xfs_trans_buf.c:349
lr : xfs_trans_brelse+0x2c/0x4e0 fs/xfs/xfs_trans_buf.c:348
sp : ffff80001d7a7340
x29: ffff80001d7a7340 x28: 00000000ffffff8b x27: 1fffe000186c4800
x26: 0000000000000007 x25: 00000000000000c8 x24: 1fffe000186c4809
x23: dfff800000000000 x22: 060c029800001079 x21: 060c029800001269
x20: ffff0000d3c0a000 x19: 060c029800001079 x18: 1fffe000368b6376
x17: 0000000000000000 x16: ffff8000120eb394 x15: ffff800008ac7c64
x14: ffff800008ac4a08 x13: ffff800008061eec x12: 0000000000000001
x11: ff80800009c8eb44 x10: 0000000000000000 x9 : ffff800009c8eb44
x8 : 00c180530000024d x7 : ffff800008061eec x6 : ffff8000080620fc
x5 : ffff0000d9d0eab0 x4 : ffff80001d7a6a78 x3 : ffff800009aa3ccc
x2 : 0000000000000000 x1 : 060c029800001079 x0 : ffff0000d3c0a000
Call trace:
 xfs_trans_brelse+0x34/0x4e0 fs/xfs/xfs_trans_buf.c:349
 xfs_btree_del_cursor+0xb8/0x24c fs/xfs/libxfs/xfs_btree.c:440
 xfs_refcount_recover_cow_leftovers+0x2d4/0xbdc fs/xfs/libxfs/xfs_refcount.c:1834
 xfs_reflink_recover_cow+0x88/0x190 fs/xfs/xfs_reflink.c:930
 xlog_recover_finish+0x708/0x7ec fs/xfs/xfs_log_recover.c:3493
 xfs_log_mount_finish+0x1b8/0x3f4 fs/xfs/xfs_log.c:827
 xfs_mountfs+0x103c/0x18fc fs/xfs/xfs_mount.c:919
 xfs_fs_fill_super+0xd38/0xf50 fs/xfs/xfs_super.c:1666
 get_tree_bdev+0x360/0x54c fs/super.c:1346
 xfs_fs_get_tree+0x28/0x38 fs/xfs/xfs_super.c:1713
 vfs_get_tree+0x90/0x274 fs/super.c:1553
 do_new_mount+0x25c/0x8c8 fs/namespace.c:3040
 path_mount+0x590/0xe58 fs/namespace.c:3370
 do_mount fs/namespace.c:3383 [inline]
 __do_sys_mount fs/namespace.c:3591 [inline]
 __se_sys_mount fs/namespace.c:3568 [inline]
 __arm64_sys_mount+0x45c/0x594 fs/namespace.c:3568
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581
Code: f2fbfff7 97a1b118 9107c275 d343fea8 (38776908) 
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
   0:	f2fbfff7 	movk	x23, #0xdfff, lsl #48
   4:	97a1b118 	bl	0xfffffffffe86c464
   8:	9107c275 	add	x21, x19, #0x1f0
   c:	d343fea8 	lsr	x8, x21, #3
* 10:	38776908 	ldrb	w8, [x8, x23] <-- trapping instruction

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/21 12:17 linux-6.1.y fa74641fb6b9 4bce1a3e .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan-arm64 KASAN: slab-out-of-bounds Read in xfs_btree_lookup_get_block
* Struck through repros no longer work on HEAD.