syzbot


KASAN: slab-use-after-free Read in list_lru_del

Status: upstream: reported syz repro on 2025/02/06 17:01
Subsystems: bcachefs mm
[Documentation on labels]
Reported-by: syzbot+6663075ddb9be85fa6e5@syzkaller.appspotmail.com
First crash: 50d, last: 6d19h
Cause bisection: introduced by (bisect log) :
commit 14152654805256d760315ec24e414363bfa19a06
Author: Kent Overstreet <kent.overstreet@linux.dev>
Date: Mon Nov 25 05:21:27 2024 +0000

  bcachefs: Bad btree roots are now autofix

Crash: invalid opcode in corrupted (log)
Repro: syz .config
  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [mm?] [bcachefs?] KASAN: slab-use-after-free Read in list_lru_del 0 (2) 2025/03/07 22:42
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream BUG: corrupted list in list_lru_del mm 2 833d 873d 0/28 auto-obsoleted due to no activity on 2023/03/15 19:34
Last patch testing requests (3)
Created Duration User Patch Repo Result
2025/03/16 02:44 1h11m retest repro upstream OK log
2025/03/16 02:44 19m retest repro upstream OK log
2025/03/15 18:54 21m retest repro upstream OK log

Sample crash report:
syz.0.0: attempt to access beyond end of device
loop0: rw=1, sector=3112, nr_sectors = 40 limit=0
gfs2: fsid=syz:syz.0: Error 10 writing to journal, jid=0
==================================================================
BUG: KASAN: slab-use-after-free in __list_del_entry_valid_or_report+0xb6/0x190 lib/list_debug.c:65
Read of size 8 at addr ffff888044dcc080 by task syz.0.0/5322

CPU: 0 UID: 0 PID: 5322 Comm: syz.0.0 Not tainted 6.14.0-rc7-syzkaller-00186-gd07de43e3f05 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:408 [inline]
 print_report+0x16e/0x5b0 mm/kasan/report.c:521
 kasan_report+0x143/0x180 mm/kasan/report.c:634
 __list_del_entry_valid_or_report+0xb6/0x190 lib/list_debug.c:65
 __list_del_entry_valid include/linux/list.h:124 [inline]
 __list_del_entry include/linux/list.h:215 [inline]
 list_del_init include/linux/list.h:287 [inline]
 list_lru_del+0x9a/0x1f0 mm/list_lru.c:206
 gfs2_quota_cleanup+0x200/0x700 fs/gfs2/quota.c:1532
 gfs2_make_fs_ro+0x29e/0x330 fs/gfs2/super.c:578
 gfs2_put_super+0x233/0x940 fs/gfs2/super.c:610
 generic_shutdown_super+0x139/0x2d0 fs/super.c:642
 kill_block_super+0x44/0x90 fs/super.c:1710
 deactivate_locked_super+0xc4/0x130 fs/super.c:473
 cleanup_mnt+0x41f/0x4b0 fs/namespace.c:1413
 task_work_run+0x24f/0x310 kernel/task_work.c:227
 exit_task_work include/linux/task_work.h:40 [inline]
 do_exit+0xa2a/0x2940 kernel/exit.c:938
 do_group_exit+0x207/0x2c0 kernel/exit.c:1087
 __do_sys_exit_group kernel/exit.c:1098 [inline]
 __se_sys_exit_group kernel/exit.c:1096 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1096
 x64_sys_call+0x26a8/0x26b0 arch/x86/include/generated/asm/syscalls_64.h:232
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd0dd78d169
Code: Unable to access opcode bytes at 0x7fd0dd78d13f.
RSP: 002b:00007ffff42dff68 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fd0dd78d169
RDX: 0000000000000064 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000003 R08: 0000001ef42e005f R09: 00007fd0dd976260
R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fd0dd976260 R14: 0000000000000003 R15: 00007ffff42e0020
 </TASK>

Allocated by task 5323:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:319 [inline]
 __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:345
 kasan_slab_alloc include/linux/kasan.h:250 [inline]
 slab_post_alloc_hook mm/slub.c:4115 [inline]
 slab_alloc_node mm/slub.c:4164 [inline]
 kmem_cache_alloc_noprof+0x1d9/0x380 mm/slub.c:4171
 qd_alloc+0x51/0x250 fs/gfs2/quota.c:234
 gfs2_quota_init+0x81a/0x1420 fs/gfs2/quota.c:1448
 gfs2_make_fs_rw+0x43f/0x5e0 fs/gfs2/super.c:159
 gfs2_fill_super+0x246f/0x2700 fs/gfs2/ops_fstype.c:1274
 get_tree_bdev_flags+0x48c/0x5c0 fs/super.c:1636
 gfs2_get_tree+0x54/0x220 fs/gfs2/ops_fstype.c:1330
 vfs_get_tree+0x90/0x2b0 fs/super.c:1814
 do_new_mount+0x2be/0xb40 fs/namespace.c:3560
 do_mount fs/namespace.c:3900 [inline]
 __do_sys_mount fs/namespace.c:4111 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4088
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 0:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:576
 poison_slab_object mm/kasan/common.c:247 [inline]
 __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:233 [inline]
 slab_free_hook mm/slub.c:2353 [inline]
 slab_free mm/slub.c:4609 [inline]
 kmem_cache_free+0x195/0x410 mm/slub.c:4711
 gfs2_qd_dealloc+0x72/0xf0 fs/gfs2/quota.c:111
 rcu_do_batch kernel/rcu/tree.c:2546 [inline]
 rcu_core+0xaaa/0x17a0 kernel/rcu/tree.c:2802
 handle_softirqs+0x2d4/0x9b0 kernel/softirq.c:561
 __do_softirq kernel/softirq.c:595 [inline]
 invoke_softirq kernel/softirq.c:435 [inline]
 __irq_exit_rcu+0xf7/0x220 kernel/softirq.c:662
 irq_exit_rcu+0x9/0x30 kernel/softirq.c:678
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1049 [inline]
 sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1049
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702

