syzbot


KASAN: use-after-free Write in nf_nat_setup_info

Status: auto-obsoleted due to no activity on 2023/05/10 12:28
Subsystems: netfilter
[Documentation on labels]
First crash: 614d, last: 614d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Write in nf_nat_setup_info 1 248d 248d 0/3 auto-obsoleted due to no activity on 2024/05/12 18:38
upstream KMSAN: uninit-value in nf_nat_setup_info (2) netfilter C 764 924d 1004d 0/28 auto-obsoleted due to no activity on 2022/09/28 07:28

Sample crash report:
BUG: KASAN: use-after-free in hlist_add_head_rcu include/linux/rculist.h:593 [inline]
BUG: KASAN: use-after-free in nf_nat_setup_info+0x21e2/0x2290 net/netfilter/nf_nat_core.c:633
Write of size 8 at addr ffff88806cf098d8 by task syz-executor.1/16365

CPU: 0 PID: 16365 Comm: syz-executor.1 Not tainted 6.2.0-rc6-syzkaller-00011-gc0b67534c95c #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:306 [inline]
 print_report+0x15e/0x45d mm/kasan/report.c:417
 kasan_report+0xbf/0x1f0 mm/kasan/report.c:517
 hlist_add_head_rcu include/linux/rculist.h:593 [inline]
 nf_nat_setup_info+0x21e2/0x2290 net/netfilter/nf_nat_core.c:633
 __nf_nat_alloc_null_binding+0x164/0x1d0 net/netfilter/nf_nat_core.c:664
 nf_nat_alloc_null_binding net/netfilter/nf_nat_core.c:670 [inline]
 nf_nat_inet_fn+0xae3/0xd30 net/netfilter/nf_nat_core.c:759
 nf_nat_ipv4_fn net/netfilter/nf_nat_proto.c:645 [inline]
 nf_nat_ipv4_local_in+0x160/0x520 net/netfilter/nf_nat_proto.c:708
 nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline]
 nf_hook_slow+0xc9/0x1f0 net/netfilter/core.c:614
 nf_hook.constprop.0+0x3ab/0x650 include/linux/netfilter.h:257
 NF_HOOK include/linux/netfilter.h:300 [inline]
 ip_local_deliver+0x176/0x200 net/ipv4/ip_input.c:254
 dst_input include/net/dst.h:454 [inline]
 ip_rcv_finish+0x1cf/0x2f0 net/ipv4/ip_input.c:449
 NF_HOOK include/linux/netfilter.h:302 [inline]
 NF_HOOK include/linux/netfilter.h:296 [inline]
 ip_rcv+0xae/0xd0 net/ipv4/ip_input.c:569
 __netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5482
 __netif_receive_skb+0x1f/0x1c0 net/core/dev.c:5596
 process_backlog+0x3e4/0x810 net/core/dev.c:5924
 __napi_poll+0xb8/0x770 net/core/dev.c:6485
 napi_poll net/core/dev.c:6552 [inline]
 net_rx_action+0xa00/0xde0 net/core/dev.c:6663
 __do_softirq+0x1fb/0xadc kernel/softirq.c:571
 do_softirq.part.0+0xde/0x130 kernel/softirq.c:472
 </IRQ>
 <TASK>
 do_softirq kernel/softirq.c:464 [inline]
 __local_bh_enable_ip+0x106/0x130 kernel/softirq.c:396
 local_bh_enable include/linux/bottom_half.h:33 [inline]
 rcu_read_unlock_bh include/linux/rcupdate.h:834 [inline]
 ip_finish_output2+0x7dc/0x2180 net/ipv4/ip_output.c:229
 __ip_finish_output net/ipv4/ip_output.c:306 [inline]
 __ip_finish_output+0x396/0x650 net/ipv4/ip_output.c:288
 ip_finish_output+0x31/0x280 net/ipv4/ip_output.c:316
 NF_HOOK_COND include/linux/netfilter.h:291 [inline]
 ip_output+0x1a3/0x320 net/ipv4/ip_output.c:430
 dst_output include/net/dst.h:444 [inline]
 ip_local_out net/ipv4/ip_output.c:126 [inline]
 ip_send_skb net/ipv4/ip_output.c:1586 [inline]
 ip_push_pending_frames+0x129/0x2b0 net/ipv4/ip_output.c:1606
 raw_sendmsg+0x1338/0x2df0 net/ipv4/raw.c:645
 inet_sendmsg+0x9d/0xe0 net/ipv4/af_inet.c:827
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xd3/0x120 net/socket.c:734
 sock_no_sendpage+0x10c/0x160 net/core/sock.c:3241
 inet_sendpage+0x107/0x140 net/ipv4/af_inet.c:845
 kernel_sendpage.part.0+0x1d5/0x700 net/socket.c:3555
 kernel_sendpage net/socket.c:3552 [inline]
 sock_sendpage+0xe3/0x140 net/socket.c:1054
 pipe_to_sendpage+0x2b1/0x380 fs/splice.c:361
 splice_from_pipe_feed fs/splice.c:415 [inline]
 __splice_from_pipe+0x449/0x8a0 fs/splice.c:559
 splice_from_pipe fs/splice.c:594 [inline]
 generic_splice_sendpage+0xd8/0x140 fs/splice.c:743
 do_splice_from fs/splice.c:764 [inline]
 do_splice+0xb5b/0x1930 fs/splice.c:1074
 __do_splice+0x134/0x250 fs/splice.c:1139
 __do_sys_splice fs/splice.c:1346 [inline]
 __se_sys_splice fs/splice.c:1328 [inline]
 __ia32_sys_splice+0x199/0x250 fs/splice.c:1328
 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline]
 __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178
 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203
 entry_SYSENTER_compat_after_hwframe+0x70/0x82
