================================================================== BUG: KASAN: slab-use-after-free in bpf_link_free+0x28d/0x320 kernel/bpf/syscall.c:3078 Read of size 8 at addr ffff888027b80d10 by task syz-executor.0/6606 CPU: 0 PID: 6606 Comm: syz-executor.0 Not tainted 6.9.0-syzkaller-07726-g3c999d1ae3c7 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:114 print_address_description mm/kasan/report.c:377 [inline] print_report+0xc3/0x620 mm/kasan/report.c:488 kasan_report+0xd9/0x110 mm/kasan/report.c:601 bpf_link_free+0x28d/0x320 kernel/bpf/syscall.c:3078 bpf_link_put_direct kernel/bpf/syscall.c:3106 [inline] bpf_link_release+0x63/0x80 kernel/bpf/syscall.c:3113 __fput+0x270/0xb80 fs/file_table.c:422 __fput_sync+0x47/0x50 fs/file_table.c:507 __do_sys_close fs/open.c:1556 [inline] __se_sys_close fs/open.c:1541 [inline] __x64_sys_close+0x86/0x100 fs/open.c:1541 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x260 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f386c67bdda Code: 48 3d 00 f0 ff ff 77 48 c3 0f 1f 80 00 00 00 00 48 83 ec 18 89 7c 24 0c e8 03 7f 02 00 8b 7c 24 0c 89 c2 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 36 89 d7 89 44 24 0c e8 63 7f 02 00 8b 44 24 RSP: 002b:00007ffe8e3518b0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: ffffffffffffffda RBX: 0000000000000008 RCX: 00007f386c67bdda RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000007 RBP: 00007f386c7ad980 R08: 0000001b32e20000 R09: 000000000000095c R10: 0000000081ad43c7 R11: 0000000000000293 R12: 0000000000034043 R13: 00007f386c7ac12c R14: 00007ffe8e3519b0 R15: 0000000000000032 Allocated by task 6608: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:387 kmalloc include/linux/slab.h:628 [inline] kzalloc include/linux/slab.h:749 [inline] bpf_raw_tp_link_attach+0x18b/0x640 kernel/bpf/syscall.c:3858 bpf_raw_tracepoint_open kernel/bpf/syscall.c:3905 [inline] __sys_bpf+0x3a7/0x4b70 kernel/bpf/syscall.c:5729 __do_sys_bpf kernel/bpf/syscall.c:5794 [inline] __se_sys_bpf kernel/bpf/syscall.c:5792 [inline] __x64_sys_bpf+0x78/0xc0 kernel/bpf/syscall.c:5792 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x260 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:579 poison_slab_object mm/kasan/common.c:240 [inline] __kasan_slab_free+0x11d/0x1a0 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2121 [inline] slab_free mm/slub.c:4353 [inline] kfree+0x129/0x3a0 mm/slub.c:4463 rcu_do_batch kernel/rcu/tree.c:2535 [inline] rcu_core+0x828/0x16b0 kernel/rcu/tree.c:2809 handle_softirqs+0x216/0x8f0 kernel/softirq.c:554 run_ksoftirqd kernel/softirq.c:928 [inline] run_ksoftirqd+0x3a/0x60 kernel/softirq.c:920 smpboot_thread_fn+0x661/0xa10 kernel/smpboot.c:164 kthread+0x2c1/0x3a0 kernel/kthread.c:389 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 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+0xba/0xd0 mm/kasan/generic.c:541 __call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:3072 bpf_link_free+0x26a/0x320 kernel/bpf/syscall.c:3076 bpf_link_put_direct kernel/bpf/syscall.c:3106 [inline] bpf_link_release+0x63/0x80 kernel/bpf/syscall.c:3113 __fput+0x270/0xb80 fs/file_table.c:422 __fput_sync+0x47/0x50 fs/file_table.c:507 __do_sys_close fs/open.c:1556 [inline] __se_sys_close fs/open.c:1541 [inline] __x64_sys_close+0x86/0x100 fs/open.c:1541 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x260 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff888027b80d00 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 16 bytes inside of freed 128-byte region [ffff888027b80d00, ffff888027b80d80) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x27b80 flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000800 ffff888015441a00 dead000000000100 dead000000000122 raw: 0000000000000000 0000000080100010 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 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 4538, tgid 4538 (udevd), ts 48233046350, free_ts 48232161043 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x2d4/0x350 mm/page_alloc.c:1534 prep_new_page mm/page_alloc.c:1541 [inline] get_page_from_freelist+0xa28/0x3780 mm/page_alloc.c:3317 __alloc_pages+0x22b/0x2460 mm/page_alloc.c:4575 __alloc_pages_node include/linux/gfp.h:238 [inline] alloc_pages_node include/linux/gfp.h:261 [inline] alloc_slab_page mm/slub.c:2190 [inline] allocate_slab mm/slub.c:2353 [inline] new_slab+0xcc/0x3a0 mm/slub.c:2406 ___slab_alloc+0xd28/0x1810 mm/slub.c:3592 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3682 __slab_alloc_node mm/slub.c:3735 [inline] slab_alloc_node mm/slub.c:3908 [inline] kmalloc_trace+0x306/0x340 mm/slub.c:4065 kmalloc include/linux/slab.h:628 [inline] kzalloc include/linux/slab.h:749 [inline] kernfs_get_open_node fs/kernfs/file.c:525 [inline] kernfs_fop_open+0xa8e/0xdb0 fs/kernfs/file.c:700 do_dentry_open+0x8da/0x18c0 fs/open.c:955 do_open fs/namei.c:3650 [inline] path_openat+0x1dfb/0x2990 fs/namei.c:3807 do_filp_open+0x1dc/0x430 fs/namei.c:3834 do_sys_openat2+0x17a/0x1e0 fs/open.c:1406 do_sys_open fs/open.c:1421 [inline] __do_sys_openat fs/open.c:1437 [inline] __se_sys_openat fs/open.c:1432 [inline] __x64_sys_openat+0x175/0x210 fs/open.c:1432 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x260 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f page last free pid 4538 tgid 4538 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1141 [inline] free_unref_page_prepare+0x527/0xb10 mm/page_alloc.c:2347 free_unref_page+0x33/0x3c0 mm/page_alloc.c:2487 selinux_genfs_get_sid security/selinux/hooks.c:1343 [inline] inode_doinit_with_dentry+0xac4/0x12c0 security/selinux/hooks.c:1541 selinux_d_instantiate+0x26/0x30 security/selinux/hooks.c:6335 security_d_instantiate+0x57/0xf0 security/security.c:3916 d_splice_alias+0x94/0xdf0 fs/dcache.c:2973 kernfs_iop_lookup+0x286/0x330 fs/kernfs/dir.c:1229 lookup_open.isra.0+0x928/0x13c0 fs/namei.c:3483 open_last_lookups fs/namei.c:3574 [inline] path_openat+0x92f/0x2990 fs/namei.c:3804 do_filp_open+0x1dc/0x430 fs/namei.c:3834 do_sys_openat2+0x17a/0x1e0 fs/open.c:1406 do_sys_open fs/open.c:1421 [inline] __do_sys_openat fs/open.c:1437 [inline] __se_sys_openat fs/open.c:1432 [inline] __x64_sys_openat+0x175/0x210 fs/open.c:1432 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x260 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff888027b80c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888027b80c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888027b80d00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888027b80d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888027b80e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc ==================================================================