Last potentially related work creation:
 kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47
 kasan_record_aux_stack+0xaa/0xc0 mm/kasan/generic.c:548
 __call_rcu_common kernel/rcu/tree.c:3065 [inline]
 call_rcu+0x168/0xac0 kernel/rcu/tree.c:3172
 gfs2_quota_sync+0x41b/0x4a0 fs/gfs2/quota.c:1361
 gfs2_sync_fs+0x4d/0xc0 fs/gfs2/super.c:670
 sync_filesystem+0xed/0x230 fs/sync.c:56
 generic_shutdown_super+0x72/0x2d0 fs/super.c:621
 kill_block_super+0x44/0x90 fs/super.c:1710
 deactivate_locked_super+0xc4/0x130 fs/super.c:473
 cleanup_mnt+0x41f/0x4b0 fs/namespace.c:1413
 task_work_run+0x24f/0x310 kernel/task_work.c:227
 exit_task_work include/linux/task_work.h:40 [inline]
 do_exit+0xa2a/0x2940 kernel/exit.c:938
 do_group_exit+0x207/0x2c0 kernel/exit.c:1087
 __do_sys_exit_group kernel/exit.c:1098 [inline]
 __se_sys_exit_group kernel/exit.c:1096 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1096
 x64_sys_call+0x26a8/0x26b0 arch/x86/include/generated/asm/syscalls_64.h:232
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888044dcc000
 which belongs to the cache gfs2_quotad of size 272
The buggy address is located 128 bytes inside of
 freed 272-byte region [ffff888044dcc000, ffff888044dcc110)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x44dcc
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 04fff00000000000 ffff88803371b8c0 dead000000000122 0000000000000000
raw: 0000000000000000 00000000800c000c 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x52c50(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_RECLAIMABLE), pid 5323, tgid 5322 (syz.0.0), ts 79045710686, free_ts 0
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f4/0x240 mm/page_alloc.c:1551
 prep_new_page mm/page_alloc.c:1559 [inline]
 get_page_from_freelist+0x365c/0x37a0 mm/page_alloc.c:3477
 __alloc_frozen_pages_noprof+0x292/0x710 mm/page_alloc.c:4740
 alloc_pages_mpol+0x311/0x660 mm/mempolicy.c:2270
 alloc_slab_page mm/slub.c:2423 [inline]
 allocate_slab+0x8f/0x3a0 mm/slub.c:2587
 new_slab mm/slub.c:2640 [inline]
 ___slab_alloc+0xc27/0x14a0 mm/slub.c:3826
 __slab_alloc+0x58/0xa0 mm/slub.c:3916
 __slab_alloc_node mm/slub.c:3991 [inline]
 slab_alloc_node mm/slub.c:4152 [inline]
 kmem_cache_alloc_noprof+0x268/0x380 mm/slub.c:4171
 qd_alloc+0x51/0x250 fs/gfs2/quota.c:234
 gfs2_quota_init+0x81a/0x1420 fs/gfs2/quota.c:1448
 gfs2_make_fs_rw+0x43f/0x5e0 fs/gfs2/super.c:159
 gfs2_fill_super+0x246f/0x2700 fs/gfs2/ops_fstype.c:1274
 get_tree_bdev_flags+0x48c/0x5c0 fs/super.c:1636
 gfs2_get_tree+0x54/0x220 fs/gfs2/ops_fstype.c:1330
 vfs_get_tree+0x90/0x2b0 fs/super.c:1814
 do_new_mount+0x2be/0xb40 fs/namespace.c:3560
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888044dcbf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888044dcc000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888044dcc080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff888044dcc100: fb fb fc fc fc fc fc fc fc fc 00 00 00 00 00 00
 ffff888044dcc180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/03/21 21:27 upstream d07de43e3f05 c6512ef7 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Read in list_lru_del
2025/02/20 22:50 upstream e9a8cac0bf89 0808a665 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Read in list_lru_del
2025/02/06 06:31 upstream 92514ef226f5 577d049b .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Read in list_lru_del
2025/03/01 18:44 upstream 03d38806a902 c3901742 .config console log report syz / log [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs BUG: corrupted list in list_lru_del
2025/02/19 02:47 upstream 6537cfb395f3 9a14138f .config console log report syz / log [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs BUG: corrupted list in list_lru_del
2025/02/06 13:59 upstream 92514ef226f5 1e1faf27 .config console log report syz / log [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro] ci-snapshot-upstream-root BUG: corrupted list in list_lru_del
* Struck through repros no longer work on HEAD.