syzbot


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

Status: fixed on 2023/06/08 14:41
Subsystems: xfs
[Documentation on labels]
Reported-by: syzbot+898115bc6d7140437215@syzkaller.appspotmail.com
Fix commit: dd07bb8b6baf xfs: revert commit 8954c44ff477
First crash: 443d, last: 435d
Discussions (4)
Title Replies (including bot) Last reply
[ANNOUNCE] xfs-linux: for-next updated to 6e2985c938e8 1 (1) 2023/02/27 17:10
[ANNOUNCE] xfs-linux: for-next updated to 60b730a40c43 1 (1) 2023/02/16 17:13
[ANNOUNCE] xfs-linux: for-next updated to dd07bb8b6baf 1 (1) 2023/02/10 17:12
[syzbot] [xfs?] KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent 0 (1) 2023/02/10 06:29

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in strscpy+0x23b/0x2a0 lib/string.c:174
Read of size 1 at addr ffff88803bdab115 by task syz-executor.3/7590

CPU: 1 PID: 7590 Comm: syz-executor.3 Not tainted 6.2.0-rc7-next-20230208-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:319
 print_report mm/kasan/report.c:430 [inline]
 kasan_report+0x11c/0x130 mm/kasan/report.c:536
 strscpy+0x23b/0x2a0 lib/string.c:174
 strscpy include/linux/fortify-string.h:328 [inline]
 __xfs_xattr_put_listent+0x161/0x220 fs/xfs/xfs_xattr.c:215
 xfs_xattr_put_listent+0xed/0x1b0 fs/xfs/xfs_xattr.c:273
 xfs_attr_shortform_list fs/xfs/xfs_attr_list.c:182 [inline]
 xfs_attr_list_ilocked+0x129d/0x1940 fs/xfs/xfs_attr_list.c:516
 xfs_attr_list+0x1fb/0x2c0 fs/xfs/xfs_attr_list.c:536
 xfs_vn_listxattr+0xec/0x180 fs/xfs/xfs_xattr.c:299
 vfs_listxattr+0x109/0x190 fs/xattr.c:473
 ovl_listxattr+0x77/0x330 fs/overlayfs/inode.c:434
 vfs_listxattr+0x109/0x190 fs/xattr.c:473
 ovl_copy_xattr+0x1bd/0xc90 fs/overlayfs/copy_up.c:99
 ovl_copy_up_metadata+0x191/0x960 fs/overlayfs/copy_up.c:616
 ovl_copy_up_workdir fs/overlayfs/copy_up.c:733 [inline]
 ovl_do_copy_up fs/overlayfs/copy_up.c:879 [inline]
 ovl_copy_up_one+0xa6d/0x2cc0 fs/overlayfs/copy_up.c:1049
 ovl_copy_up_flags+0x150/0x1d0 fs/overlayfs/copy_up.c:1095
 ovl_rename+0x28d/0x1770 fs/overlayfs/dir.c:1139
 vfs_rename+0xef6/0x17a0 fs/namei.c:4772
 do_renameat2+0xb62/0xc90 fs/namei.c:4923
 __do_sys_rename fs/namei.c:4969 [inline]
 __se_sys_rename fs/namei.c:4967 [inline]
 __x64_sys_rename+0x81/0xa0 fs/namei.c:4967
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f37f9e8c0f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f37fac05168 EFLAGS: 00000246 ORIG_RAX: 0000000000000052
RAX: ffffffffffffffda RBX: 00007f37f9fac050 RCX: 00007f37f9e8c0f9
RDX: 0000000000000000 RSI: 0000000020000440 RDI: 0000000020000100
RBP: 00007f37f9ee7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffcba90580f R14: 00007f37fac05300 R15: 0000000000022000
 </TASK>

