syzbot


KASAN: use-after-free Write in nf_nat_setup_info (2)

Status: upstream: reported on 2024/10/29 01:05
Reported-by: syzbot+e501cd2c647c6837c80d@syzkaller.appspotmail.com
First crash: 23d, last: 10h07m
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in nf_nat_setup_info netfilter 1 659d 659d 0/28 auto-obsoleted due to no activity on 2023/05/10 12:28
linux-6.1 KASAN: use-after-free Write in nf_nat_setup_info 1 292d 292d 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 968d 1048d 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+0x1bb1/0x28d0 net/netfilter/nf_nat_core.c:633
Write of size 8 at addr ffff888059489cd8 by task ksoftirqd/1/21

CPU: 1 PID: 21 Comm: ksoftirqd/1 Not tainted 6.1.118-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 hlist_add_head_rcu include/linux/rculist.h:593 [inline]
 nf_nat_setup_info+0x1bb1/0x28d0 net/netfilter/nf_nat_core.c:633
 __nf_nat_alloc_null_binding net/netfilter/nf_nat_core.c:664 [inline]
 nf_nat_alloc_null_binding net/netfilter/nf_nat_core.c:670 [inline]
 nf_nat_inet_fn+0x9d1/0xce0 net/netfilter/nf_nat_core.c:759
 nf_nat_ipv4_fn net/netfilter/nf_nat_proto.c:645 [inline]
 nf_nat_ipv4_local_in+0x227/0x5a0 net/netfilter/nf_nat_proto.c:708
 nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline]
 nf_hook_slow+0xae/0x1e0 net/netfilter/core.c:614
 nf_hook include/linux/netfilter.h:257 [inline]
 NF_HOOK+0x29a/0x450 include/linux/netfilter.h:300
 NF_HOOK+0x39d/0x450 include/linux/netfilter.h:302
 __netif_receive_skb_one_core net/core/dev.c:5536 [inline]
 __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5650
 process_backlog+0x381/0x760 net/core/dev.c:5978
 __napi_poll+0xc7/0x470 net/core/dev.c:6545
 napi_poll net/core/dev.c:6612 [inline]
 net_rx_action+0x70f/0xeb0 net/core/dev.c:6726
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:571
 run_ksoftirqd+0xc6/0x120 kernel/softirq.c:938
 smpboot_thread_fn+0x52c/0xa30 kernel/smpboot.c:164
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

Allocated by task 9446:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:557 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 nf_ct_tmpl_alloc+0x7a/0x220 net/netfilter/nf_conntrack_core.c:550
 nft_ct_set_zone_eval+0x3b9/0x5c0 net/netfilter/nft_ct.c:270
 expr_call_ops_eval net/netfilter/nf_tables_core.c:214 [inline]
 nft_do_chain+0x4ee/0x1b70 net/netfilter/nf_tables_core.c:264
 nft_do_chain_ipv4+0x1f7/0x310 net/netfilter/nft_chain_filter.c:23
 nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline]
 nf_hook_slow+0xae/0x1e0 net/netfilter/core.c:614
 nf_hook include/linux/netfilter.h:257 [inline]
 NF_HOOK+0x29a/0x450 include/linux/netfilter.h:300
 __netif_receive_skb_one_core net/core/dev.c:5536 [inline]
 __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5650
 process_backlog+0x381/0x760 net/core/dev.c:5978
 __napi_poll+0xc7/0x470 net/core/dev.c:6545
 napi_poll net/core/dev.c:6612 [inline]
 net_rx_action+0x70f/0xeb0 net/core/dev.c:6726
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:571
 __do_softirq kernel/softirq.c:605 [inline]
 invoke_softirq kernel/softirq.c:445 [inline]
 __irq_exit_rcu+0x157/0x240 kernel/softirq.c:654
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:666
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1118 [inline]
 sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1118
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:691

