================================================================== BUG: KASAN: double-free or invalid-free in packet_set_ring+0xfa6/0x1b20 net/packet/af_packet.c:4495 CPU: 1 PID: 30202 Comm: syz-executor.0 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/0x2ed 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+0xf6/0x110 mm/kasan/common.c:374 kasan_slab_free include/linux/kasan.h:235 [inline] __cache_free mm/slab.c:3445 [inline] kfree+0x10d/0x2c0 mm/slab.c:3802 packet_set_ring+0xfa6/0x1b20 net/packet/af_packet.c:4495 packet_setsockopt+0x1bd3/0x3c10 net/packet/af_packet.c:3785 __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:0x7fa1b57e9e99 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:00007fa1b411d168 EFLAGS: 00000246 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 00007fa1b58fd100 RCX: 00007fa1b57e9e99 RDX: 0000000000000005 RSI: 0000000000000107 RDI: 0000000000000003 RBP: 00007fa1b5844031 R08: 000000000000001c R09: 0000000000000000 R10: 00000000200000c0 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fffd81d59df R14: 00007fa1b411d300 R15: 0000000000022000 Allocated by task 30199: 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+0xa6/0xd0 mm/kasan/common.c:522 kasan_kmalloc include/linux/kasan.h:269 [inline] __do_kmalloc mm/slab.c:3702 [inline] __kmalloc+0x209/0x4d0 mm/slab.c:3711 kmalloc_array include/linux/slab.h:630 [inline] kcalloc include/linux/slab.h:661 [inline] alloc_pg_vec net/packet/af_packet.c:4317 [inline] packet_set_ring+0xa76/0x1b20 net/packet/af_packet.c:4407 packet_setsockopt+0x1bd3/0x3c10 net/packet/af_packet.c:3785 __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 30199: 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+0xd1/0x110 mm/kasan/common.c:374 kasan_slab_free include/linux/kasan.h:235 [inline] __cache_free mm/slab.c:3445 [inline] kfree+0x10d/0x2c0 mm/slab.c:3802 packet_set_ring+0x6c7/0x1b20 net/packet/af_packet.c:4497 packet_setsockopt+0x1bd3/0x3c10 net/packet/af_packet.c:3785 __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 Last potentially related work creation: kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38 __kasan_record_aux_stack+0xb5/0xe0 mm/kasan/generic.c:348 kvfree_call_rcu+0x74/0x990 kernel/rcu/tree.c:3550 ct_limit_set net/openvswitch/conntrack.c:1122 [inline] ovs_ct_limit_set_zone_limit net/openvswitch/conntrack.c:1980 [inline] ovs_ct_limit_cmd_set+0x617/0xc70 net/openvswitch/conntrack.c:2148 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:731 genl_family_rcv_msg net/netlink/genetlink.c:775 [inline] genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:792 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2496 genl_rcv+0x24/0x40 net/netlink/genetlink.c:803 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline] netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345 netlink_sendmsg+0x904/0xdf0 net/netlink/af_netlink.c:1921 sock_sendmsg_nosec net/socket.c:704 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:724 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2409 ___sys_sendmsg+0xf3/0x170 net/socket.c:2463 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2492 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 ffff88807f48f700 which belongs to the cache kmalloc-64 of size 64 The buggy address is located 0 bytes inside of 64-byte region [ffff88807f48f700, ffff88807f48f740) The buggy address belongs to the page: page:ffffea0001fd23c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807f48fe80 pfn:0x7f48f flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea0000476948 ffffea0001da2748 ffff888010c40200 raw: ffff88807f48fe80 ffff88807f48f000 0000000100000019 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 0x342220(__GFP_HIGH|__GFP_ATOMIC|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 3643, ts 172314122219, free_ts 172313896111 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_node include/linux/gfp.h:570 [inline] kmem_getpages mm/slab.c:1377 [inline] cache_grow_begin+0x75/0x470 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:3275 [inline] slab_alloc mm/slab.c:3316 [inline] kmem_cache_alloc_trace+0x380/0x4a0 mm/slab.c:3573 kmalloc include/linux/slab.h:590 [inline] kzalloc include/linux/slab.h:724 [inline] netlbl_secattr_alloc include/net/netlabel.h:382 [inline] selinux_netlbl_sock_genattr+0xac/0x4b0 security/selinux/netlabel.c:77 selinux_netlbl_socket_post_create+0x73/0x160 security/selinux/netlabel.c:401 selinux_socket_post_create+0x4de/0x7c0 security/selinux/hooks.c:4696 security_socket_post_create+0x64/0xc0 security/security.c:2175 __sock_create+0x64a/0x790 net/socket.c:1480 sock_create net/socket.c:1515 [inline] __sys_socket+0xef/0x200 net/socket.c:1557 __do_sys_socket net/socket.c:1566 [inline] __se_sys_socket net/socket.c:1564 [inline] __x64_sys_socket+0x6f/0xb0 net/socket.c:1564 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 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 __vunmap+0x781/0xb70 mm/vmalloc.c:2632 __vfree+0x3c/0xd0 mm/vmalloc.c:2680 vfree+0x5a/0x90 mm/vmalloc.c:2711 copy_entries_to_user net/ipv4/netfilter/arp_tables.c:713 [inline] get_entries net/ipv4/netfilter/arp_tables.c:867 [inline] do_arpt_get_ctl+0x7ac/0x8f0 net/ipv4/netfilter/arp_tables.c:1453 nf_getsockopt+0x72/0xd0 net/netfilter/nf_sockopt.c:116 ip_getsockopt net/ipv4/ip_sockglue.c:1786 [inline] ip_getsockopt+0x164/0x1c0 net/ipv4/ip_sockglue.c:1765 tcp_getsockopt+0x86/0xd0 net/ipv4/tcp.c:4252 __sys_getsockopt+0x21f/0x5f0 net/socket.c:2220 __do_sys_getsockopt net/socket.c:2235 [inline] __se_sys_getsockopt net/socket.c:2232 [inline] __x64_sys_getsockopt+0xba/0x150 net/socket.c:2232 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 Memory state around the buggy address: ffff88807f48f600: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff88807f48f680: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc >ffff88807f48f700: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ^ ffff88807f48f780: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc ffff88807f48f800: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc ==================================================================