Allocated by task 7575:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 ____kasan_kmalloc mm/kasan/common.c:333 [inline]
 __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:196 [inline]
 __do_kmalloc_node mm/slab_common.c:967 [inline]
 __kmalloc_node_track_caller+0x5b/0xc0 mm/slab_common.c:987
 __do_krealloc mm/slab_common.c:1364 [inline]
 krealloc+0x5e/0x100 mm/slab_common.c:1397
 xfs_idata_realloc+0xcc/0x280 fs/xfs/libxfs/xfs_inode_fork.c:503
 xfs_attr_shortform_add+0x23b/0x930 fs/xfs/libxfs/xfs_attr_leaf.c:775
 xfs_attr_shortform_addname+0x3bf/0x610 fs/xfs/libxfs/xfs_attr.c:1158
 xfs_attr_try_sf_addname+0x6b/0x240 fs/xfs/libxfs/xfs_attr.c:358
 xfs_attr_sf_addname fs/xfs/libxfs/xfs_attr.c:383 [inline]
 xfs_attr_set_iter+0x17dd/0x3930 fs/xfs/libxfs/xfs_attr.c:719
 xfs_xattri_finish_update+0x3c/0x140 fs/xfs/xfs_attr_item.c:332
 xfs_attr_finish_item+0x6d/0x280 fs/xfs/xfs_attr_item.c:463
 xfs_defer_finish_one fs/xfs/libxfs/xfs_defer.c:479 [inline]
 xfs_defer_finish_noroll+0xac5/0x2430 fs/xfs/libxfs/xfs_defer.c:563
 __xfs_trans_commit+0x82b/0x1100 fs/xfs/xfs_trans.c:970
 xfs_attr_set+0x13ac/0x2650 fs/xfs/libxfs/xfs_attr.c:1083
 xfs_attr_change fs/xfs/xfs_xattr.c:106 [inline]
 xfs_xattr_set+0xf2/0x1c0 fs/xfs/xfs_xattr.c:151
 __vfs_setxattr+0x173/0x1e0 fs/xattr.c:203
 __vfs_setxattr_noperm+0x129/0x5f0 fs/xattr.c:237
 __vfs_setxattr_locked+0x1d3/0x260 fs/xattr.c:298
 vfs_setxattr+0x143/0x340 fs/xattr.c:324
 ovl_do_setxattr fs/overlayfs/overlayfs.h:255 [inline]
 ovl_setxattr fs/overlayfs/overlayfs.h:267 [inline]
 ovl_check_setxattr+0x183/0x350 fs/overlayfs/util.c:641
 ovl_set_origin+0xed/0x140 fs/overlayfs/copy_up.c:450
 ovl_copy_up_metadata+0x5e0/0x960 fs/overlayfs/copy_up.c:638
 ovl_copy_up_workdir fs/overlayfs/copy_up.c:733 [inline]
 ovl_do_copy_up fs/overlayfs/copy_up.c:879 [inline]
 ovl_copy_up_one+0xa6d/0x2cc0 fs/overlayfs/copy_up.c:1049
 ovl_copy_up_flags+0x150/0x1d0 fs/overlayfs/copy_up.c:1095
 ovl_setattr+0x111/0x520 fs/overlayfs/inode.c:45
 notify_change+0xb2c/0x1180 fs/attr.c:482
 chown_common+0x57f/0x650 fs/open.c:738
 do_fchownat+0x12a/0x1e0 fs/open.c:769
 __do_sys_chown fs/open.c:789 [inline]
 __se_sys_chown fs/open.c:787 [inline]
 __x64_sys_chown+0x7b/0xc0 fs/open.c:787
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88803bdab100
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes to the right of
 allocated 21-byte region [ffff88803bdab100, ffff88803bdab115)

