================================================================== BUG: KASAN: use-after-free in prog_list_prog kernel/bpf/cgroup.c:174 [inline] BUG: KASAN: use-after-free in prog_list_length kernel/bpf/cgroup.c:187 [inline] BUG: KASAN: use-after-free in compute_effective_progs+0x1d3/0x6e0 kernel/bpf/cgroup.c:240 Read of size 8 at addr ffff888113030218 by task syz-executor.0/2435 CPU: 0 PID: 2435 Comm: syz-executor.0 Tainted: G W 5.10.118-syzkaller-00163-gfa7f6a5f56d9 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/29/2022 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118 print_address_description+0x81/0x3c0 mm/kasan/report.c:233 __kasan_report mm/kasan/report.c:419 [inline] kasan_report+0x1a4/0x1f0 mm/kasan/report.c:436 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309 prog_list_prog kernel/bpf/cgroup.c:174 [inline] prog_list_length kernel/bpf/cgroup.c:187 [inline] compute_effective_progs+0x1d3/0x6e0 kernel/bpf/cgroup.c:240 update_effective_progs+0x79/0x320 kernel/bpf/cgroup.c:343 __cgroup_bpf_detach+0x312/0x570 kernel/bpf/cgroup.c:689 bpf_cgroup_link_release+0x94/0x260 kernel/bpf/cgroup.c:833 bpf_link_free kernel/bpf/syscall.c:2350 [inline] bpf_link_put+0x1e9/0x270 kernel/bpf/syscall.c:2376 bpf_link_release+0x3b/0x40 kernel/bpf/syscall.c:2384 __fput+0x348/0x7c0 fs/file_table.c:281 ____fput+0x15/0x20 fs/file_table.c:314 task_work_run+0x147/0x1b0 kernel/task_work.c:154 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_user_mode_loop+0xc8/0xe0 kernel/entry/common.c:164 exit_to_user_mode_prepare kernel/entry/common.c:191 [inline] syscall_exit_to_user_mode+0x77/0xa0 kernel/entry/common.c:266 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f8b38035d4b Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44 RSP: 002b:00007ffd4b9d4b00 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000006 RCX: 00007f8b38035d4b RDX: 0000000000000000 RSI: 0000001b31621bd4 RDI: 0000000000000005 RBP: 00007f8b38197960 R08: 0000000000000000 R09: 0000000038e29901 R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000021cf7 R13: 00007ffd4b9d4c00 R14: 00007ffd4b9d4c20 R15: 0000000000000032 Allocated by task 2436: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:428 [inline] ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516 kasan_kmalloc include/linux/kasan.h:269 [inline] kmem_cache_alloc_trace+0x1dd/0x330 mm/slub.c:2983 kmalloc include/linux/slab.h:552 [inline] kzalloc include/linux/slab.h:664 [inline] cgroup_bpf_link_attach+0x12e/0x4a0 kernel/bpf/cgroup.c:918 link_create+0x540/0x6e0 kernel/bpf/syscall.c:4092 __do_sys_bpf+0x528/0x6c0 kernel/bpf/syscall.c:4497 __se_sys_bpf kernel/bpf/syscall.c:4383 [inline] __x64_sys_bpf+0x7a/0x90 kernel/bpf/syscall.c:4383 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 2436: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4c/0x80 mm/kasan/common.c:46 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:360 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1604 [inline] slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1630 slab_free mm/slub.c:3212 [inline] kfree+0xc3/0x290 mm/slub.c:4200 bpf_cgroup_link_dealloc+0x15/0x20 kernel/bpf/cgroup.c:849 bpf_link_free kernel/bpf/syscall.c:2354 [inline] bpf_link_put+0x243/0x270 kernel/bpf/syscall.c:2376 bpf_link_release+0x3b/0x40 kernel/bpf/syscall.c:2384 __fput+0x348/0x7c0 fs/file_table.c:281 ____fput+0x15/0x20 fs/file_table.c:314 task_work_run+0x147/0x1b0 kernel/task_work.c:154 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_user_mode_loop+0xc8/0xe0 kernel/entry/common.c:164 exit_to_user_mode_prepare kernel/entry/common.c:191 [inline] syscall_exit_to_user_mode+0x77/0xa0 kernel/entry/common.c:266 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff888113030200 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 24 bytes inside of 96-byte region [ffff888113030200, ffff888113030260) The buggy address belongs to the page: page:ffffea00044c0c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x113030 flags: 0x8000000000000200(slab) raw: 8000000000000200 ffffea000445db40 0000000a0000000a ffff888100043680 raw: 0000000000000000 0000000000200020 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 616, ts 105927842482, free_ts 105911936836 set_page_owner include/linux/page_owner.h:35 [inline] post_alloc_hook mm/page_alloc.c:2385 [inline] prep_new_page mm/page_alloc.c:2391 [inline] get_page_from_freelist+0x745/0x760 mm/page_alloc.c:4067 __alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5117 alloc_slab_page mm/slub.c:1815 [inline] allocate_slab+0x78/0x540 mm/slub.c:1817 new_slab mm/slub.c:1878 [inline] new_slab_objects mm/slub.c:2637 [inline] ___slab_alloc+0x131/0x2e0 mm/slub.c:2800 __slab_alloc+0x63/0xa0 mm/slub.c:2840 slab_alloc_node mm/slub.c:2922 [inline] slab_alloc mm/slub.c:2964 [inline] __kmalloc+0x24f/0x360 mm/slub.c:4038 kmalloc include/linux/slab.h:557 [inline] copy_verifier_state+0xc4/0xfe0 kernel/bpf/verifier.c:877 push_stack+0x1a9/0x730 kernel/bpf/verifier.c:975 check_cond_jmp_op kernel/bpf/verifier.c:8050 [inline] do_check+0xb0e0/0xd410 kernel/bpf/verifier.c:10065 do_check_common+0x8a0/0x18a0 kernel/bpf/verifier.c:11816 do_check_main kernel/bpf/verifier.c:11879 [inline] bpf_check+0xe7a0/0x10f10 kernel/bpf/verifier.c:12434 bpf_prog_load+0x12b0/0x1b70 kernel/bpf/syscall.c:2233 __do_sys_bpf+0x441/0x6c0 kernel/bpf/syscall.c:4427 __se_sys_bpf kernel/bpf/syscall.c:4383 [inline] __x64_sys_bpf+0x7a/0x90 kernel/bpf/syscall.c:4383 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 page last free stack trace: reset_page_owner include/linux/page_owner.h:28 [inline] free_pages_prepare mm/page_alloc.c:1331 [inline] free_pcp_prepare+0x18c/0x1c0 mm/page_alloc.c:1405 free_unref_page_prepare mm/page_alloc.c:3291 [inline] free_unref_page mm/page_alloc.c:3345 [inline] free_the_page mm/page_alloc.c:5176 [inline] __free_pages+0x390/0x570 mm/page_alloc.c:5185 __free_slab+0xd3/0x190 mm/slub.c:1903 free_slab mm/slub.c:1918 [inline] discard_slab+0x29/0x40 mm/slub.c:1924 __slab_free+0x31d/0x3a0 mm/slub.c:3140 do_slab_free mm/slub.c:3200 [inline] ___cache_free+0x11f/0x140 mm/slub.c:3219 qlink_free+0x38/0x40 mm/kasan/quarantine.c:146 qlist_free_all+0x4c/0xc0 mm/kasan/quarantine.c:165 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:272 ____kasan_kmalloc+0x2f/0x110 mm/kasan/common.c:473 __kasan_krealloc+0x8e/0xd0 mm/kasan/common.c:575 kasan_krealloc include/linux/kasan.h:289 [inline] __do_krealloc mm/slab_common.c:1105 [inline] krealloc+0xa4/0xf0 mm/slab_common.c:1142 push_jmp_history kernel/bpf/verifier.c:1774 [inline] is_state_visited kernel/bpf/verifier.c:9668 [inline] do_check+0x2817/0xd410 kernel/bpf/verifier.c:9808 do_check_common+0x8a0/0x18a0 kernel/bpf/verifier.c:11816 do_check_main kernel/bpf/verifier.c:11879 [inline] bpf_check+0xe7a0/0x10f10 kernel/bpf/verifier.c:12434 bpf_prog_load+0x12b0/0x1b70 kernel/bpf/syscall.c:2233 Memory state around the buggy address: ffff888113030100: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff888113030180: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc >ffff888113030200: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff888113030280: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff888113030300: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ==================================================================