RIP: 0023:0xf7f23549
Code: 03 74 c0 01 10 05 03 74 b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00
RSP: 002b:00000000f7efd5cc EFLAGS: 00000296 ORIG_RAX: 0000000000000139
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000000000
RDX: 0000000000000005 RSI: 0000000000000000 RDI: 0000000000040009
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>

Allocated by task 16365:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:371 [inline]
 ____kasan_kmalloc mm/kasan/common.c:330 [inline]
 __kasan_kmalloc+0xa5/0xb0 mm/kasan/common.c:380
 kmalloc include/linux/slab.h:580 [inline]
 kzalloc include/linux/slab.h:720 [inline]
 nf_ct_tmpl_alloc+0x92/0x270 net/netfilter/nf_conntrack_core.c:546
 nft_ct_set_zone_eval+0x41b/0x4f0 net/netfilter/nft_ct.c:270
 expr_call_ops_eval net/netfilter/nf_tables_core.c:214 [inline]
 nft_do_chain+0x2ac/0x1490 net/netfilter/nf_tables_core.c:264
 nft_do_chain_ipv4+0x188/0x200 net/netfilter/nft_chain_filter.c:23
 nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline]
 nf_hook_slow+0xc9/0x1f0 net/netfilter/core.c:614
 nf_hook.constprop.0+0x3ab/0x650 include/linux/netfilter.h:257
 NF_HOOK include/linux/netfilter.h:300 [inline]
 ip_rcv+0x78/0xd0 net/ipv4/ip_input.c:569
 __netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5482
 __netif_receive_skb+0x1f/0x1c0 net/core/dev.c:5596
 process_backlog+0x3e4/0x810 net/core/dev.c:5924
 __napi_poll+0xb8/0x770 net/core/dev.c:6485
 napi_poll net/core/dev.c:6552 [inline]
 net_rx_action+0xa00/0xde0 net/core/dev.c:6663
 __do_softirq+0x1fb/0xadc kernel/softirq.c:571

