syzbot


KASAN: use-after-free Read in gfs2_invalidatepage

Status: upstream: reported on 2024/11/27 20:24
Reported-by: syzbot+601c05a8b1b256cbe4ee@syzkaller.appspotmail.com
First crash: 23d, last: 23d

Sample crash report:
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 do_notify_resume+0x262c/0x32b8 arch/arm64/kernel/signal.c:946
 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:133 [inline]
 exit_to_user_mode arch/arm64/kernel/entry-common.c:138 [inline]
 el0_svc+0xfc/0x1f0 arch/arm64/kernel/entry-common.c:609
 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584
==================================================================
BUG: KASAN: use-after-free in list_empty include/linux/list.h:290 [inline]
BUG: KASAN: use-after-free in gfs2_discard fs/gfs2/aops.c:656 [inline]
BUG: KASAN: use-after-free in gfs2_invalidatepage+0x438/0x874 fs/gfs2/aops.c:693
Read of size 8 at addr ffff0000c9846168 by task syz-executor/4026

CPU: 1 PID: 4026 Comm: syz-executor Not tainted 5.15.173-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call trace:
 dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 print_address_description+0x7c/0x3f0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x174/0x1e4 mm/kasan/report.c:451
 __asan_report_load8_noabort+0x44/0x50 mm/kasan/report_generic.c:309
 list_empty include/linux/list.h:290 [inline]
 gfs2_discard fs/gfs2/aops.c:656 [inline]
 gfs2_invalidatepage+0x438/0x874 fs/gfs2/aops.c:693
 do_invalidatepage mm/truncate.c:157 [inline]
 truncate_cleanup_page+0x15c/0x414 mm/truncate.c:176
 truncate_inode_pages_range+0x254/0xbe0 mm/truncate.c:325
 truncate_inode_pages mm/truncate.c:425 [inline]
 truncate_inode_pages_final+0x94/0xd0 mm/truncate.c:464
 gfs2_evict_inode+0x8c4/0xf1c fs/gfs2/super.c:1415
 evict+0x418/0x894 fs/inode.c:622
 iput_final fs/inode.c:1744 [inline]
 iput+0x744/0x824 fs/inode.c:1770
 gfs2_put_super+0x25c/0x684 fs/gfs2/super.c:603
 generic_shutdown_super+0x130/0x2f0 fs/super.c:475
 kill_block_super+0x70/0xdc fs/super.c:1427
 gfs2_kill_sb+0xc0/0xd4
 deactivate_locked_super+0xb8/0x13c fs/super.c:335
 deactivate_super+0x108/0x128 fs/super.c:366
 cleanup_mnt+0x3c0/0x474 fs/namespace.c:1143
 __cleanup_mnt+0x20/0x30 fs/namespace.c:1150
 task_work_run+0x130/0x1e4 kernel/task_work.c:188
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 do_notify_resume+0x262c/0x32b8 arch/arm64/kernel/signal.c:946
 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:133 [inline]
 exit_to_user_mode arch/arm64/kernel/entry-common.c:138 [inline]
 el0_svc+0xfc/0x1f0 arch/arm64/kernel/entry-common.c:609
 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Allocated by task 4127:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x8c/0xcc mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x74/0x3f4 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x1dc/0x45c mm/slub.c:3233
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 gfs2_alloc_bufdata fs/gfs2/trans.c:168 [inline]
 gfs2_trans_add_data+0x1f8/0x6b8 fs/gfs2/trans.c:209
 gfs2_unstuffer_page fs/gfs2/bmap.c:83 [inline]
 __gfs2_unstuff_inode fs/gfs2/bmap.c:121 [inline]
 gfs2_unstuff_dinode+0xcd8/0x118c fs/gfs2/bmap.c:168
 gfs2_adjust_quota+0x258/0x908 fs/gfs2/quota.c:847
 gfs2_set_dqblk+0x8a8/0xb7c fs/gfs2/quota.c:1764
 quota_setquota+0x5f4/0x728 fs/quota/quota.c:309
 do_quotactl+0x508/0x698 fs/quota/quota.c:801
 __do_sys_quotactl fs/quota/quota.c:959 [inline]
 __se_sys_quotactl fs/quota/quota.c:915 [inline]
 __arm64_sys_quotactl+0x2d8/0x7a4 fs/quota/quota.c:915
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

The buggy address belongs to the object at ffff0000c9846150
 which belongs to the cache gfs2_bufdata of size 80
The buggy address is located 24 bytes inside of
 80-byte region [ffff0000c9846150, ffff0000c98461a0)
The buggy address belongs to the page:
page:00000000d7df9b18 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff0000c9846150 pfn:0x109846
flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000200 0000000000000000 dead000000000122 ffff0000c629a900
raw: ffff0000c9846150 000000008024001d 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000c9846000: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fb fb
 ffff0000c9846080: fb fb fb fb fb fb fb fb fc fc fc fc fb fb fb fb
