================================================================== BUG: KASAN: slab-use-after-free in radix_tree_next_slot include/linux/radix-tree.h:424 [inline] BUG: KASAN: slab-use-after-free in idr_for_each+0x252/0x270 lib/idr.c:202 Read of size 8 at addr ffff88805354a3f0 by task syz.0.13243/4790 CPU: 0 UID: 0 PID: 4790 Comm: syz.0.13243 Tainted: G U 6.14.0-rc2-syzkaller-00039-g09fbf3d50205 #0 Tainted: [U]=USER Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xc3/0x620 mm/kasan/report.c:489 kasan_report+0xd9/0x110 mm/kasan/report.c:602 radix_tree_next_slot include/linux/radix-tree.h:424 [inline] idr_for_each+0x252/0x270 lib/idr.c:202 shm_destroy_orphaned+0x85/0x90 ipc/shm.c:435 proc_ipc_dointvec_minmax_orphans+0xca/0xe0 ipc/ipc_sysctl.c:32 proc_sys_call_handler+0x3c6/0x5a0 fs/proc/proc_sysctl.c:601 new_sync_write fs/read_write.c:586 [inline] vfs_write+0x5ae/0x1150 fs/read_write.c:679 ksys_write+0x12b/0x250 fs/read_write.c:731 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fcfe838cde9 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:00007fcfe9214038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007fcfe85a5fa0 RCX: 00007fcfe838cde9 RDX: 000000000000fdef RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00007fcfe840e2a0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fcfe85a5fa0 R15: 00007ffc477f12e8 Allocated by task 1798: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 unpoison_slab_object mm/kasan/common.c:319 [inline] __kasan_slab_alloc+0x89/0x90 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+0x1c8/0x3b0 mm/slub.c:4171 radix_tree_node_alloc.constprop.0+0x1e8/0x350 lib/radix-tree.c:253 idr_get_free+0x528/0xa40 lib/radix-tree.c:1506 idr_alloc_u32+0x191/0x2f0 lib/idr.c:46 idr_alloc_cyclic+0x10c/0x230 lib/idr.c:125 ipc_idr_alloc ipc/util.c:230 [inline] ipc_addid+0x697/0x1f50 ipc/util.c:305 newseg+0x674/0xe60 ipc/shm.c:775 ipcget_public ipc/util.c:415 [inline] ipcget+0x866/0xd80 ipc/util.c:676 ksys_shmget ipc/shm.c:839 [inline] __do_sys_shmget ipc/shm.c:844 [inline] __se_sys_shmget ipc/shm.c:842 [inline] __x64_sys_shmget+0x13f/0x1b0 ipc/shm.c:842 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 16: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:576 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x51/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+0x2e2/0x4d0 mm/slub.c:4711 rcu_do_batch kernel/rcu/tree.c:2546 [inline] rcu_core+0x79d/0x14d0 kernel/rcu/tree.c:2802 handle_softirqs+0x213/0x8f0 kernel/softirq.c:561 run_ksoftirqd kernel/softirq.c:950 [inline] run_ksoftirqd+0x3a/0x60 kernel/softirq.c:942 smpboot_thread_fn+0x661/0xa30 kernel/smpboot.c:164 kthread+0x3af/0x750 kernel/kthread.c:464 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 Last potentially related work creation: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_record_aux_stack+0xb8/0xd0 mm/kasan/generic.c:548 __call_rcu_common.constprop.0+0x9a/0x870 kernel/rcu/tree.c:3065 radix_tree_node_free lib/radix-tree.c:310 [inline] delete_node+0x1fc/0x8e0 lib/radix-tree.c:573 __radix_tree_delete+0x193/0x3d0 lib/radix-tree.c:1379 radix_tree_delete_item+0xeb/0x230 lib/radix-tree.c:1430 ipc_rmid+0x10b/0x3e0 ipc/util.c:501 shm_rmid ipc/shm.c:275 [inline] shm_destroy+0x2d7/0x6d0 ipc/shm.c:336 shm_try_destroy_orphaned ipc/shm.c:426 [inline] shm_try_destroy_orphaned+0x1a8/0x270 ipc/shm.c:409 idr_for_each+0x141/0x270 lib/idr.c:208 shm_destroy_orphaned+0x85/0x90 ipc/shm.c:435 proc_ipc_dointvec_minmax_orphans+0xca/0xe0 ipc/ipc_sysctl.c:32 proc_sys_call_handler+0x3c6/0x5a0 fs/proc/proc_sysctl.c:601 new_sync_write fs/read_write.c:586 [inline] vfs_write+0x5ae/0x1150 fs/read_write.c:679 ksys_write+0x12b/0x250 fs/read_write.c:731 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88805354a3c0 which belongs to the cache radix_tree_node of size 576 The buggy address is located 48 bytes inside of freed 576-byte region [ffff88805354a3c0, ffff88805354a600) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff8880535498c0 pfn:0x53548 head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 memcg:ffff88802f32c001 flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000240 ffff88801b04fdc0 ffffea00008e6010 ffff88801b04ed08 raw: ffff8880535498c0 0000000000170013 00000000f5000000 ffff88802f32c001 head: 00fff00000000240 ffff88801b04fdc0 ffffea00008e6010 ffff88801b04ed08 head: ffff8880535498c0 0000000000170013 00000000f5000000 ffff88802f32c001 head: 00fff00000000002 ffffea00014d5201 ffffffffffffffff 0000000000000000 head: 0000000000000004 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Reclaimable, gfp_mask 0x52830(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_RECLAIMABLE), pid 15204, tgid 15203 (syz.4.4472), ts 346641279489, free_ts 344707683829 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x181/0x1b0 mm/page_alloc.c:1551 prep_new_page mm/page_alloc.c:1559 [inline] get_page_from_freelist+0xfce/0x2f80 mm/page_alloc.c:3477 __alloc_frozen_pages_noprof+0x221/0x2470 mm/page_alloc.c:4739 alloc_pages_mpol+0x1fc/0x540 mm/mempolicy.c:2270 alloc_slab_page mm/slub.c:2423 [inline] allocate_slab mm/slub.c:2587 [inline] new_slab+0x23d/0x330 mm/slub.c:2640 ___slab_alloc+0xbfa/0x1600 mm/slub.c:3826 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3916 __slab_alloc_node mm/slub.c:3991 [inline] slab_alloc_node mm/slub.c:4152 [inline] kmem_cache_alloc_noprof+0xeb/0x3b0 mm/slub.c:4171 radix_tree_node_alloc.constprop.0+0x1e8/0x350 lib/radix-tree.c:253 idr_get_free+0x528/0xa40 lib/radix-tree.c:1506 idr_alloc_u32+0x191/0x2f0 lib/idr.c:46 idr_alloc_cyclic+0x10c/0x230 lib/idr.c:125 __kernfs_new_node+0x11b/0x890 fs/kernfs/dir.c:630 kernfs_new_node+0x186/0x240 fs/kernfs/dir.c:700 __kernfs_create_file+0x53/0x350 fs/kernfs/file.c:1034 sysfs_add_file_mode_ns+0x1ff/0x3b0 fs/sysfs/file.c:313 page last free pid 15144 tgid 15144 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] free_frozen_pages+0x6db/0xfb0 mm/page_alloc.c:2660 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x4e/0x120 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x195/0x1e0 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:329 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_node_noprof+0x1ca/0x3b0 mm/slub.c:4216 alloc_task_struct_node kernel/fork.c:180 [inline] dup_task_struct kernel/fork.c:1119 [inline] copy_process+0x49c/0x6f20 kernel/fork.c:2233 kernel_clone+0xfd/0x960 kernel/fork.c:2815 __do_sys_clone3+0x1f9/0x270 kernel/fork.c:3119 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff88805354a280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88805354a300: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc >ffff88805354a380: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb ^ ffff88805354a400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88805354a480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================