Freed by task 9446:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674
 nf_conntrack_destroy+0x121/0x2c0 net/netfilter/core.c:703
 nf_conntrack_put include/linux/netfilter/nf_conntrack_common.h:37 [inline]
 skb_release_head_state+0x165/0x230 net/core/skbuff.c:846
 skb_release_all net/core/skbuff.c:854 [inline]
 __kfree_skb net/core/skbuff.c:870 [inline]
 kfree_skb_reason+0x13d/0x390 net/core/skbuff.c:893
 nf_hook_slow+0x173/0x1e0 net/netfilter/core.c:619
 nf_hook include/linux/netfilter.h:257 [inline]
 NF_HOOK+0x29a/0x450 include/linux/netfilter.h:300
 NF_HOOK+0x39d/0x450 include/linux/netfilter.h:302
 __netif_receive_skb_one_core net/core/dev.c:5536 [inline]
 __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5650
 process_backlog+0x381/0x760 net/core/dev.c:5978
 __napi_poll+0xc7/0x470 net/core/dev.c:6545
 napi_poll net/core/dev.c:6612 [inline]
 net_rx_action+0x70f/0xeb0 net/core/dev.c:6726
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:571
 __do_softirq kernel/softirq.c:605 [inline]
 invoke_softirq kernel/softirq.c:445 [inline]
 __irq_exit_rcu+0x157/0x240 kernel/softirq.c:654
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:666
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1118 [inline]
 sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1118
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:691

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 insert_work+0x54/0x3d0 kernel/workqueue.c:1361
 __queue_work+0xb4b/0xf90 kernel/workqueue.c:1520
 call_timer_fn+0x1ad/0x6b0 kernel/time/timer.c:1504
 expire_timers kernel/time/timer.c:1544 [inline]
 __run_timers+0x6a8/0x890 kernel/time/timer.c:1820
 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1833
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:571
 __do_softirq kernel/softirq.c:605 [inline]
 invoke_softirq kernel/softirq.c:445 [inline]
 __irq_exit_rcu+0x157/0x240 kernel/softirq.c:654
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:666
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1118 [inline]
 sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1118
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:691

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

The buggy address belongs to the physical page:
page:ffffea0001652200 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88805948a800 pfn:0x59488
head:ffffea0001652200 order:2 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0000a1d908 ffffea000165ef08 ffff888017c41c80
raw: ffff88805948a800 000000000010000d 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4259, tgid 4259 (syz-executor), ts 72683230003, free_ts 21108939506
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517
 prep_new_page mm/page_alloc.c:2524 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4313
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5589
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:935 [inline]
 __kmalloc_node_track_caller+0xa0/0x220 mm/slab_common.c:956
 kmalloc_reserve net/core/skbuff.c:446 [inline]
 __alloc_skb+0x135/0x670 net/core/skbuff.c:515
 alloc_skb include/linux/skbuff.h:1271 [inline]
 nlmsg_new include/net/netlink.h:991 [inline]
 inet_netconf_notify_devconf+0x156/0x210 net/ipv4/devinet.c:2128
 __devinet_sysctl_register+0x238/0x2a0 net/ipv4/devinet.c:2618
 devinet_sysctl_register+0x13a/0x1a0 net/ipv4/devinet.c:2652
 inetdev_init+0x2af/0x4d0 net/ipv4/devinet.c:280
 inetdev_event+0x29b/0x1490 net/ipv4/devinet.c:1547
 notifier_call_chain kernel/notifier.c:87 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:455
 call_netdevice_notifiers_info net/core/dev.c:1970 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2008 [inline]
 call_netdevice_notifiers+0x145/0x1b0 net/core/dev.c:2022
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1444 [inline]
 free_pcp_prepare mm/page_alloc.c:1494 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3369
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3464
 free_contig_range+0x9a/0x150 mm/page_alloc.c:9549
 destroy_args+0xfe/0x997 mm/debug_vm_pgtable.c:1031
 debug_vm_pgtable+0x416/0x46b mm/debug_vm_pgtable.c:1354
 do_one_initcall+0x265/0x8f0 init/main.c:1298
 do_initcall_level+0x157/0x207 init/main.c:1371
 do_initcalls+0x49/0x86 init/main.c:1387
 kernel_init_freeable+0x45c/0x60f init/main.c:1626
 kernel_init+0x19/0x290 init/main.c:1514
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff888059489b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888059489c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888059489c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff888059489d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888059489d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/21 06:15 linux-6.1.y b67dc5c9ade9 4b25d554 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Write in nf_nat_setup_info
2024/11/20 17:31 linux-6.1.y b67dc5c9ade9 4fca1650 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Write in nf_nat_setup_info
2024/11/11 19:40 linux-6.1.y d7039b844a1c 0c4b1325 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Write in nf_nat_setup_info
2024/11/05 02:36 linux-6.1.y 7c15117f9468 509da429 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Write in nf_nat_setup_info
2024/10/29 01:04 linux-6.1.y 7ec6f9fa3d97 9efb3cc7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Write in nf_nat_setup_info
* Struck through repros no longer work on HEAD.