================================================================== BUG: KASAN: double-free or invalid-free in packet_set_ring+0xd9a/0x19d0 net/packet/af_packet.c:4451 CPU: 0 PID: 19913 Comm: syz-executor965 Not tainted 5.11.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x9a/0xcc lib/dump_stack.c:120 print_address_description.constprop.0.cold+0x5b/0x2c6 mm/kasan/report.c:230 kasan_report_invalid_free+0x51/0x80 mm/kasan/report.c:355 ____kasan_slab_free+0xcc/0xe0 mm/kasan/common.c:341 kasan_slab_free include/linux/kasan.h:192 [inline] __cache_free mm/slab.c:3424 [inline] kfree+0xed/0x270 mm/slab.c:3760 packet_set_ring+0xd9a/0x19d0 net/packet/af_packet.c:4451 packet_setsockopt+0x16c8/0x3640 net/packet/af_packet.c:3737 __sys_setsockopt+0x1fd/0x4e0 net/socket.c:2115 __do_sys_setsockopt net/socket.c:2126 [inline] __se_sys_setsockopt net/socket.c:2123 [inline] __x64_sys_setsockopt+0xb5/0x150 net/socket.c:2123 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f47707199b9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 15 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f47706a9318 EFLAGS: 00000246 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 00007f47707a34b8 RCX: 00007f47707199b9 RDX: 0000000000000005 RSI: 0000000000000107 RDI: 0000000000000003 RBP: 00007f47707a34b0 R08: 000000000000001c R09: 0000000000000000 R10: 00000000200000c0 R11: 0000000000000246 R12: 00007f4770770294 R13: 00007ffe0be36b1f R14: 00007f47706a9400 R15: 0000000000022000 Allocated by task 19906: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:401 [inline] ____kasan_kmalloc.constprop.0+0x7f/0xa0 mm/kasan/common.c:429 kasan_kmalloc include/linux/kasan.h:219 [inline] __do_kmalloc mm/slab.c:3659 [inline] __kmalloc+0x20c/0x440 mm/slab.c:3668 kmalloc_array include/linux/slab.h:592 [inline] kcalloc include/linux/slab.h:621 [inline] alloc_pg_vec net/packet/af_packet.c:4273 [inline] packet_set_ring+0xa86/0x19d0 net/packet/af_packet.c:4363 packet_setsockopt+0x16c8/0x3640 net/packet/af_packet.c:3737 __sys_setsockopt+0x1fd/0x4e0 net/socket.c:2115 __do_sys_setsockopt net/socket.c:2126 [inline] __se_sys_setsockopt net/socket.c:2123 [inline] __x64_sys_setsockopt+0xb5/0x150 net/socket.c:2123 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 19913: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:356 ____kasan_slab_free+0xb0/0xe0 mm/kasan/common.c:362 kasan_slab_free include/linux/kasan.h:192 [inline] __cache_free mm/slab.c:3424 [inline] kfree+0xed/0x270 mm/slab.c:3760 packet_set_ring+0x620/0x19d0 net/packet/af_packet.c:4453 packet_setsockopt+0x16c8/0x3640 net/packet/af_packet.c:3737 __sys_setsockopt+0x1fd/0x4e0 net/socket.c:2115 __do_sys_setsockopt net/socket.c:2126 [inline] __se_sys_setsockopt net/socket.c:2123 [inline] __x64_sys_setsockopt+0xb5/0x150 net/socket.c:2123 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff888016922f00 which belongs to the cache kmalloc-64 of size 64 The buggy address is located 0 bytes inside of 64-byte region [ffff888016922f00, ffff888016922f40) The buggy address belongs to the page: page:00000000e69c5d50 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x16922 flags: 0xfff00000000200(slab) raw: 00fff00000000200 ffffea0000aced08 ffffea0000684988 ffff88800f440200 raw: 0000000000000000 ffff888016922000 0000000100000020 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 0x342040(__GFP_IO|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 5899, ts 75416457169 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x144/0x1c0 mm/page_alloc.c:2297 prep_new_page mm/page_alloc.c:2306 [inline] get_page_from_freelist+0x1c6e/0x3f80 mm/page_alloc.c:3945 __alloc_pages_nodemask+0x2d6/0x730 mm/page_alloc.c:4995 __alloc_pages include/linux/gfp.h:511 [inline] __alloc_pages_node include/linux/gfp.h:524 [inline] kmem_getpages mm/slab.c:1376 [inline] cache_grow_begin+0x71/0x430 mm/slab.c:2593 cache_alloc_refill+0x27f/0x380 mm/slab.c:2965 ____cache_alloc mm/slab.c:3048 [inline] ____cache_alloc mm/slab.c:3031 [inline] __do_cache_alloc mm/slab.c:3271 [inline] slab_alloc mm/slab.c:3307 [inline] __do_kmalloc mm/slab.c:3657 [inline] __kmalloc+0x35c/0x440 mm/slab.c:3668 kmalloc include/linux/slab.h:557 [inline] kzalloc include/linux/slab.h:682 [inline] tomoyo_encode2.part.0+0x92/0x310 security/tomoyo/realpath.c:45 tomoyo_realpath_from_path+0x140/0x6a0 security/tomoyo/realpath.c:288 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x1fb/0x350 security/tomoyo/file.c:822 tomoyo_path_unlink+0x7f/0xd0 security/tomoyo/tomoyo.c:150 security_path_unlink+0xb3/0x110 security/security.c:1102 do_unlinkat+0x2ac/0x520 fs/namei.c:3896 do_syscall_64+0x2d/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:24 [inline] free_pages_prepare mm/page_alloc.c:1271 [inline] free_pcp_prepare+0x2cb/0x410 mm/page_alloc.c:1306 free_unref_page_prepare mm/page_alloc.c:3200 [inline] free_unref_page+0x12/0x1b0 mm/page_alloc.c:3248 __vunmap+0x59e/0x940 mm/vmalloc.c:2286 free_work+0x4b/0x70 mm/vmalloc.c:67 process_one_work+0x84c/0x13b0 kernel/workqueue.c:2275 worker_thread+0x598/0xf80 kernel/workqueue.c:2421 kthread+0x36f/0x450 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296 Memory state around the buggy address: ffff888016922e00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff888016922e80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc >ffff888016922f00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ^ ffff888016922f80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff888016923000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================