================================================================== BUG: KASAN: slab-use-after-free in key_put+0xea/0x230 security/keys/key.c:656 Read of size 8 at addr ffff8880282707c0 by task syz.0.482/8927 CPU: 1 UID: 0 PID: 8927 Comm: syz.0.482 Not tainted 6.12.0-rc1-next-20241001-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 key_put+0xea/0x230 security/keys/key.c:656 __key_create_or_update+0xaf4/0xc70 security/keys/key.c:940 key_create_or_update+0x42/0x60 security/keys/key.c:1018 __do_sys_add_key security/keys/keyctl.c:134 [inline] __se_sys_add_key+0x33f/0x490 security/keys/keyctl.c:74 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fe03277dff9 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:00007fe03356e038 EFLAGS: 00000246 ORIG_RAX: 00000000000000f8 RAX: ffffffffffffffda RBX: 00007fe032935f80 RCX: 00007fe03277dff9 RDX: 0000000020000100 RSI: 0000000020000180 RDI: 0000000020000140 RBP: 00007fe0327f0296 R08: fffffffffffffffe R09: 0000000000000000 R10: 00000000000000ca R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fe032935f80 R15: 00007ffd8acb3418 Allocated by task 8927: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 unpoison_slab_object mm/kasan/common.c:319 [inline] __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:345 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4086 [inline] slab_alloc_node mm/slub.c:4135 [inline] kmem_cache_alloc_noprof+0x135/0x2a0 mm/slub.c:4142 key_alloc+0x341/0xff0 security/keys/key.c:277 __key_create_or_update+0xa55/0xc70 security/keys/key.c:930 key_create_or_update+0x42/0x60 security/keys/key.c:1018 __do_sys_add_key security/keys/keyctl.c:134 [inline] __se_sys_add_key+0x33f/0x490 security/keys/keyctl.c:74 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 8: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2343 [inline] slab_free mm/slub.c:4580 [inline] kmem_cache_free+0x1a2/0x420 mm/slub.c:4682 key_gc_unused_keys+0x389/0x400 security/keys/gc.c:167 key_garbage_collector+0x8b5/0xa00 security/keys/gc.c:300 process_one_work kernel/workqueue.c:3229 [inline] process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310 worker_thread+0x870/0xd30 kernel/workqueue.c:3391 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 The buggy address belongs to the object at ffff888028270700 which belongs to the cache key_jar of size 336 The buggy address is located 192 bytes inside of freed 336-byte region [ffff888028270700, ffff888028270850) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880282708c0 pfn:0x28270 head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000040 ffff88801be88140 dead000000000122 0000000000000000 raw: ffff8880282708c0 0000000080120011 00000001f5000000 0000000000000000 head: 00fff00000000040 ffff88801be88140 dead000000000122 0000000000000000 head: ffff8880282708c0 0000000080120011 00000001f5000000 0000000000000000 head: 00fff00000000001 ffffea0000a09c01 ffffffffffffffff 0000000000000000 head: 0000000000000002 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 8288, tgid 8282 (syz.3.397), ts 477513153137, free_ts 476083959872 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1537 prep_new_page mm/page_alloc.c:1545 [inline] get_page_from_freelist+0x3129/0x3270 mm/page_alloc.c:3493 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4769 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265 alloc_slab_page+0x6a/0x120 mm/slub.c:2413 allocate_slab+0x5a/0x2f0 mm/slub.c:2579 new_slab mm/slub.c:2632 [inline] ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3819 __slab_alloc+0x58/0xa0 mm/slub.c:3909 __slab_alloc_node mm/slub.c:3962 [inline] slab_alloc_node mm/slub.c:4123 [inline] kmem_cache_alloc_noprof+0x1c1/0x2a0 mm/slub.c:4142 key_alloc+0x341/0xff0 security/keys/key.c:277 keyring_alloc+0x44/0xb0 security/keys/keyring.c:526 install_process_keyring_to_cred security/keys/process_keys.c:275 [inline] install_process_keyring security/keys/process_keys.c:300 [inline] lookup_user_key+0x54d/0x1500 security/keys/process_keys.c:653 __do_sys_add_key security/keys/keyctl.c:126 [inline] __se_sys_add_key+0x2fa/0x490 security/keys/keyctl.c:74 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f page last free pid 8277 tgid 8277 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1108 [inline] free_unref_page+0xcfb/0xf20 mm/page_alloc.c:2674 mm_free_pgd kernel/fork.c:802 [inline] __mmdrop+0xb9/0x3d0 kernel/fork.c:918 exec_mmap+0x680/0x710 fs/exec.c:1014 begin_new_exec+0x12c0/0x2050 fs/exec.c:1280 load_elf_binary+0x966/0x2710 fs/binfmt_elf.c:996 search_binary_handler fs/exec.c:1752 [inline] exec_binprm fs/exec.c:1794 [inline] bprm_execve+0xaf8/0x1770 fs/exec.c:1845 do_execveat_common+0x55f/0x6f0 fs/exec.c:1952 do_execve fs/exec.c:2026 [inline] __do_sys_execve fs/exec.c:2102 [inline] __se_sys_execve fs/exec.c:2097 [inline] __x64_sys_execve+0x92/0xb0 fs/exec.c:2097 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff888028270680: fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888028270700: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888028270780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888028270800: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc ffff888028270880: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb ==================================================================