syzbot


KASAN: use-after-free Read in lockref_put_or_lock

Status: upstream: reported on 2025/04/22 22:06
Reported-by: syzbot+d601919f47cdae876037@syzkaller.appspotmail.com
First crash: 83d, last: 36d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x74/0x1ff0 kernel/locking/lockdep.c:4882
Read of size 8 at addr ffff888058ca5048 by task syz.2.674/6517

CPU: 0 PID: 6517 Comm: syz.2.674 Not tainted 5.15.180-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 __lock_acquire+0x74/0x1ff0 kernel/locking/lockdep.c:4882
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
 _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
 spin_lock include/linux/spinlock.h:363 [inline]
 lockref_put_or_lock+0x22/0xb0 lib/lockref.c:173
 qd_put fs/gfs2/quota.c:309 [inline]
 gfs2_set_dqblk+0x47e/0xd00 fs/gfs2/quota.c:1780
 quota_setquota+0x6d3/0x840 fs/quota/quota.c:309
 __do_sys_quotactl fs/quota/quota.c:959 [inline]
 __se_sys_quotactl+0x2b1/0x770 fs/quota/quota.c:915
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0x80 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7ff60761c969
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ff605463038 EFLAGS: 00000246 ORIG_RAX: 00000000000000b3
RAX: ffffffffffffffda RBX: 00007ff607844080 RCX: 00007ff60761c969
RDX: 0000000000000000 RSI: 0000200000001a80 RDI: ffffffff80000801
RBP: 00007ff60769eab1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000200000006140 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000001 R14: 00007ff607844080 R15: 00007ffd303aafa8
 </TASK>

Allocated by task 6432:
 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+0x8e/0xc0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 kmem_cache_zalloc include/linux/slab.h:725 [inline]
 qd_alloc+0x51/0x250 fs/gfs2/quota.c:216
 gfs2_quota_init+0x7ea/0x1110 fs/gfs2/quota.c:1426
 gfs2_make_fs_rw+0x436/0x5b0 fs/gfs2/super.c:155
 gfs2_fill_super+0x23e8/0x2750 fs/gfs2/ops_fstype.c:1276
 get_tree_bdev+0x3fe/0x620 fs/super.c:1325
 gfs2_get_tree+0x50/0x210 fs/gfs2/ops_fstype.c:1332
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x2ba/0xb40 fs/namespace.c:3012
 do_mount fs/namespace.c:3355 [inline]
 __do_sys_mount fs/namespace.c:3563 [inline]
 __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3540
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0x80 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 6432:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kmem_cache_free+0x91/0x1f0 mm/slub.c:3515
 rcu_do_batch kernel/rcu/tree.c:2523 [inline]
 rcu_core+0xa15/0x1650 kernel/rcu/tree.c:2763
 handle_softirqs+0x3a7/0x930 kernel/softirq.c:558
 __do_softirq kernel/softirq.c:592 [inline]
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x157/0x240 kernel/softirq.c:641
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:653
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1108 [inline]
 sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1108
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:676

Last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:3007 [inline]
 call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3087
 gfs2_quota_cleanup+0x43e/0x6a0 fs/gfs2/quota.c:1490
 gfs2_make_fs_ro+0x4ad/0x5f0 fs/gfs2/super.c:557
 signal_our_withdraw fs/gfs2/util.c:166 [inline]
 gfs2_withdraw+0x5fb/0x14e0 fs/gfs2/util.c:343
 gfs2_dirent_scan+0x512/0x640 fs/gfs2/dir.c:602
 gfs2_dirent_search+0x30a/0x8c0 fs/gfs2/dir.c:850
 gfs2_dir_search+0xae/0x2f0 fs/gfs2/dir.c:1651
 gfs2_lookupi+0x45b/0x5e0 fs/gfs2/inode.c:332
 __gfs2_lookup+0xa0/0x270 fs/gfs2/inode.c:873
 gfs2_atomic_open+0x9a/0x220 fs/gfs2/inode.c:1277
 atomic_open fs/namei.c:3325 [inline]
 lookup_open fs/namei.c:3433 [inline]
 open_last_lookups fs/namei.c:3532 [inline]
 path_openat+0xf75/0x2f20 fs/namei.c:3739
 do_filp_open+0x21c/0x460 fs/namei.c:3769
 do_sys_openat2+0x13b/0x4f0 fs/open.c:1253
 do_sys_open fs/open.c:1269 [inline]
 __do_sys_openat fs/open.c:1285 [inline]
 __se_sys_openat fs/open.c:1280 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1280
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0x80 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff888058ca5000
 which belongs to the cache gfs2_quotad of size 272
The buggy address is located 72 bytes inside of
 272-byte region [ffff888058ca5000, ffff888058ca5110)
The buggy address belongs to the page:
page:ffffea0001632940 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x58ca5
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff8881466cdc80
raw: 0000000000000000 00000000800c000c 00000001ffffffff 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 0x112c50(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 6432, ts 201004855383, free_ts 199360972633
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5466
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x18e/0x280 mm/slub.c:3233
 kmem_cache_zalloc include/linux/slab.h:725 [inline]
 qd_alloc+0x51/0x250 fs/gfs2/quota.c:216
 gfs2_quota_init+0x7ea/0x1110 fs/gfs2/quota.c:1426
 gfs2_make_fs_rw+0x436/0x5b0 fs/gfs2/super.c:155
 gfs2_fill_super+0x23e8/0x2750 fs/gfs2/ops_fstype.c:1276
 get_tree_bdev+0x3fe/0x620 fs/super.c:1325
 gfs2_get_tree+0x50/0x210 fs/gfs2/ops_fstype.c:1332
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x2ba/0xb40 fs/namespace.c:3012
 do_mount fs/namespace.c:3355 [inline]
 __do_sys_mount fs/namespace.c:3563 [inline]
 __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3540
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0x80 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 free_slab mm/slub.c:2015 [inline]
 discard_slab mm/slub.c:2021 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
 put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 getname_flags+0xb8/0x4e0 fs/namei.c:138
 user_path_at_empty+0x2a/0x180 fs/namei.c:2882
 user_path_at include/linux/namei.h:57 [inline]
 ksys_umount fs/namespace.c:1779 [inline]
 __do_sys_umount fs/namespace.c:1787 [inline]
 __se_sys_umount fs/namespace.c:1785 [inline]
 __x64_sys_umount+0xf0/0x170 fs/namespace.c:1785
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0x80 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
 ffff888058ca4f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888058ca4f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888058ca5000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff888058ca5080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888058ca5100: fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/04/25 07:03 linux-5.15.y f7347f400572 e3715315 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in lockref_put_or_lock
2025/04/22 22:06 linux-5.15.y f7347f400572 53a8b9bd .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in lockref_put_or_lock
2025/06/09 16:48 linux-5.15.y 1c700860e8bc 4826c28e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in lockref_put_or_lock
* Struck through repros no longer work on HEAD.