syzbot


KASAN: use-after-free Read in gfs2_quota_unhold

Status: upstream: reported on 2024/12/22 15:10
Reported-by: syzbot+a6015d2577b15c580ff4@syzkaller.appspotmail.com
First crash: 5h24m, last: 5h20m

Sample crash report:
RBP: 00007feb76353aa8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007feb764c7fa0 R15: 00007ffe0412ea68
 </TASK>
==================================================================
BUG: KASAN: use-after-free in bh_put fs/gfs2/quota.c:414 [inline]
BUG: KASAN: use-after-free in qdsb_put fs/gfs2/quota.c:533 [inline]
BUG: KASAN: use-after-free in gfs2_quota_unhold+0x17a/0x5d0 fs/gfs2/quota.c:652
Read of size 8 at addr ffff88805b52b0c8 by task syz.0.592/6599

CPU: 1 PID: 6599 Comm: syz.0.592 Not tainted 5.15.175-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
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
 bh_put fs/gfs2/quota.c:414 [inline]
 qdsb_put fs/gfs2/quota.c:533 [inline]
 gfs2_quota_unhold+0x17a/0x5d0 fs/gfs2/quota.c:652
 gfs2_quota_lock+0x3ea/0x450 fs/gfs2/quota.c:1095
 gfs2_quota_lock_check fs/gfs2/quota.h:50 [inline]
 alloc_dinode+0x1c9/0x580 fs/gfs2/inode.c:402
 gfs2_create_inode+0xfc4/0x1ba0 fs/gfs2/inode.c:720
 gfs2_atomic_open+0xe1/0x220 fs/gfs2/inode.c:1295
 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/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7feb762d7d29
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:00007feb74148038 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007feb764c7fa0 RCX: 00007feb762d7d29
RDX: 000000000000275a RSI: 0000000020000000 RDI: ffffffffffffff9c
RBP: 00007feb76353aa8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007feb764c7fa0 R15: 00007ffe0412ea68
 </TASK>

Allocated by task 6599:
 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:711 [inline]
 qd_alloc+0x51/0x250 fs/gfs2/quota.c:216
 qd_get+0x23f/0x5c0 fs/gfs2/quota.c:275
 qdsb_get+0x2a/0x3b0 fs/gfs2/quota.c:510
 gfs2_quota_hold+0x19d/0x5c0 fs/gfs2/quota.c:604
 gfs2_quota_lock+0x9f/0x450 fs/gfs2/quota.c:1076
 gfs2_quota_lock_check fs/gfs2/quota.h:50 [inline]
 alloc_dinode+0x1c9/0x580 fs/gfs2/inode.c:402
 gfs2_create_inode+0xfc4/0x1ba0 fs/gfs2/inode.c:720
 gfs2_atomic_open+0xe1/0x220 fs/gfs2/inode.c:1295
 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/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 20:
 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
 run_ksoftirqd+0xc6/0x120 kernel/softirq.c:925
 smpboot_thread_fn+0x51b/0x9d0 kernel/smpboot.c:164
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

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_meta_check_ii+0x6e/0x80 fs/gfs2/util.c:498
 gfs2_metatype_check_i fs/gfs2/util.h:126 [inline]
 gfs2_meta_buffer+0x324/0x410 fs/gfs2/meta_io.c:493
 gfs2_meta_inode_buffer fs/gfs2/meta_io.h:70 [inline]
 gfs2_inode_refresh+0xdd/0x1070 fs/gfs2/glops.c:481
 inode_go_lock+0x12c/0x470 fs/gfs2/glops.c:510
 do_promote+0x74b/0xb10 fs/gfs2/glock.c:507
 finish_xmote+0x50d/0xb60 fs/gfs2/glock.c:678
 do_xmote+0x775/0x10b0 fs/gfs2/glock.c:824
 gfs2_glock_nq+0xc32/0x15e0 fs/gfs2/glock.c:1534
 gfs2_glock_nq_init fs/gfs2/glock.h:246 [inline]
 do_glock+0x392/0x730 fs/gfs2/quota.c:1043
 gfs2_quota_lock+0x1fc/0x450 fs/gfs2/quota.c:1085
 gfs2_quota_lock_check fs/gfs2/quota.h:50 [inline]
 alloc_dinode+0x1c9/0x580 fs/gfs2/inode.c:402
 gfs2_create_inode+0xfc4/0x1ba0 fs/gfs2/inode.c:720
 gfs2_atomic_open+0xe1/0x220 fs/gfs2/inode.c:1295
 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/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff88805b52b000
 which belongs to the cache gfs2_quotad of size 272
The buggy address is located 200 bytes inside of
 272-byte region [ffff88805b52b000, ffff88805b52b110)
The buggy address belongs to the page:
page:ffffea00016d4ac0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5b52b
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff888146cc1640
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 6599, ts 184528706637, free_ts 144825932755
 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:5465
 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:711 [inline]
 qd_alloc+0x51/0x250 fs/gfs2/quota.c:216
 qd_get+0x23f/0x5c0 fs/gfs2/quota.c:275
 qdsb_get+0x2a/0x3b0 fs/gfs2/quota.c:510
 gfs2_quota_hold+0x19d/0x5c0 fs/gfs2/quota.c:604
 gfs2_quota_lock+0x9f/0x450 fs/gfs2/quota.c:1076
 gfs2_quota_lock_check fs/gfs2/quota.h:50 [inline]
 alloc_dinode+0x1c9/0x580 fs/gfs2/inode.c:402
 gfs2_create_inode+0xfc4/0x1ba0 fs/gfs2/inode.c:720
 gfs2_atomic_open+0xe1/0x220 fs/gfs2/inode.c:1295
 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
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
 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]
 kmem_cache_alloc_node+0x121/0x2c0 mm/slub.c:3256
 __alloc_skb+0xdd/0x590 net/core/skbuff.c:415
 alloc_skb include/linux/skbuff.h:1162 [inline]
 nlmsg_new include/net/netlink.h:953 [inline]
 inet6_netconf_notify_devconf+0xf8/0x1b0 net/ipv6/addrconf.c:583
 __addrconf_sysctl_unregister net/ipv6/addrconf.c:7124 [inline]
 addrconf_sysctl_unregister net/ipv6/addrconf.c:7148 [inline]
 addrconf_ifdown+0x1879/0x1bb0 net/ipv6/addrconf.c:3931
 addrconf_notify+0x432/0xf30
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
 call_netdevice_notifiers_info net/core/dev.c:2018 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2030 [inline]
 call_netdevice_notifiers net/core/dev.c:2044 [inline]
 unregister_netdevice_many+0xf1b/0x18f0 net/core/dev.c:11102
 default_device_exit_batch+0x390/0x3f0 net/core/dev.c:11635
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x763/0xb60 net/core/net_namespace.c:599

Memory state around the buggy address:
 ffff88805b52af80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88805b52b000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88805b52b080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff88805b52b100: fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb
 ffff88805b52b180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/22 15:14 linux-5.15.y 91786f140358 b4fbdbd4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in gfs2_quota_unhold
2024/12/22 15:12 linux-5.15.y 91786f140358 b4fbdbd4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in gfs2_quota_unhold
2024/12/22 15:10 linux-5.15.y 91786f140358 b4fbdbd4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in gfs2_quota_unhold
* Struck through repros no longer work on HEAD.