Freed by task 16365:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 kasan_save_free_info+0x2e/0x40 mm/kasan/generic.c:518
 ____kasan_slab_free mm/kasan/common.c:236 [inline]
 ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1781 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1807
 slab_free mm/slub.c:3787 [inline]
 __kmem_cache_free+0xaf/0x3b0 mm/slub.c:3800
 nf_ct_tmpl_free net/netfilter/nf_conntrack_core.c:567 [inline]
 nf_ct_destroy+0x247/0x320 net/netfilter/nf_conntrack_core.c:589
 nf_conntrack_destroy+0xaf/0x230 net/netfilter/core.c:700
 nf_conntrack_put include/linux/netfilter/nf_conntrack_common.h:37 [inline]
 nf_conntrack_put include/linux/netfilter/nf_conntrack_common.h:34 [inline]
 skb_release_head_state+0x223/0x2a0 net/core/skbuff.c:906
 skb_release_all net/core/skbuff.c:914 [inline]
 __kfree_skb net/core/skbuff.c:930 [inline]
 kfree_skb_reason+0x16d/0x4f0 net/core/skbuff.c:956
 nf_hook_slow+0x187/0x1f0 net/netfilter/core.c:619
 nf_hook.constprop.0+0x3ab/0x650 include/linux/netfilter.h:257
 NF_HOOK include/linux/netfilter.h:300 [inline]
 ip_local_deliver+0x176/0x200 net/ipv4/ip_input.c:254
 dst_input include/net/dst.h:454 [inline]
 ip_rcv_finish+0x1cf/0x2f0 net/ipv4/ip_input.c:449
 NF_HOOK include/linux/netfilter.h:302 [inline]
 NF_HOOK include/linux/netfilter.h:296 [inline]
 ip_rcv+0xae/0xd0 net/ipv4/ip_input.c:569
 __netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5482
 __netif_receive_skb+0x1f/0x1c0 net/core/dev.c:5596
 process_backlog+0x3e4/0x810 net/core/dev.c:5924
 __napi_poll+0xb8/0x770 net/core/dev.c:6485
 napi_poll net/core/dev.c:6552 [inline]
 net_rx_action+0xa00/0xde0 net/core/dev.c:6663
 __do_softirq+0x1fb/0xadc kernel/softirq.c:571

Last potentially related work creation:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:488
 kvfree_call_rcu+0x78/0x8f0 kernel/rcu/tree.c:3376
 drop_sysctl_table+0x3c0/0x4e0 fs/proc/proc_sysctl.c:1709
 unregister_sysctl_table fs/proc/proc_sysctl.c:1747 [inline]
 unregister_sysctl_table+0xc4/0x190 fs/proc/proc_sysctl.c:1722
 lowpan_frags_ns_sysctl_unregister net/ieee802154/6lowpan/reassembly.c:403 [inline]
 lowpan_frags_exit_net+0x5c/0xc0 net/ieee802154/6lowpan/reassembly.c:476
 ops_exit_list+0xb0/0x170 net/core/net_namespace.c:169
 setup_net+0x9bd/0xe60 net/core/net_namespace.c:356
 copy_net_ns+0x31b/0x6b0 net/core/net_namespace.c:483
 create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110
 copy_namespaces+0x3b3/0x4a0 kernel/nsproxy.c:179
 copy_process+0x30d3/0x7520 kernel/fork.c:2269
 kernel_clone+0xeb/0x990 kernel/fork.c:2681
 __do_sys_clone3+0x1cd/0x2e0 kernel/fork.c:2980
 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline]
 __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178
 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203
 entry_SYSENTER_compat_after_hwframe+0x70/0x82

Second to last potentially related work creation:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:488
 insert_work+0x48/0x350 kernel/workqueue.c:1358
 __queue_work+0x693/0x13b0 kernel/workqueue.c:1517
 call_timer_fn+0x1da/0x7c0 kernel/time/timer.c:1700
 expire_timers+0xbb/0x5c0 kernel/time/timer.c:1746
 __run_timers kernel/time/timer.c:2022 [inline]
 __run_timers kernel/time/timer.c:1995 [inline]
 run_timer_softirq+0x326/0x910 kernel/time/timer.c:2035
 __do_softirq+0x1fb/0xadc kernel/softirq.c:571

The buggy address belongs to the object at ffff88806cf09800
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 216 bytes inside of
 512-byte region [ffff88806cf09800, ffff88806cf09a00)