>ffff0000c9846100: fb fb fb fb fb fb fc fc fc fc fb fb fb fb fb fb
                                                          ^
 ffff0000c9846180: fb fb fb fb fc fc fc fc fb fb fb fb fb fb fb fb
 ffff0000c9846200: fb fb fc fc fc fc fb fb fb fb fb fb fb fb fb fb
==================================================================
Unable to handle kernel paging request at virtual address dfff800000000005
Mem abort info:
  ESR = 0x0000000096000006
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x06: level 2 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000006
  CM = 0, WnR = 0
[dfff800000000005] address between user and kernel address ranges
Internal error: Oops: 0000000096000006 [#1] PREEMPT SMP
Modules linked in:
CPU: 1 PID: 4026 Comm: syz-executor Tainted: G    B             5.15.173-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : gfs2_remove_from_journal+0x3a8/0x848 fs/gfs2/meta_io.c:351
lr : gfs2_remove_from_journal+0x398/0x848 fs/gfs2/meta_io.c:351
sp : ffff80001fee7170
x29: ffff80001fee7190 x28: dfff800000000000 x27: ffff0000c9846170
x26: ffff0000c9846170 x25: 1fffe0001b8d8581 x24: 0000000000010000
x23: 000000000000002c x22: 0000000000000000 x21: ffff0000dc6c2c08
x20: ffff0000c9846150 x19: ffff0000dc6c2bc8 x18: 0000000000000003
x17: 0000000000000000 x16: ffff800011b4c108 x15: 00000000ffffffff
x14: ffff0000c7cf9b40 x13: 0000000000000001 x12: 0000000000000001
x11: 0000000000000002 x10: 0000000000000000 x9 : ffff0000c7cf9b40
x8 : 0000000000000005 x7 : 0000000000000000 x6 : ffff80000a3473bc
x5 : 0000000000000000 x4 : 0000000000000001 x3 : ffff80000a3432c0
x2 : 0000000000000001 x1 : 0000000000000000 x0 : 0000000000000001
Call trace:
 gfs2_remove_from_journal+0x3a8/0x848 fs/gfs2/meta_io.c:351
 gfs2_discard fs/gfs2/aops.c:660 [inline]
 gfs2_invalidatepage+0x51c/0x874 fs/gfs2/aops.c:693
 do_invalidatepage mm/truncate.c:157 [inline]
 truncate_cleanup_page+0x15c/0x414 mm/truncate.c:176
 truncate_inode_pages_range+0x254/0xbe0 mm/truncate.c:325
 truncate_inode_pages mm/truncate.c:425 [inline]
 truncate_inode_pages_final+0x94/0xd0 mm/truncate.c:464
 gfs2_evict_inode+0x8c4/0xf1c fs/gfs2/super.c:1415
 evict+0x418/0x894 fs/inode.c:622
 iput_final fs/inode.c:1744 [inline]
 iput+0x744/0x824 fs/inode.c:1770
 gfs2_put_super+0x25c/0x684 fs/gfs2/super.c:603
 generic_shutdown_super+0x130/0x2f0 fs/super.c:475
 kill_block_super+0x70/0xdc fs/super.c:1427
 gfs2_kill_sb+0xc0/0xd4
 deactivate_locked_super+0xb8/0x13c fs/super.c:335
 deactivate_super+0x108/0x128 fs/super.c:366
 cleanup_mnt+0x3c0/0x474 fs/namespace.c:1143
 __cleanup_mnt+0x20/0x30 fs/namespace.c:1150
 task_work_run+0x130/0x1e4 kernel/task_work.c:188
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 do_notify_resume+0x262c/0x32b8 arch/arm64/kernel/signal.c:946
 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:133 [inline]
 exit_to_user_mode arch/arm64/kernel/entry-common.c:138 [inline]
 el0_svc+0xfc/0x1f0 arch/arm64/kernel/entry-common.c:609
 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584
Code: f94003f6 f9400bf9 9100b2d7 d343fee8 (38fc6908) 
---[ end trace 9922a0c037cbccdb ]---
----------------
Code disassembly (best guess):
   0:	f94003f6 	ldr	x22, [sp]
   4:	f9400bf9 	ldr	x25, [sp, #16]
   8:	9100b2d7 	add	x23, x22, #0x2c
   c:	d343fee8 	lsr	x8, x23, #3
* 10:	38fc6908 	ldrsb	w8, [x8, x28] <-- trapping instruction

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/27 20:24 linux-5.15.y 0a51d2d4527b 5df23865 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in gfs2_invalidatepage
* Struck through repros no longer work on HEAD.