[v6.1] KASAN: use-after-free Write in nf_nat_setup_info

6 views
Skip to first unread message

syzbot

unread,
Feb 2, 2024, 1:38:24 PMFeb 2
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: e5c3b988b827 Linux 6.1.76
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15c244d4180000
kernel config: https://syzkaller.appspot.com/x/.config?x=907f7acef7540378
dashboard link: https://syzkaller.appspot.com/bug?extid=c55eec9136c0d848b161
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/fd64649e0495/disk-e5c3b988.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/257d7545589e/vmlinux-e5c3b988.xz
kernel image: https://storage.googleapis.com/syzbot-assets/25a59d22a12c/Image-e5c3b988.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c55eec...@syzkaller.appspotmail.com

==================================================================
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+0x1778/0x2188 net/netfilter/nf_nat_core.c:633
Write of size 8 at addr ffff0000cef114d8 by task syz-executor.3/15037

CPU: 0 PID: 15037 Comm: syz-executor.3 Not tainted 6.1.76-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x174/0x4c0 mm/kasan/report.c:395
kasan_report+0xd4/0x130 mm/kasan/report.c:495
__asan_report_store8_noabort+0x2c/0x38 mm/kasan/report_generic.c:356
hlist_add_head_rcu include/linux/rculist.h:593 [inline]
nf_nat_setup_info+0x1778/0x2188 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+0x80c/0xad4 net/netfilter/nf_nat_core.c:759
nf_nat_ipv4_fn net/netfilter/nf_nat_proto.c:645 [inline]
nf_nat_ipv4_local_in+0x1bc/0x4bc net/netfilter/nf_nat_proto.c:708
nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline]
nf_hook_slow+0xc8/0x1f4 net/netfilter/core.c:614
nf_hook include/linux/netfilter.h:257 [inline]
NF_HOOK+0x22c/0x3d4 include/linux/netfilter.h:300
ip_local_deliver+0x11c/0x190 net/ipv4/ip_input.c:254
dst_input include/net/dst.h:454 [inline]
ip_rcv_finish+0x224/0x250 net/ipv4/ip_input.c:449
NF_HOOK+0x328/0x3d4 include/linux/netfilter.h:302
ip_rcv+0x78/0x98 net/ipv4/ip_input.c:569
__netif_receive_skb_one_core net/core/dev.c:5528 [inline]
__netif_receive_skb+0x18c/0x400 net/core/dev.c:5642
process_backlog+0x410/0x784 net/core/dev.c:5970
__napi_poll+0xb4/0x3f0 net/core/dev.c:6537
napi_poll net/core/dev.c:6604 [inline]
net_rx_action+0x5cc/0xd3c net/core/dev.c:6715
__do_softirq+0x314/0xe38 kernel/softirq.c:571
____do_softirq+0x14/0x20 arch/arm64/kernel/irq.c:79
call_on_irq_stack+0x24/0x4c arch/arm64/kernel/entry.S:893
do_softirq_own_stack+0x20/0x2c arch/arm64/kernel/irq.c:84
do_softirq+0xf8/0x1ac kernel/softirq.c:472
__local_bh_enable_ip+0x298/0x470 kernel/softirq.c:396
local_bh_enable+0x28/0x34 include/linux/bottom_half.h:33
rcu_read_unlock_bh include/linux/rcupdate.h:829 [inline]
__dev_queue_xmit+0x1a68/0x38d8 net/core/dev.c:4320
dev_queue_xmit include/linux/netdevice.h:3021 [inline]
neigh_hh_output include/net/neighbour.h:528 [inline]
neigh_output include/net/neighbour.h:542 [inline]
ip_finish_output2+0xc58/0x1198 net/ipv4/ip_output.c:228
__ip_finish_output+0x1b0/0x458
ip_finish_output+0x40/0x268 net/ipv4/ip_output.c:316
NF_HOOK_COND include/linux/netfilter.h:291 [inline]
ip_output+0x330/0x49c 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_queue_xmit+0xd8c/0x1840 net/ipv4/ip_output.c:532
ip_queue_xmit+0x5c/0x78 net/ipv4/ip_output.c:546
__tcp_transmit_skb+0x1954/0x3258 net/ipv4/tcp_output.c:1403
tcp_transmit_skb net/ipv4/tcp_output.c:1421 [inline]
tcp_write_xmit+0x131c/0x4e2c net/ipv4/tcp_output.c:2709
__tcp_push_pending_frames+0x98/0x228 net/ipv4/tcp_output.c:2894
tcp_push+0x44c/0x68c net/ipv4/tcp.c:733
tcp_sendmsg_locked+0x2ca8/0x34f8 net/ipv4/tcp.c:1461
tcp_sendmsg+0x40/0x64 net/ipv4/tcp.c:1489
inet_sendmsg+0x15c/0x290 net/ipv4/af_inet.c:839
sock_sendmsg_nosec net/socket.c:718 [inline]
__sock_sendmsg net/socket.c:730 [inline]
____sys_sendmsg+0x55c/0x848 net/socket.c:2514
___sys_sendmsg net/socket.c:2568 [inline]
__sys_sendmmsg+0x318/0x7d8 net/socket.c:2654
__do_sys_sendmmsg net/socket.c:2683 [inline]
__se_sys_sendmmsg net/socket.c:2680 [inline]
__arm64_sys_sendmmsg+0xa0/0xbc net/socket.c:2680
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Allocated by task 15037:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
kasan_save_alloc_info+0x24/0x30 mm/kasan/generic.c:505
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:211 [inline]
kmalloc_trace+0x7c/0x94 mm/slab_common.c:1050
kmalloc include/linux/slab.h:553 [inline]
kzalloc include/linux/slab.h:689 [inline]
nf_ct_tmpl_alloc+0x90/0x1f4 net/netfilter/nf_conntrack_core.c:550
nft_ct_set_zone_eval+0x3c8/0x600 net/netfilter/nft_ct.c:270
expr_call_ops_eval net/netfilter/nf_tables_core.c:214 [inline]
nft_do_chain+0x440/0x1544 net/netfilter/nf_tables_core.c:264
nft_do_chain_ipv4+0x1a4/0x2d8 net/netfilter/nft_chain_filter.c:23
nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline]
nf_hook_slow+0xc8/0x1f4 net/netfilter/core.c:614
nf_hook include/linux/netfilter.h:257 [inline]
NF_HOOK+0x22c/0x3d4 include/linux/netfilter.h:300
ip_rcv+0x78/0x98 net/ipv4/ip_input.c:569
__netif_receive_skb_one_core net/core/dev.c:5528 [inline]
__netif_receive_skb+0x18c/0x400 net/core/dev.c:5642
process_backlog+0x410/0x784 net/core/dev.c:5970
__napi_poll+0xb4/0x3f0 net/core/dev.c:6537
napi_poll net/core/dev.c:6604 [inline]
net_rx_action+0x5cc/0xd3c net/core/dev.c:6715
__do_softirq+0x314/0xe38 kernel/softirq.c:571