The buggy address belongs to the physical page:
page:ffffea0001b3c200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x6cf08
head:ffffea0001b3c200 order:2 compound_mapcount:0 subpages_mapcount:0 compound_pincount:0
anon flags: 0x4fff00000010200(slab|head|node=1|zone=1|lastcpupid=0x7ff)
raw: 04fff00000010200 ffff888012442c80 0000000000000000 dead000000000001
raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 1849, tgid 1838 (syz-executor.2), ts 1161607862652, free_ts 1122727527544
 prep_new_page mm/page_alloc.c:2531 [inline]
 get_page_from_freelist+0x119c/0x2ce0 mm/page_alloc.c:4283
 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5549
 alloc_pages+0x1aa/0x270 mm/mempolicy.c:2286
 alloc_slab_page mm/slub.c:1851 [inline]
 allocate_slab+0x25f/0x350 mm/slub.c:1998
 new_slab mm/slub.c:2051 [inline]
 ___slab_alloc+0xa91/0x1400 mm/slub.c:3193
 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3292
 __slab_alloc_node mm/slub.c:3345 [inline]
 slab_alloc_node mm/slub.c:3442 [inline]
 __kmem_cache_alloc_node+0x1a4/0x430 mm/slub.c:3491
 __do_kmalloc_node mm/slab_common.c:967 [inline]
 __kmalloc_node_track_caller+0x4b/0xc0 mm/slab_common.c:988
 kmalloc_reserve net/core/skbuff.c:492 [inline]
 __alloc_skb+0xe9/0x310 net/core/skbuff.c:565
 alloc_skb include/linux/skbuff.h:1270 [inline]
 alloc_uevent_skb+0x7b/0x210 lib/kobject_uevent.c:290
 uevent_net_broadcast_tagged lib/kobject_uevent.c:351 [inline]
 kobject_uevent_net_broadcast lib/kobject_uevent.c:412 [inline]
 kobject_uevent_env+0x10f3/0x1620 lib/kobject_uevent.c:593
 rx_queue_add_kobject net/core/net-sysfs.c:1074 [inline]
 net_rx_queue_update_kobjects+0xed/0x510 net/core/net-sysfs.c:1114
 register_queue_kobjects net/core/net-sysfs.c:1774 [inline]
 netdev_register_kobject+0x279/0x400 net/core/net-sysfs.c:2019
 register_netdevice+0xd77/0x1640 net/core/dev.c:10045
 __ip_tunnel_create+0x398/0x570 net/ipv4/ip_tunnel.c:267
 ip_tunnel_init_net+0x2ec/0x9f0 net/ipv4/ip_tunnel.c:1073
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1446 [inline]
 free_pcp_prepare+0x65c/0xc00 mm/page_alloc.c:1496
 free_unref_page_prepare mm/page_alloc.c:3369 [inline]
 free_unref_page+0x1d/0x490 mm/page_alloc.c:3464
 __vunmap+0x85d/0xd30 mm/vmalloc.c:2727
 __vfree+0x3c/0xd0 mm/vmalloc.c:2775
 vfree+0x5e/0x90 mm/vmalloc.c:2806
 bpf_check+0x5ff/0xacc0 kernel/bpf/verifier.c:17070
 bpf_prog_load+0x1543/0x2140 kernel/bpf/syscall.c:2609
 __sys_bpf+0x1435/0x5000 kernel/bpf/syscall.c:4969
 __do_sys_bpf kernel/bpf/syscall.c:5073 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5071 [inline]
 __ia32_sys_bpf+0x78/0xe0 kernel/bpf/syscall.c:5071
 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline]
 __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178
 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203
 entry_SYSENTER_compat_after_hwframe+0x70/0x82

Memory state around the buggy address:
 ffff88806cf09780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88806cf09800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88806cf09880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88806cf09900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88806cf09980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
   0:	03 74 c0 01          	add    0x1(%rax,%rax,8),%esi
   4:	10 05 03 74 b8 01    	adc    %al,0x1b87403(%rip)        # 0x1b8740d
   a:	10 06                	adc    %al,(%rsi)
   c:	03 74 b4 01          	add    0x1(%rsp,%rsi,4),%esi
  10:	10 07                	adc    %al,(%rdi)
  12:	03 74 b0 01          	add    0x1(%rax,%rsi,4),%esi
  16:	10 08                	adc    %cl,(%rax)
  18:	03 74 d8 01          	add    0x1(%rax,%rbx,8),%esi
  1c:	00 00                	add    %al,(%rax)
  1e:	00 00                	add    %al,(%rax)
  20:	00 51 52             	add    %dl,0x52(%rcx)
  23:	55                   	push   %rbp
  24:	89 e5                	mov    %esp,%ebp
  26:	0f 34                	sysenter
  28:	cd 80                	int    $0x80
* 2a:	5d                   	pop    %rbp <-- trapping instruction
  2b:	5a                   	pop    %rdx
  2c:	59                   	pop    %rcx
  2d:	c3                   	retq
  2e:	90                   	nop
  2f:	90                   	nop
  30:	90                   	nop
  31:	90                   	nop
  32:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi
  39:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/02/01 11:28 upstream c0b67534c95c 7374c4e5 .config console log report info ci-qemu-upstream-386 KASAN: use-after-free Write in nf_nat_setup_info
* Struck through repros no longer work on HEAD.