KASAN: use-after-free Write in nft_ct_tmpl_put_pcpu

5 views
Skip to first unread message

syzbot

unread,
Jun 7, 2021, 12:06:23 PM6/7/21
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 63d1cb53 Merge tag 'powerpc-5.13-3' of git://git.kernel.or..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=152d1ffbd00000
kernel config: https://syzkaller.appspot.com/x/.config?x=4e950b1ffed48778
dashboard link: https://syzkaller.appspot.com/bug?extid=39a117c889fa105083ea
userspace arch: i386
CC: [core...@netfilter.org da...@davemloft.net f...@strlen.de kad...@netfilter.org ku...@kernel.org linux-...@vger.kernel.org net...@vger.kernel.org netfilt...@vger.kernel.org pa...@netfilter.org]

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

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

==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline]
BUG: KASAN: use-after-free in nf_conntrack_put include/linux/netfilter/nf_conntrack_common.h:33 [inline]
BUG: KASAN: use-after-free in nf_ct_put include/net/netfilter/nf_conntrack.h:176 [inline]
BUG: KASAN: use-after-free in nft_ct_tmpl_put_pcpu+0x135/0x1e0 net/netfilter/nft_ct.c:356
Write of size 4 at addr ffff888028719c00 by task syz-executor.1/25822

CPU: 1 PID: 25822 Comm: syz-executor.1 Not tainted 5.13.0-rc1-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:79 [inline]
dump_stack+0x141/0x1d7 lib/dump_stack.c:120
print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:233
__kasan_report mm/kasan/report.c:419 [inline]
kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:436
check_region_inline mm/kasan/generic.c:180 [inline]
kasan_check_range+0x13d/0x180 mm/kasan/generic.c:186
instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline]
nf_conntrack_put include/linux/netfilter/nf_conntrack_common.h:33 [inline]
nf_ct_put include/net/netfilter/nf_conntrack.h:176 [inline]
nft_ct_tmpl_put_pcpu+0x135/0x1e0 net/netfilter/nft_ct.c:356
__nft_ct_set_destroy net/netfilter/nft_ct.c:529 [inline]
__nft_ct_set_destroy net/netfilter/nft_ct.c:518 [inline]
nft_ct_set_init+0x41e/0x750 net/netfilter/nft_ct.c:614
nf_tables_newexpr net/netfilter/nf_tables_api.c:2725 [inline]
nft_expr_init+0x145/0x2d0 net/netfilter/nf_tables_api.c:2763
nft_set_elem_expr_alloc+0x27/0x280 net/netfilter/nf_tables_api.c:5292
nf_tables_newset+0x1b78/0x32a0 net/netfilter/nf_tables_api.c:4352
nfnetlink_rcv_batch+0x1788/0x25c0 net/netfilter/nfnetlink.c:510
nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:631 [inline]
nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:649
netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927
sock_sendmsg_nosec net/socket.c:654 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:674
____sys_sendmsg+0x6e8/0x810 net/socket.c:2350
___sys_sendmsg+0xf3/0x170 net/socket.c:2404
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2433
do_syscall_32_irqs_on arch/x86/entry/common.c:78 [inline]
__do_fast_syscall_32+0x67/0xe0 arch/x86/entry/common.c:143
do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:168
entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
RIP: 0023:0xf7f18549
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:00000000f55125fc EFLAGS: 00000296 ORIG_RAX: 0000000000000172
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00000000200000c0
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 25822:
kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:428 [inline]
____kasan_kmalloc mm/kasan/common.c:507 [inline]
____kasan_kmalloc mm/kasan/common.c:466 [inline]
__kasan_kmalloc+0x9b/0xd0 mm/kasan/common.c:516
kmalloc include/linux/slab.h:556 [inline]
kzalloc include/linux/slab.h:686 [inline]
nf_ct_tmpl_alloc+0x88/0x230 net/netfilter/nf_conntrack_core.c:565
nft_ct_tmpl_alloc_pcpu net/netfilter/nft_ct.c:371 [inline]
nft_ct_set_init+0x4d6/0x750 net/netfilter/nft_ct.c:567
nf_tables_newexpr net/netfilter/nf_tables_api.c:2725 [inline]
nft_expr_init+0x145/0x2d0 net/netfilter/nf_tables_api.c:2763
nft_set_elem_expr_alloc+0x27/0x280 net/netfilter/nf_tables_api.c:5292
nf_tables_newset+0x1b78/0x32a0 net/netfilter/nf_tables_api.c:4352
nfnetlink_rcv_batch+0x1788/0x25c0 net/netfilter/nfnetlink.c:510
nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:631 [inline]
nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:649
netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927
sock_sendmsg_nosec net/socket.c:654 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:674
____sys_sendmsg+0x6e8/0x810 net/socket.c:2350
___sys_sendmsg+0xf3/0x170 net/socket.c:2404
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2433
do_syscall_32_irqs_on arch/x86/entry/common.c:78 [inline]
__do_fast_syscall_32+0x67/0xe0 arch/x86/entry/common.c:143
do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:168
entry_SYSENTER_compat_after_hwframe+0x4d/0x5c

