================================================================== BUG: KASAN: use-after-free in kernfs_type include/linux/kernfs.h:335 [inline] BUG: KASAN: use-after-free in kernfs_leftmost_descendant fs/kernfs/dir.c:1261 [inline] BUG: KASAN: use-after-free in __kernfs_remove+0xf2d/0x1180 fs/kernfs/dir.c:1369 Read of size 2 at addr ffff8881456ee098 by task syz-executor619/3646 CPU: 1 PID: 3646 Comm: syz-executor619 Not tainted 6.0.0-rc7-syzkaller-00220-gffb4d94b4314 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 print_address_description+0x65/0x4b0 mm/kasan/report.c:317 print_report+0x108/0x220 mm/kasan/report.c:433 kasan_report+0xfb/0x130 mm/kasan/report.c:495 kernfs_type include/linux/kernfs.h:335 [inline] kernfs_leftmost_descendant fs/kernfs/dir.c:1261 [inline] __kernfs_remove+0xf2d/0x1180 fs/kernfs/dir.c:1369 kernfs_remove_by_name_ns+0x96/0xe0 fs/kernfs/dir.c:1589 sysfs_slab_add+0x54/0x2a0 mm/slub.c:5955 __kmem_cache_create+0x34/0x170 mm/slub.c:4906 create_cache mm/slab_common.c:229 [inline] kmem_cache_create_usercopy+0x1a6/0x340 mm/slab_common.c:335 p9_client_create+0xbbe/0x1030 net/9p/client.c:993 v9fs_session_init+0x1e3/0x1990 fs/9p/v9fs.c:408 v9fs_mount+0xd2/0xcb0 fs/9p/vfs_super.c:126 legacy_get_tree+0xea/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1530 do_new_mount+0x289/0xad0 fs/namespace.c:3040 do_mount fs/namespace.c:3383 [inline] __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3568 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fb782fc70b9 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 c0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffede7f6e18 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007ffede7f6e50 RCX: 00007fb782fc70b9 RDX: 00000000200001c0 RSI: 0000000020000040 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000020000300 R09: 000000000000c567 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000000f4240 R13: 000000000000c567 R14: 00007ffede7f6e3c R15: 00007ffede7f6e40 Allocated by task 3645: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:437 [inline] __kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:470 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:727 [inline] slab_alloc_node mm/slub.c:3248 [inline] slab_alloc mm/slub.c:3256 [inline] __kmem_cache_alloc_lru mm/slub.c:3263 [inline] kmem_cache_alloc+0x1a6/0x310 mm/slub.c:3273 kmem_cache_zalloc include/linux/slab.h:723 [inline] __kernfs_new_node+0xdb/0x730 fs/kernfs/dir.c:593 kernfs_new_node fs/kernfs/dir.c:655 [inline] kernfs_create_dir_ns+0x90/0x220 fs/kernfs/dir.c:1010 sysfs_create_dir_ns+0x181/0x390 fs/sysfs/dir.c:59 create_dir lib/kobject.c:63 [inline] kobject_add_internal+0x6dd/0xd10 lib/kobject.c:223 kobject_add_varg lib/kobject.c:358 [inline] kobject_init_and_add+0x123/0x190 lib/kobject.c:441 sysfs_slab_add+0x80/0x2a0 mm/slub.c:5968 __kmem_cache_create+0x34/0x170 mm/slub.c:4906 create_cache mm/slab_common.c:229 [inline] kmem_cache_create_usercopy+0x1a6/0x340 mm/slab_common.c:335 p9_client_create+0xbbe/0x1030 net/9p/client.c:993 v9fs_session_init+0x1e3/0x1990 fs/9p/v9fs.c:408 v9fs_mount+0xd2/0xcb0 fs/9p/vfs_super.c:126 legacy_get_tree+0xea/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1530 do_new_mount+0x289/0xad0 fs/namespace.c:3040 do_mount fs/namespace.c:3383 [inline] __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3568 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 3646: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4c/0x70 mm/kasan/common.c:45 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:367 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1759 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1785 slab_free mm/slub.c:3539 [inline] kmem_cache_free+0x95/0x1d0 mm/slub.c:3556 kernfs_put+0x340/0x490 fs/kernfs/dir.c:547 __kernfs_remove+0xec0/0x1180 fs/kernfs/dir.c:1407 kernfs_remove_by_name_ns+0x96/0xe0 fs/kernfs/dir.c:1589 sysfs_slab_add+0x54/0x2a0 mm/slub.c:5955 __kmem_cache_create+0x34/0x170 mm/slub.c:4906 create_cache mm/slab_common.c:229 [inline] kmem_cache_create_usercopy+0x1a6/0x340 mm/slab_common.c:335 p9_client_create+0xbbe/0x1030 net/9p/client.c:993 v9fs_session_init+0x1e3/0x1990 fs/9p/v9fs.c:408 v9fs_mount+0xd2/0xcb0 fs/9p/vfs_super.c:126 legacy_get_tree+0xea/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1530 do_new_mount+0x289/0xad0 fs/namespace.c:3040 do_mount fs/namespace.c:3383 [inline] __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3568 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff8881456ee000 which belongs to the cache kernfs_node_cache of size 168 The buggy address is located 152 bytes inside of 168-byte region [ffff8881456ee000, ffff8881456ee0a8) The buggy address belongs to the physical page: page:ffffea000515bb80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1456ee flags: 0x57ff00000000200(slab|node=1|zone=2|lastcpupid=0x7ff) raw: 057ff00000000200 ffffea000515bc00 dead000000000003 ffff8880121dbc80 raw: 0000000000000000 0000000000110011 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, tgid 1 (swapper/0), ts 2137211527, free_ts 0 prep_new_page mm/page_alloc.c:2532 [inline] get_page_from_freelist+0x72b/0x7a0 mm/page_alloc.c:4283 __alloc_pages+0x259/0x560 mm/page_alloc.c:5549 alloc_page_interleave+0x22/0x1c0 mm/mempolicy.c:2103 alloc_slab_page+0x70/0xf0 mm/slub.c:1829 allocate_slab+0x5e/0x520 mm/slub.c:1974 new_slab mm/slub.c:2034 [inline] ___slab_alloc+0x42e/0xce0 mm/slub.c:3036 __slab_alloc mm/slub.c:3123 [inline] slab_alloc_node mm/slub.c:3214 [inline] slab_alloc mm/slub.c:3256 [inline] __kmem_cache_alloc_lru mm/slub.c:3263 [inline] kmem_cache_alloc+0x25d/0x310 mm/slub.c:3273 kmem_cache_zalloc include/linux/slab.h:723 [inline] __kernfs_new_node+0xdb/0x730 fs/kernfs/dir.c:593 kernfs_new_node+0x95/0x160 fs/kernfs/dir.c:655 __kernfs_create_file+0x45/0x2e0 fs/kernfs/file.c:1050 sysfs_add_file_mode_ns+0x21d/0x330 fs/sysfs/file.c:294 create_files fs/sysfs/group.c:64 [inline] internal_create_group+0x55c/0xf50 fs/sysfs/group.c:148 kernel_add_sysfs_param+0xe8/0x126 kernel/params.c:814 param_sysfs_builtin+0x16a/0x1e2 kernel/params.c:851 param_sysfs_init+0x68/0x6c kernel/params.c:970 do_one_initcall+0xbd/0x2b0 init/main.c:1296 page_owner free stack trace missing Memory state around the buggy address: ffff8881456edf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8881456ee000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881456ee080: fb fb fb fb fb fc fc fc fc fc fc fc fc 00 00 00 ^ ffff8881456ee100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8881456ee180: 00 00 fc fc fc fc fc fc fc fc 00 00 00 00 00 00 ==================================================================