================================================================== BUG: KASAN: double-free or invalid-free in slab_free mm/slub.c:3513 [inline] BUG: KASAN: double-free or invalid-free in kfree+0xf6/0x560 mm/slub.c:4561 CPU: 0 PID: 8109 Comm: syz-executor016 Not tainted 5.16.0-rc4-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0x8d/0x320 mm/kasan/report.c:247 kasan_report_invalid_free+0x51/0x80 mm/kasan/report.c:372 ____kasan_slab_free mm/kasan/common.c:346 [inline] __kasan_slab_free+0x124/0x130 mm/kasan/common.c:374 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1723 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1749 slab_free mm/slub.c:3513 [inline] kfree+0xf6/0x560 mm/slub.c:4561 packet_set_ring+0xfa6/0x1b20 net/packet/af_packet.c:4491 packet_setsockopt+0x1bd3/0x3c10 net/packet/af_packet.c:3781 __sys_setsockopt+0x2db/0x610 net/socket.c:2176 __do_sys_setsockopt net/socket.c:2187 [inline] __se_sys_setsockopt net/socket.c:2184 [inline] __x64_sys_setsockopt+0xba/0x150 net/socket.c:2184 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f5274a18859 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 18 00 00 90 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:00007f52749a0208 EFLAGS: 00000246 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 00007f5274a9a498 RCX: 00007f5274a18859 RDX: 0000000000000005 RSI: 0000000000000107 RDI: 0000000000000003 RBP: 00007f5274a9a490 R08: 000000000000001c R09: 0000000000000000 R10: 00000000200000c0 R11: 0000000000000246 R12: 00007f5274a9a49c R13: 00007ffd09f07d3f R14: 00007f52749a0300 R15: 0000000000022000 Allocated by task 8108: kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:434 [inline] ____kasan_kmalloc mm/kasan/common.c:513 [inline] ____kasan_kmalloc mm/kasan/common.c:472 [inline] __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:522 kmalloc_array include/linux/slab.h:630 [inline] kcalloc include/linux/slab.h:661 [inline] alloc_pg_vec net/packet/af_packet.c:4313 [inline] packet_set_ring+0xa76/0x1b20 net/packet/af_packet.c:4403 packet_setsockopt+0x1bd3/0x3c10 net/packet/af_packet.c:3781 __sys_setsockopt+0x2db/0x610 net/socket.c:2176 __do_sys_setsockopt net/socket.c:2187 [inline] __se_sys_setsockopt net/socket.c:2184 [inline] __x64_sys_setsockopt+0xba/0x150 net/socket.c:2184 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 8108: kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:46 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free mm/kasan/common.c:328 [inline] __kasan_slab_free+0xff/0x130 mm/kasan/common.c:374 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1723 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1749 slab_free mm/slub.c:3513 [inline] kfree+0xf6/0x560 mm/slub.c:4561 packet_set_ring+0x6c7/0x1b20 net/packet/af_packet.c:4493 packet_setsockopt+0x1bd3/0x3c10 net/packet/af_packet.c:3781 __sys_setsockopt+0x2db/0x610 net/socket.c:2176 __do_sys_setsockopt net/socket.c:2187 [inline] __se_sys_setsockopt net/socket.c:2184 [inline] __x64_sys_setsockopt+0xba/0x150 net/socket.c:2184 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff888022226000 which belongs to the cache kmalloc-64 of size 64 The buggy address is located 0 bytes inside of 64-byte region [ffff888022226000, ffff888022226040) The buggy address belongs to the page: page:ffffea0000888980 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x22226 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 dead000000000100 dead000000000122 ffff888010c41640 raw: 0000000000000000 0000000080200020 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 2974, ts 18691008845, free_ts 17169017097 prep_new_page mm/page_alloc.c:2418 [inline] get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4149 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5369 alloc_pages+0x1a7/0x300 mm/mempolicy.c:2191 alloc_slab_page mm/slub.c:1793 [inline] allocate_slab mm/slub.c:1930 [inline] new_slab+0x32d/0x4a0 mm/slub.c:1993 ___slab_alloc+0x918/0xfe0 mm/slub.c:3022 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3109 slab_alloc_node mm/slub.c:3200 [inline] slab_alloc mm/slub.c:3242 [inline] __kmalloc+0x2fb/0x340 mm/slub.c:4419 kmalloc include/linux/slab.h:595 [inline] kzalloc include/linux/slab.h:724 [inline] tomoyo_encode2.part.0+0xe9/0x3a0 security/tomoyo/realpath.c:45 tomoyo_encode2 security/tomoyo/realpath.c:31 [inline] tomoyo_encode+0x28/0x50 security/tomoyo/realpath.c:80 tomoyo_realpath_from_path+0x186/0x620 security/tomoyo/realpath.c:288 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x272/0x380 security/tomoyo/file.c:771 tomoyo_file_open security/tomoyo/tomoyo.c:311 [inline] tomoyo_file_open+0xa3/0xd0 security/tomoyo/tomoyo.c:306 security_file_open+0x45/0xb0 security/security.c:1635 do_dentry_open+0x353/0x1250 fs/open.c:809 do_open fs/namei.c:3426 [inline] path_openat+0x1cad/0x2750 fs/namei.c:3559 do_filp_open+0x1aa/0x400 fs/namei.c:3586 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1338 [inline] free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1389 free_unref_page_prepare mm/page_alloc.c:3309 [inline] free_unref_page+0x19/0x690 mm/page_alloc.c:3388 kasan_depopulate_vmalloc_pte+0x5c/0x70 mm/kasan/shadow.c:380 apply_to_pte_range mm/memory.c:2518 [inline] apply_to_pmd_range mm/memory.c:2562 [inline] apply_to_pud_range mm/memory.c:2598 [inline] apply_to_p4d_range mm/memory.c:2634 [inline] __apply_to_page_range+0x694/0x1080 mm/memory.c:2668 kasan_release_vmalloc+0xa7/0xc0 mm/kasan/shadow.c:490 __purge_vmap_area_lazy+0x8f9/0x1c50 mm/vmalloc.c:1708 _vm_unmap_aliases.part.0+0x3f0/0x500 mm/vmalloc.c:2111 _vm_unmap_aliases mm/vmalloc.c:2085 [inline] vm_unmap_aliases+0x45/0x50 mm/vmalloc.c:2134 change_page_attr_set_clr+0x241/0x500 arch/x86/mm/pat/set_memory.c:1743 change_page_attr_set arch/x86/mm/pat/set_memory.c:1793 [inline] set_memory_nx+0xb2/0x110 arch/x86/mm/pat/set_memory.c:1941 free_init_pages+0x73/0xc0 arch/x86/mm/init.c:894 kernel_init+0x2e/0x1d0 init/main.c:1508 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Memory state around the buggy address: ffff888022225f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888022225f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888022226000: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ^ ffff888022226080: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff888022226100: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc ==================================================================