Freed by task 25821:
kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:357
____kasan_slab_free mm/kasan/common.c:360 [inline]
____kasan_slab_free mm/kasan/common.c:325 [inline]
__kasan_slab_free+0xfb/0x130 mm/kasan/common.c:368
kasan_slab_free include/linux/kasan.h:212 [inline]
slab_free_hook mm/slub.c:1581 [inline]
slab_free_freelist_hook+0xdf/0x240 mm/slub.c:1606
slab_free mm/slub.c:3166 [inline]
kfree+0xe5/0x7f0 mm/slub.c:4216
nf_ct_tmpl_free net/netfilter/nf_conntrack_core.c:586 [inline]
destroy_conntrack+0x225/0x2c0 net/netfilter/nf_conntrack_core.c:609
nf_conntrack_destroy+0xdd/0x220 net/netfilter/core.c:677
nf_conntrack_put include/linux/netfilter/nf_conntrack_common.h:34 [inline]
nf_ct_put include/net/netfilter/nf_conntrack.h:176 [inline]
nft_ct_tmpl_put_pcpu+0x15e/0x1e0 net/netfilter/nft_ct.c:356
__nft_ct_set_destroy net/netfilter/nft_ct.c:529 [inline]
__nft_ct_set_destroy net/netfilter/nft_ct.c:518 [inline]
nft_ct_set_init+0x41e/0x750 net/netfilter/nft_ct.c:614
nf_tables_newexpr net/netfilter/nf_tables_api.c:2725 [inline]
nft_expr_init+0x145/0x2d0 net/netfilter/nf_tables_api.c:2763
nft_set_elem_expr_alloc+0x27/0x280 net/netfilter/nf_tables_api.c:5292
nf_tables_newset+0x1b78/0x32a0 net/netfilter/nf_tables_api.c:4352
nfnetlink_rcv_batch+0x1788/0x25c0 net/netfilter/nfnetlink.c:510
nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:631 [inline]
nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:649
netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927
sock_sendmsg_nosec net/socket.c:654 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:674
____sys_sendmsg+0x6e8/0x810 net/socket.c:2350
___sys_sendmsg+0xf3/0x170 net/socket.c:2404
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2433
do_syscall_32_irqs_on arch/x86/entry/common.c:78 [inline]
__do_fast_syscall_32+0x67/0xe0 arch/x86/entry/common.c:143
do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:168
entry_SYSENTER_compat_after_hwframe+0x4d/0x5c