The buggy address belongs to the physical page:
page:ffffea0000ef6ac0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x3bdab
anon flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffff888012441500 0000000000000000 dead000000000001
raw: 0000000000000000 0000000080400040 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 9796, tgid 9792 (syz-executor.5), ts 658676476773, free_ts 658583156283
 prep_new_page mm/page_alloc.c:2552 [inline]
 get_page_from_freelist+0x11bb/0x2d50 mm/page_alloc.c:4339
 __alloc_pages+0x1cb/0x5c0 mm/page_alloc.c:5605
 alloc_pages+0x1aa/0x270 mm/mempolicy.c:2283
 alloc_slab_page mm/slub.c:1851 [inline]
 allocate_slab+0x28e/0x380 mm/slub.c:1998
 new_slab mm/slub.c:2051 [inline]
 ___slab_alloc+0xa91/0x1400 mm/slub.c:3193
 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3292
 __slab_alloc_node mm/slub.c:3345 [inline]
 slab_alloc_node mm/slub.c:3442 [inline]
 __kmem_cache_alloc_node+0x136/0x330 mm/slub.c:3491
 kmalloc_trace+0x26/0x60 mm/slab_common.c:1061
 kmalloc include/linux/slab.h:580 [inline]
 kzalloc include/linux/slab.h:720 [inline]
 ref_tracker_alloc+0x158/0x580 lib/ref_tracker.c:85
 __netdev_tracker_alloc include/linux/netdevice.h:4038 [inline]
 netdev_hold include/linux/netdevice.h:4067 [inline]
 netdev_hold include/linux/netdevice.h:4062 [inline]
 neigh_parms_alloc+0x25d/0x5f0 net/core/neighbour.c:1743
 ipv6_add_dev+0x331/0x13b0 net/ipv6/addrconf.c:393
 addrconf_notify+0x63d/0x19f0 net/ipv6/addrconf.c:3552
 notifier_call_chain+0xb5/0x200 kernel/notifier.c:87
 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1945
 call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
 call_netdevice_notifiers net/core/dev.c:1997 [inline]
 register_netdevice+0xfb4/0x1640 net/core/dev.c:10084
 register_netdev+0x31/0x50 net/core/dev.c:10179
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1453 [inline]
 free_pcp_prepare+0x4d0/0x910 mm/page_alloc.c:1503
 free_unref_page_prepare mm/page_alloc.c:3401 [inline]
 free_unref_page_list+0x176/0xcd0 mm/page_alloc.c:3542
 release_pages+0xcb1/0x1330 mm/swap.c:1072
 tlb_batch_pages_flush+0xa8/0x1a0 mm/mmu_gather.c:97
 tlb_flush_mmu_free mm/mmu_gather.c:292 [inline]
 tlb_flush_mmu mm/mmu_gather.c:299 [inline]
 tlb_finish_mmu+0x14b/0x7e0 mm/mmu_gather.c:391
 exit_mmap+0x205/0x7d0 mm/mmap.c:3047
 __mmput+0x128/0x4c0 kernel/fork.c:1209
 mmput+0x60/0x70 kernel/fork.c:1231
 exit_mm kernel/exit.c:563 [inline]
 do_exit+0x9d7/0x2b60 kernel/exit.c:856
 do_group_exit+0xd4/0x2a0 kernel/exit.c:1019
 get_signal+0x2321/0x25b0 kernel/signal.c:2859
 arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306
 exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
 exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
 syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff88803bdab000: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc
 ffff88803bdab080: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
>ffff88803bdab100: 00 00 05 fc fc fc fc fc fa fb fb fb fc fc fc fc
                         ^
 ffff88803bdab180: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc
 ffff88803bdab200: 00 00 00 fc fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/02/14 10:47 linux-next 38d2b86a665b 93ae7e0a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/14 10:21 linux-next 38d2b86a665b 93ae7e0a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/14 10:10 linux-next 38d2b86a665b 93ae7e0a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/13 21:44 linux-next 38d2b86a665b 4d66ad72 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/13 21:38 linux-next 38d2b86a665b 4d66ad72 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/13 21:37 linux-next 38d2b86a665b 4d66ad72 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/13 21:37 linux-next 38d2b86a665b 4d66ad72 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/12 21:32 linux-next 38d2b86a665b 93e26d60 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/12 03:44 linux-next 38d2b86a665b 93e26d60 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/11 02:22 linux-next 38d2b86a665b 95871dcc .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/11 02:22 linux-next 38d2b86a665b 95871dcc .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
2023/02/06 05:28 linux-next 129af7708234 be607b78 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: slab-out-of-bounds Read in __xfs_xattr_put_listent
* Struck through repros no longer work on HEAD.