================================================================== BUG: KASAN: slab-use-after-free in bpf_link_free+0x28d/0x320 kernel/bpf/syscall.c:3065 Read of size 8 at addr ffff88801eb6a510 by task syz-executor.1/13318 CPU: 2 PID: 13318 Comm: syz-executor.1 Not tainted 6.9.0-syzkaller-01768-ga5131c3fdf26 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 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:3065 bpf_link_put_direct kernel/bpf/syscall.c:3093 [inline] bpf_link_release+0x63/0x80 kernel/bpf/syscall.c:3100 __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] __ia32_sys_close+0x86/0x100 fs/open.c:1541 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0x75/0x120 arch/x86/entry/common.c:386 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf7259579 Code: b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 00 00 00 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00 RSP: 002b:00000000ffb46d50 EFLAGS: 00000293 ORIG_RAX: 0000000000000006 RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00000000568e2400 RDX: 0000000000000000 RSI: 00000000f73b0ff4 RDI: 00000000ffffffff RBP: 00000000ffffffff R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 13319: 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+0x188/0x610 kernel/bpf/syscall.c:3850 bpf_raw_tracepoint_open kernel/bpf/syscall.c:3892 [inline] __sys_bpf+0x3b7/0x58b0 kernel/bpf/syscall.c:5702 __do_sys_bpf kernel/bpf/syscall.c:5767 [inline] __se_sys_bpf kernel/bpf/syscall.c:5765 [inline] __ia32_sys_bpf+0x76/0xe0 kernel/bpf/syscall.c:5765 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0x75/0x120 arch/x86/entry/common.c:386 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Freed by task 5220: 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 __do_softirq kernel/softirq.c:588 [inline] invoke_softirq kernel/softirq.c:428 [inline] __irq_exit_rcu kernel/softirq.c:637 [inline] irq_exit_rcu+0xbb/0x120 kernel/softirq.c:649 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1043 [inline] sysvec_apic_timer_interrupt+0x95/0xb0 arch/x86/kernel/apic/apic.c:1043 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702 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:3063 bpf_link_put_direct kernel/bpf/syscall.c:3093 [inline] bpf_link_release+0x63/0x80 kernel/bpf/syscall.c:3100 __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] __ia32_sys_close+0x86/0x100 fs/open.c:1541 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0x75/0x120 arch/x86/entry/common.c:386 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e The buggy address belongs to the object at ffff88801eb6a500 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 16 bytes inside of freed 128-byte region [ffff88801eb6a500, ffff88801eb6a580) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1eb6a anon flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000800 ffff888014c42a00 0000000000000000 dead000000000001 raw: 0000000000000000 0000000000100010 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 0x152cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 69, tgid 69 (kworker/1:1H), ts 101474123316, free_ts 101431624006 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] __do_kmalloc_node mm/slub.c:4038 [inline] __kmalloc+0x3bf/0x440 mm/slub.c:4052 kmalloc include/linux/slab.h:632 [inline] __bch2_trans_get+0x462/0xed0 fs/bcachefs/btree_iter.c:3060 btree_node_write_work+0x319/0xa30 fs/bcachefs/btree_io.c:1870 process_one_work+0x902/0x1a30 kernel/workqueue.c:3267 process_scheduled_works kernel/workqueue.c:3348 [inline] worker_thread+0x6c8/0xf70 kernel/workqueue.c:3429 kthread+0x2c1/0x3a0 kernel/kthread.c:388 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 page last free pid 4694 tgid 4694 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 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x4e/0x140 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x192/0x1e0 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:322 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slub.c:3871 [inline] slab_alloc_node mm/slub.c:3918 [inline] kmem_cache_alloc+0x136/0x330 mm/slub.c:3925 getname_flags.part.0+0x50/0x4f0 fs/namei.c:139 getname_flags include/linux/audit.h:322 [inline] getname+0x8f/0xe0 fs/namei.c:218 do_sys_openat2+0x104/0x1e0 fs/open.c:1400 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: ffff88801eb6a400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc ffff88801eb6a480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88801eb6a500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88801eb6a580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88801eb6a600: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc ================================================================== ---------------- Code disassembly (best guess), 2 bytes skipped: 0: 10 06 adc %al,(%rsi) 2: 03 74 b4 01 add 0x1(%rsp,%rsi,4),%esi 6: 10 07 adc %al,(%rdi) 8: 03 74 b0 01 add 0x1(%rax,%rsi,4),%esi c: 10 08 adc %cl,(%rax) e: 03 74 d8 01 add 0x1(%rax,%rbx,8),%esi 1e: 00 51 52 add %dl,0x52(%rcx) 21: 55 push %rbp 22: 89 e5 mov %esp,%ebp 24: 0f 34 sysenter 26: cd 80 int $0x80 * 28: 5d pop %rbp <-- trapping instruction 29: 5a pop %rdx 2a: 59 pop %rcx 2b: c3 ret 2c: 90 nop 2d: 90 nop 2e: 90 nop 2f: 90 nop 30: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi 37: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi