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: 16h39m, last: 16h39m
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 636d 636d 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 269d 269d 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 945d 1026d 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 ffff88807f06c8d8 by task ksoftirqd/0/15

CPU: 0 PID: 15 Comm: ksoftirqd/0 Not tainted 6.1.114-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/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:5532 [inline]
 __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5646
 process_backlog+0x381/0x760 net/core/dev.c:5974
 __napi_poll+0xc7/0x470 net/core/dev.c:6541
 napi_poll net/core/dev.c:6608 [inline]
 net_rx_action+0x70f/0xeb0 net/core/dev.c:6722
 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 15:
 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:5532 [inline]
 __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5646
 process_backlog+0x381/0x760 net/core/dev.c:5974
 __napi_poll+0xc7/0x470 net/core/dev.c:6541
 napi_poll net/core/dev.c:6608 [inline]
 net_rx_action+0x70f/0xeb0 net/core/dev.c:6722
 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

Freed by task 15:
 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:5532 [inline]
 __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5646
 process_backlog+0x381/0x760 net/core/dev.c:5974
 __napi_poll+0xc7/0x470 net/core/dev.c:6541
 napi_poll net/core/dev.c:6608 [inline]
 net_rx_action+0x70f/0xeb0 net/core/dev.c:6722
 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

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

The buggy address belongs to the physical page:
page:ffffea0001fc1b00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807f06c400 pfn:0x7f06c
head:ffffea0001fc1b00 order:2 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea00009ea208 ffffea00016e6a08 ffff888017c41c80
raw: ffff88807f06c400 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 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3591, tgid 3591 (modprobe), ts 22703681572, free_ts 22701882226
 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+0x322e/0x33b0 mm/page_alloc.c:4290
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5558
 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+0xa1/0x230 mm/slab_common.c:949
 kmalloc include/linux/slab.h:562 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 tomoyo_init_log+0x1b37/0x2040 security/tomoyo/audit.c:275
 tomoyo_supervisor+0x396/0x12d0 security/tomoyo/common.c:2088
 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
 tomoyo_path_permission+0x243/0x360 security/tomoyo/file.c:587
 tomoyo_path_perm+0x478/0x710 security/tomoyo/file.c:838
 security_inode_getattr+0xcf/0x120 security/security.c:1361
 vfs_getattr+0x26/0x360 fs/stat.c:158
 vfs_statx+0x194/0x4b0 fs/stat.c:233
 vfs_fstatat fs/stat.c:267 [inline]
 __do_sys_newfstatat fs/stat.c:437 [inline]
 __se_sys_newfstatat fs/stat.c:431 [inline]
 __x64_sys_newfstatat+0x151/0x1e0 fs/stat.c:431
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
 __stack_depot_save+0x409/0x470 lib/stackdepot.c:506
 kasan_save_stack mm/kasan/common.c:46 [inline]
 kasan_set_track+0x60/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x65/0x70 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
 kmem_cache_alloc_bulk+0x3a2/0x4d0 mm/slub.c:3854
 mt_alloc_bulk lib/maple_tree.c:157 [inline]
 mas_alloc_nodes+0x3df/0x800 lib/maple_tree.c:1299
 mas_node_count_gfp lib/maple_tree.c:1359 [inline]
 mas_preallocate+0x12d/0x350 lib/maple_tree.c:5804
 vma_link+0x15b/0x300 mm/mmap.c:475
 insert_vm_struct+0x30c/0x3e0 mm/mmap.c:3295
 __install_special_mapping+0x193/0x2f0 mm/mmap.c:3543
 map_vdso+0x15b/0x2e0 arch/x86/entry/vdso/vma.c:268
 load_elf_binary+0x1e97/0x2720 fs/binfmt_elf.c:1288
 search_binary_handler fs/exec.c:1744 [inline]
 exec_binprm fs/exec.c:1785 [inline]
 bprm_execve+0x96a/0x18a0 fs/exec.c:1854
 kernel_execve+0x8e6/0xa10 fs/exec.c:2019

Memory state around the buggy address:
 ffff88807f06c780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807f06c800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807f06c880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88807f06c900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807f06c980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
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.