Freed by task 15037:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
kasan_save_free_info+0x38/0x5c mm/kasan/generic.c:516
____kasan_slab_free+0x144/0x1c0 mm/kasan/common.c:236
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:244
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+0x2c0/0x4b4 mm/slub.c:3674
kfree+0xcc/0x1b8 mm/slab_common.c:1007
nf_ct_tmpl_free net/netfilter/nf_conntrack_core.c:571 [inline]
nf_ct_destroy+0x198/0x298 net/netfilter/nf_conntrack_core.c:593
nf_conntrack_destroy+0x124/0x2c8 net/netfilter/core.c:703
nf_conntrack_put include/linux/netfilter/nf_conntrack_common.h:37 [inline]
skb_release_head_state+0x180/0x28c 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+0x178/0x47c net/core/skbuff.c:893
nf_hook_slow+0x188/0x1f4 net/netfilter/core.c:619
nf_hook include/linux/netfilter.h:257 [inline]
NF_HOOK+0x22c/0x3d4 include/linux/netfilter.h:300
ip_local_deliver+0x11c/0x190 net/ipv4/ip_input.c:254
dst_input include/net/dst.h:454 [inline]
ip_rcv_finish+0x224/0x250 net/ipv4/ip_input.c:449
NF_HOOK+0x328/0x3d4 include/linux/netfilter.h:302
ip_rcv+0x78/0x98 net/ipv4/ip_input.c:569
__netif_receive_skb_one_core net/core/dev.c:5528 [inline]
__netif_receive_skb+0x18c/0x400 net/core/dev.c:5642
process_backlog+0x410/0x784 net/core/dev.c:5970
__napi_poll+0xb4/0x3f0 net/core/dev.c:6537
napi_poll net/core/dev.c:6604 [inline]
net_rx_action+0x5cc/0xd3c net/core/dev.c:6715
__do_softirq+0x314/0xe38 kernel/softirq.c:571

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

The buggy address belongs to the physical page:
page:000000004c5ffd70 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10ef10
head:000000004c5ffd70 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 fffffc0003512e00 dead000000000003 ffff0000c0002600
raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff0000cef11380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff0000cef11400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff0000cef11480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff0000cef11500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000cef11580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages