================================================================== 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 __cgroup_bpf_attach+0x5aa/0x1070 kernel/bpf/cgroup.c:467 Read of size 8 at addr ffff888119300a98 by task syz-executor.1/12297 CPU: 0 PID: 12297 Comm: syz-executor.1 Tainted: G W 5.10.77-syzkaller-01258-g76698ea35fd3 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233 __kasan_report+0x142/0x220 mm/kasan/report.c:419 kasan_report+0x51/0x70 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] __cgroup_bpf_attach+0x5aa/0x1070 kernel/bpf/cgroup.c:467 cgroup_bpf_attach+0x4a/0x70 kernel/cgroup/cgroup.c:6566 cgroup_bpf_link_attach+0x239/0x4a0 kernel/bpf/cgroup.c:934 link_create kernel/bpf/syscall.c:4073 [inline] __do_sys_bpf+0xab52/0x116d0 kernel/bpf/syscall.c:4478 __se_sys_bpf kernel/bpf/syscall.c:4364 [inline] __x64_sys_bpf+0x7a/0x90 kernel/bpf/syscall.c:4364 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f813af1eae9 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 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f8138c95188 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 00007f813b031f60 RCX: 00007f813af1eae9 RDX: 0000000000000010 RSI: 0000000020000040 RDI: 000000000000001c RBP: 00007f813af78f6d R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffd2eb221ef R14: 00007f8138c95300 R15: 0000000000022000 Allocated by task 12261: 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+0x210/0x3a0 mm/slub.c:2975 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 kernel/bpf/syscall.c:4073 [inline] __do_sys_bpf+0xab52/0x116d0 kernel/bpf/syscall.c:4478 __se_sys_bpf kernel/bpf/syscall.c:4364 [inline] __x64_sys_bpf+0x7a/0x90 kernel/bpf/syscall.c:4364 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 12260: 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+0x133/0x170 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:1596 [inline] slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1622 slab_free mm/slub.c:3204 [inline] kfree+0xd5/0x320 mm/slub.c:4192 bpf_cgroup_link_dealloc+0x15/0x20 kernel/bpf/cgroup.c:849 bpf_link_free kernel/bpf/syscall.c:2336 [inline] bpf_link_put+0x243/0x270 kernel/bpf/syscall.c:2358 bpf_link_release+0x3b/0x40 kernel/bpf/syscall.c:2366 __fput+0x348/0x7d0 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 kernel/entry/common.c:164 [inline] exit_to_user_mode_prepare+0xc3/0xe0 kernel/entry/common.c:191 syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:266 do_syscall_64+0x3d/0x70 arch/x86/entry/common.c:56 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Last potentially related work creation: kasan_save_stack+0x36/0x60 mm/kasan/common.c:38 kasan_record_aux_stack+0xd3/0xf0 mm/kasan/generic.c:345 insert_work+0x56/0x330 kernel/workqueue.c:1340 __queue_work+0x951/0xda0 kernel/workqueue.c:1506 queue_work_on+0xef/0x150 kernel/workqueue.c:1533 queue_work include/linux/workqueue.h:513 [inline] schedule_work include/linux/workqueue.h:574 [inline] nf_nat_masq_schedule+0x49a/0x5b0 net/netfilter/nf_nat_masquerade.c:125 masq_device_event+0xa2/0xd0 net/netfilter/nf_nat_masquerade.c:157 notifier_call_chain kernel/notifier.c:83 [inline] raw_notifier_call_chain+0x8e/0xf0 kernel/notifier.c:410 __dev_notify_flags+0x306/0x5e0 net/core/dev.c:2054 dev_change_flags+0xec/0x190 net/core/dev.c:8564 do_setlink+0xd2f/0x4190 net/core/rtnetlink.c:2707 rtnl_group_changelink net/core/rtnetlink.c:3226 [inline] __rtnl_newlink net/core/rtnetlink.c:3380 [inline] rtnl_newlink+0x119a/0x1db0 net/core/rtnetlink.c:3501 rtnetlink_rcv_msg+0xbae/0xd70 net/core/rtnetlink.c:5567 netlink_rcv_skb+0x200/0x470 net/netlink/af_netlink.c:2502 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:5585 netlink_unicast_kernel net/netlink/af_netlink.c:1311 [inline] netlink_unicast+0x814/0x9f0 net/netlink/af_netlink.c:1337 netlink_sendmsg+0xa20/0xe00 net/netlink/af_netlink.c:1927 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg net/socket.c:672 [inline] ____sys_sendmsg+0x5b9/0x910 net/socket.c:2343 ___sys_sendmsg net/socket.c:2397 [inline] __sys_sendmsg+0x384/0x470 net/socket.c:2430 __do_sys_sendmsg net/socket.c:2439 [inline] __se_sys_sendmsg net/socket.c:2437 [inline] __x64_sys_sendmsg+0x7f/0x90 net/socket.c:2437 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Second to last potentially related work creation: kasan_save_stack+0x36/0x60 mm/kasan/common.c:38 kasan_record_aux_stack+0xd3/0xf0 mm/kasan/generic.c:345 __call_rcu kernel/rcu/tree.c:2962 [inline] call_rcu+0x134/0x1470 kernel/rcu/tree.c:3036 release_probes kernel/tracepoint.c:164 [inline] tracepoint_remove_func kernel/tracepoint.c:479 [inline] tracepoint_probe_unregister+0x974/0x9e0 kernel/tracepoint.c:572 bpf_probe_unregister+0x61/0x70 kernel/trace/bpf_trace.c:2121 bpf_raw_tp_link_release+0x63/0x90 kernel/bpf/syscall.c:2738 bpf_link_free kernel/bpf/syscall.c:2332 [inline] bpf_link_put+0x1e9/0x270 kernel/bpf/syscall.c:2358 bpf_link_release+0x3b/0x40 kernel/bpf/syscall.c:2366 __fput+0x348/0x7d0 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 kernel/entry/common.c:164 [inline] exit_to_user_mode_prepare+0xc3/0xe0 kernel/entry/common.c:191 syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:266 do_syscall_64+0x3d/0x70 arch/x86/entry/common.c:56 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff888119300a80 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 24 bytes inside of 96-byte region [ffff888119300a80, ffff888119300ae0) The buggy address belongs to the page: page:ffffea000464c000 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888119300800 pfn:0x119300 flags: 0x8000000000000200(slab) raw: 8000000000000200 ffffea00043d48c8 ffffea00042b4608 ffff888100043680 raw: ffff888119300800 0000000000200011 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 0x12c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY), pid 178, ts 13198375634, free_ts 13170488090 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+0xa74/0xa90 mm/page_alloc.c:4063 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5106 alloc_slab_page mm/slub.c:1807 [inline] allocate_slab+0x6b/0x350 mm/slub.c:1809 new_slab mm/slub.c:1870 [inline] new_slab_objects mm/slub.c:2629 [inline] ___slab_alloc+0x143/0x2f0 mm/slub.c:2792 __slab_alloc mm/slub.c:2832 [inline] slab_alloc_node mm/slub.c:2914 [inline] slab_alloc mm/slub.c:2956 [inline] __kmalloc+0x2af/0x3d0 mm/slub.c:4030 kmalloc_array include/linux/slab.h:592 [inline] kcalloc+0x36/0x50 include/linux/slab.h:603 ext4_find_extent+0x235/0xd20 fs/ext4/extents.c:864 ext4_ext_map_blocks+0x242/0x4340 fs/ext4/extents.c:4060 ext4_map_blocks+0xada/0x1de0 fs/ext4/inode.c:638 mpage_map_one_extent+0x1bc/0x690 fs/ext4/inode.c:2417 mpage_map_and_submit_extent fs/ext4/inode.c:2470 [inline] ext4_writepages+0x15be/0x3950 fs/ext4/inode.c:2822 do_writepages+0x13a/0x280 mm/page-writeback.c:2358 __writeback_single_inode+0xb8/0x6f0 fs/fs-writeback.c:1467 writeback_sb_inodes+0x9a4/0x1910 fs/fs-writeback.c:1729 __writeback_inodes_wb fs/fs-writeback.c:1798 [inline] wb_writeback+0x4ec/0xc40 fs/fs-writeback.c:1904 wb_check_background_flush fs/fs-writeback.c:1972 [inline] wb_do_writeback+0xa3d/0xbc0 fs/fs-writeback.c:2060 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+0x18f/0x1c0 mm/page_alloc.c:1405 free_unref_page_prepare mm/page_alloc.c:3291 [inline] free_unref_page_list+0x116/0x5d0 mm/page_alloc.c:3361 release_pages+0xa62/0xaa0 mm/swap.c:1081 free_pages_and_swap_cache+0x88/0xa0 mm/swap_state.c:356 tlb_batch_pages_flush mm/mmu_gather.c:49 [inline] tlb_flush_mmu_free mm/mmu_gather.c:242 [inline] tlb_flush_mmu+0x860/0xa00 mm/mmu_gather.c:249 tlb_finish_mmu+0xd2/0x1f0 mm/mmu_gather.c:328 exit_mmap+0x2e8/0x570 mm/mmap.c:3326 __mmput+0x95/0x2c0 kernel/fork.c:1128 mmput+0x4b/0x50 kernel/fork.c:1149 exit_mm+0x615/0x7e0 kernel/exit.c:489 do_exit+0x6c4/0x23a0 kernel/exit.c:800 do_group_exit+0x16a/0x2d0 kernel/exit.c:910 __do_sys_exit_group+0x17/0x20 kernel/exit.c:921 __se_sys_exit_group+0x14/0x20 kernel/exit.c:919 __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:919 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 Memory state around the buggy address: ffff888119300980: 00 00 00 00 00 00 00 00 00 02 fc fc fc fc fc fc ffff888119300a00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc >ffff888119300a80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff888119300b00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff888119300b80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ==================================================================