================================================================== BUG: KASAN: use-after-free in nf_hook_entries_get_hook_ops include/linux/netfilter.h:130 [inline] BUG: KASAN: use-after-free in hooks_validate+0x173/0x1b0 net/netfilter/core.c:171 Read of size 2 at addr ffff888022ca9f00 by task syz-executor.5/14857 CPU: 0 PID: 14857 Comm: syz-executor.5 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 mm/kasan/report.c:433 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:450 nf_hook_entries_get_hook_ops include/linux/netfilter.h:130 [inline] hooks_validate+0x173/0x1b0 net/netfilter/core.c:171 __nf_register_net_hook+0x17f/0x6e0 net/netfilter/core.c:438 nf_register_net_hook+0x114/0x170 net/netfilter/core.c:571 clusterip_tg_check+0xea5/0x2300 net/ipv4/netfilter/ipt_CLUSTERIP.c:536 xt_check_target+0x26c/0x9e0 net/netfilter/x_tables.c:1038 check_target net/ipv4/netfilter/ip_tables.c:512 [inline] find_check_entry.constprop.0+0x7a9/0x9a0 net/ipv4/netfilter/ip_tables.c:554 translate_table+0xc26/0x16a0 net/ipv4/netfilter/ip_tables.c:718 do_replace net/ipv4/netfilter/ip_tables.c:1136 [inline] do_ipt_set_ctl+0x56e/0xb80 net/ipv4/netfilter/ip_tables.c:1630 nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101 ip_setsockopt+0x3c3/0x3a90 net/ipv4/ip_sockglue.c:1444 tcp_setsockopt+0x136/0x2520 net/ipv4/tcp.c:3656 __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:0x7f846ab3bb49 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:00007f84696b1188 EFLAGS: 00000246 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 00007f846ac4ef60 RCX: 00007f846ab3bb49 RDX: 0000000000000040 RSI: 0004000000000000 RDI: 0000000000000004 RBP: 00007f846ab96012 R08: 0000000000000298 R09: 0000000000000000 R10: 00000000200002c0 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fffd212944f R14: 00007f84696b1300 R15: 0000000000022000 Allocated by task 14857: 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 kmalloc_node include/linux/slab.h:613 [inline] kvmalloc_node+0x61/0x120 mm/util.c:587 kvmalloc include/linux/slab.h:741 [inline] kvzalloc include/linux/slab.h:749 [inline] allocate_hook_entries_size net/netfilter/core.c:61 [inline] nf_hook_entries_grow+0x140/0x780 net/netfilter/core.c:128 __nf_register_net_hook+0x128/0x6e0 net/netfilter/core.c:429 nf_register_net_hook+0x114/0x170 net/netfilter/core.c:571 clusterip_tg_check+0xea5/0x2300 net/ipv4/netfilter/ipt_CLUSTERIP.c:536 xt_check_target+0x26c/0x9e0 net/netfilter/x_tables.c:1038 check_target net/ipv4/netfilter/ip_tables.c:512 [inline] find_check_entry.constprop.0+0x7a9/0x9a0 net/ipv4/netfilter/ip_tables.c:554 translate_table+0xc26/0x16a0 net/ipv4/netfilter/ip_tables.c:718 do_replace net/ipv4/netfilter/ip_tables.c:1136 [inline] do_ipt_set_ctl+0x56e/0xb80 net/ipv4/netfilter/ip_tables.c:1630 nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101 ip_setsockopt+0x3c3/0x3a90 net/ipv4/ip_sockglue.c:1444 tcp_setsockopt+0x136/0x2520 net/ipv4/tcp.c:3656 __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 13117: 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 kvfree+0x42/0x50 mm/util.c:620 rcu_do_batch kernel/rcu/tree.c:2506 [inline] rcu_core+0x7ab/0x1470 kernel/rcu/tree.c:2741 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558 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 __call_rcu kernel/rcu/tree.c:2985 [inline] call_rcu+0xb1/0x740 kernel/rcu/tree.c:3065 nf_hook_entries_free net/netfilter/core.c:88 [inline] nf_hook_entries_free net/netfilter/core.c:75 [inline] __nf_register_net_hook+0x2b1/0x6e0 net/netfilter/core.c:450 nf_register_net_hook+0x114/0x170 net/netfilter/core.c:571 clusterip_tg_check+0xea5/0x2300 net/ipv4/netfilter/ipt_CLUSTERIP.c:536 xt_check_target+0x26c/0x9e0 net/netfilter/x_tables.c:1038 check_target net/ipv4/netfilter/ip_tables.c:512 [inline] find_check_entry.constprop.0+0x7a9/0x9a0 net/ipv4/netfilter/ip_tables.c:554 translate_table+0xc26/0x16a0 net/ipv4/netfilter/ip_tables.c:718 do_replace net/ipv4/netfilter/ip_tables.c:1136 [inline] do_ipt_set_ctl+0x56e/0xb80 net/ipv4/netfilter/ip_tables.c:1630 nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101 ip_setsockopt+0x3c3/0x3a90 net/ipv4/ip_sockglue.c:1444 tcp_setsockopt+0x136/0x2520 net/ipv4/tcp.c:3656 __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 Second to 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 cfg80211_update_known_bss+0x833/0xa60 net/wireless/scan.c:1663 cfg80211_bss_update+0xef/0x2070 net/wireless/scan.c:1710 cfg80211_inform_single_bss_frame_data+0x6e2/0xed0 net/wireless/scan.c:2425 cfg80211_inform_bss_frame_data+0xa7/0xb50 net/wireless/scan.c:2458 ieee80211_bss_info_update+0x35b/0xb30 net/mac80211/scan.c:190 ieee80211_rx_bss_info net/mac80211/ibss.c:1119 [inline] ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1610 [inline] ieee80211_ibss_rx_queued_mgmt+0x19cf/0x3130 net/mac80211/ibss.c:1639 ieee80211_iface_process_skb net/mac80211/iface.c:1468 [inline] ieee80211_iface_work+0xa65/0xd00 net/mac80211/iface.c:1522 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298 worker_thread+0x658/0x11f0 kernel/workqueue.c:2445 kthread+0x405/0x4f0 kernel/kthread.c:327 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 The buggy address belongs to the object at ffff888022ca9f00 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 0 bytes inside of 96-byte region [ffff888022ca9f00, ffff888022ca9f60) The buggy address belongs to the page: page:ffffea00008b2a40 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888022ca9580 pfn:0x22ca9 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea0001e8d3c8 ffffea00013467c8 ffff888010c40300 raw: ffff888022ca9580 ffff888022ca9000 000000010000001c 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 5515, ts 309047782000, free_ts 308857021345 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] __do_kmalloc mm/slab.c:3700 [inline] __kmalloc+0x3b3/0x4d0 mm/slab.c:3711 cfg80211_inform_single_bss_frame_data+0x2fc/0xed0 net/wireless/scan.c:2397 cfg80211_inform_bss_frame_data+0xa7/0xb50 net/wireless/scan.c:2458 ieee80211_bss_info_update+0x35b/0xb30 net/mac80211/scan.c:190 ieee80211_rx_bss_info net/mac80211/ibss.c:1119 [inline] ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1610 [inline] ieee80211_ibss_rx_queued_mgmt+0x19cf/0x3130 net/mac80211/ibss.c:1639 ieee80211_iface_process_skb net/mac80211/iface.c:1468 [inline] ieee80211_iface_work+0xa65/0xd00 net/mac80211/iface.c:1522 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298 worker_thread+0x658/0x11f0 kernel/workqueue.c:2445 kthread+0x405/0x4f0 kernel/kthread.c:327 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 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 mm_free_pgd kernel/fork.c:647 [inline] __mmdrop+0xcb/0x3f0 kernel/fork.c:698 mmdrop include/linux/sched/mm.h:49 [inline] __mmput+0x3f1/0x4b0 kernel/fork.c:1123 mmput+0x56/0x60 kernel/fork.c:1134 exit_mm kernel/exit.c:507 [inline] do_exit+0xb27/0x2b40 kernel/exit.c:819 do_group_exit+0x125/0x310 kernel/exit.c:929 get_signal+0x47d/0x2220 kernel/signal.c:2852 arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:868 handle_signal_work kernel/entry/common.c:148 [inline] exit_to_user_mode_loop kernel/entry/common.c:172 [inline] exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:207 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline] syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x44/0xae Memory state around the buggy address: ffff888022ca9e00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff888022ca9e80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc >ffff888022ca9f00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff888022ca9f80: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc ffff888022caa000: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ==================================================================