Last potentially related work creation:
kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
kasan_record_aux_stack+0xe5/0x110 mm/kasan/generic.c:345
__call_rcu kernel/rcu/tree.c:3038 [inline]
call_rcu+0xb1/0x750 kernel/rcu/tree.c:3113
put_ctx kernel/events/core.c:1272 [inline]
put_ctx+0x116/0x1e0 kernel/events/core.c:1265
perf_event_exit_task_context kernel/events/core.c:12661 [inline]
perf_event_exit_task+0x527/0x740 kernel/events/core.c:12690
do_exit+0xc0c/0x2a60 kernel/exit.c:835
do_group_exit+0x125/0x310 kernel/exit.c:923
get_signal+0x47f/0x2150 kernel/signal.c:2818
arch_do_signal_or_restart+0x2a8/0x1eb0 arch/x86/kernel/signal.c:789
handle_signal_work kernel/entry/common.c:147 [inline]
exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
exit_to_user_mode_prepare+0x171/0x280 kernel/entry/common.c:208
__syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:301
__do_fast_syscall_32+0x74/0xe0 arch/x86/entry/common.c:146
do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:168
entry_SYSENTER_compat_after_hwframe+0x4d/0x5c

Second to last potentially related work creation:
kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
kasan_record_aux_stack+0xe5/0x110 mm/kasan/generic.c:345
insert_work+0x48/0x370 kernel/workqueue.c:1331
__queue_work+0x5c1/0xed0 kernel/workqueue.c:1497
call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1431
expire_timers kernel/time/timer.c:1471 [inline]
__run_timers.part.0+0x4a6/0xa50 kernel/time/timer.c:1745
__run_timers kernel/time/timer.c:1726 [inline]
run_timer_softirq+0xb3/0x1d0 kernel/time/timer.c:1758
__do_softirq+0x29b/0x9f6 kernel/softirq.c:559

The buggy address belongs to the object at ffff888028719c00
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 0 bytes inside of
512-byte region [ffff888028719c00, ffff888028719e00)
The buggy address belongs to the page:
page:ffffea0000a1c600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x28718
head:ffffea0000a1c600 order:2 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888011041c80
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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, ts 17340639738, free_ts 0
prep_new_page mm/page_alloc.c:2358 [inline]
get_page_from_freelist+0x1033/0x2b60 mm/page_alloc.c:3994
__alloc_pages+0x1b2/0x500 mm/page_alloc.c:5200
alloc_page_interleave+0x1e/0x1d0 mm/mempolicy.c:2147
alloc_pages+0x238/0x2a0 mm/mempolicy.c:2270
alloc_slab_page mm/slub.c:1644 [inline]
allocate_slab+0x2c5/0x4c0 mm/slub.c:1784
new_slab mm/slub.c:1847 [inline]
new_slab_objects mm/slub.c:2593 [inline]
___slab_alloc+0x4a1/0x810 mm/slub.c:2756
__slab_alloc.constprop.0+0xa7/0xf0 mm/slub.c:2796
slab_alloc_node mm/slub.c:2878 [inline]
__kmalloc_node_track_caller+0x2e6/0x350 mm/slub.c:4595
kmalloc_reserve net/core/skbuff.c:354 [inline]
__alloc_skb+0xde/0x340 net/core/skbuff.c:425
alloc_skb include/linux/skbuff.h:1107 [inline]
nlmsg_new include/net/netlink.h:953 [inline]
mpls_netconf_notify_devconf+0x4a/0x110 net/mpls/af_mpls.c:1188
mpls_dev_sysctl_register+0x1fe/0x2d0 net/mpls/af_mpls.c:1425
mpls_add_dev net/mpls/af_mpls.c:1472 [inline]
mpls_dev_notify+0x214/0x8b0 net/mpls/af_mpls.c:1588
call_netdevice_notifier net/core/dev.c:1821 [inline]
call_netdevice_register_notifiers net/core/dev.c:1829 [inline]
call_netdevice_register_net_notifiers+0xdd/0x2b0 net/core/dev.c:1859
register_netdevice_notifier+0xf5/0x260 net/core/dev.c:1910
mpls_init+0x3a/0x13b net/mpls/af_mpls.c:2725
do_one_initcall+0x103/0x650 init/main.c:1249
page_owner free stack trace missing

Memory state around the buggy address:
ffff888028719b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888028719b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888028719c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888028719c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888028719d00: 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.

syzbot

unread,
Aug 7, 2021, 9:44:19 AM8/7/21
to syzkaller-upst...@googlegroups.com
Sending this report upstream.
Reply all
Reply to author
Forward
0 new messages