[v5.15] KASAN: use-after-free Read in ovs_ct_exit

0 views
Skip to first unread message

syzbot

unread,
Jan 23, 2024, 5:11:21 PMJan 23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: ddcaf4999061 Linux 5.15.147
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16b68b3be80000
kernel config: https://syzkaller.appspot.com/x/.config?x=8c65db3d25098c3c
dashboard link: https://syzkaller.appspot.com/bug?extid=26577a1b7bc1084a314c
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/fe87fb57528f/disk-ddcaf499.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f64608a2759c/vmlinux-ddcaf499.xz
kernel image: https://storage.googleapis.com/syzbot-assets/84cae5bc6ed5/bzImage-ddcaf499.xz

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

==================================================================
BUG: KASAN: use-after-free in ovs_ct_exit+0x100/0x200 net/openvswitch/conntrack.c:2310
Read of size 8 at addr ffff88807e135780 by task kworker/u4:0/18978

CPU: 0 PID: 18978 Comm: kworker/u4:0 Not tainted 5.15.147-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
Workqueue: netns cleanup_net
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
print_address_description+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
ovs_ct_exit+0x100/0x200 net/openvswitch/conntrack.c:2310
ovs_exit_net+0xea/0x7c0 net/openvswitch/datapath.c:2626
ops_exit_list net/core/net_namespace.c:169 [inline]
cleanup_net+0x6ce/0xb60 net/core/net_namespace.c:596
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
</TASK>

Allocated by task 10663:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
kasan_kmalloc include/linux/kasan.h:264 [inline]
kmem_cache_alloc_trace+0x143/0x290 mm/slub.c:3247
kmalloc include/linux/slab.h:591 [inline]
ovs_ct_limit_set_zone_limit net/openvswitch/conntrack.c:1979 [inline]
ovs_ct_limit_cmd_set+0x2e0/0xad0 net/openvswitch/conntrack.c:2155
genl_family_rcv_msg_doit net/netlink/genetlink.c:731 [inline]
genl_family_rcv_msg net/netlink/genetlink.c:775 [inline]
genl_rcv_msg+0xfbd/0x14a0 net/netlink/genetlink.c:792
netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2505
genl_rcv+0x24/0x40 net/netlink/genetlink.c:803
netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1356
netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1924
sock_sendmsg_nosec net/socket.c:704 [inline]
__sock_sendmsg net/socket.c:716 [inline]
____sys_sendmsg+0x59e/0x8f0 net/socket.c:2431
___sys_sendmsg+0x252/0x2e0 net/socket.c:2485
__sys_sendmsg net/socket.c:2514 [inline]
__do_sys_sendmsg net/socket.c:2523 [inline]
__se_sys_sendmsg+0x19a/0x260 net/socket.c:2521
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 8881:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kmem_cache_free_bulk+0x28f/0x4c0 mm/slub.c:3640
kfree_bulk include/linux/slab.h:448 [inline]
kfree_rcu_work+0x332/0x7a0 kernel/rcu/tree.c:3295
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Last potentially related work creation:
kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
kvfree_call_rcu+0x118/0x8a0 kernel/rcu/tree.c:3596
ovs_ct_limit_exit net/openvswitch/conntrack.c:1918 [inline]
ovs_ct_exit+0xeb/0x200 net/openvswitch/conntrack.c:2310
ovs_exit_net+0xea/0x7c0 net/openvswitch/datapath.c:2626
ops_exit_list net/core/net_namespace.c:169 [inline]
cleanup_net+0x6ce/0xb60 net/core/net_namespace.c:596
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Second to last potentially related work creation:
kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
kvfree_call_rcu+0x118/0x8a0 kernel/rcu/tree.c:3596
ip6addrlbl_net_exit+0x122/0x1a0 net/ipv6/addrlabel.c:347
ops_exit_list net/core/net_namespace.c:169 [inline]
cleanup_net+0x6ce/0xb60 net/core/net_namespace.c:596
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

The buggy address belongs to the object at ffff88807e135780
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
64-byte region [ffff88807e135780, ffff88807e1357c0)
The buggy address belongs to the page:
page:ffffea0001f84d40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e135
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0001d17740 0000001900000018 ffff888011c41640
raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 2965, ts 119887843343, free_ts 119886526715
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
__alloc_pages+0x272/0x700 mm/page_alloc.c:5421
alloc_slab_page mm/slub.c:1775 [inline]
allocate_slab mm/slub.c:1912 [inline]
new_slab+0xbb/0x4b0 mm/slub.c:1975
___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
__slab_alloc mm/slub.c:3095 [inline]
slab_alloc_node mm/slub.c:3186 [inline]
slab_alloc mm/slub.c:3228 [inline]
__kmalloc+0x1c9/0x300 mm/slub.c:4403
kmalloc include/linux/slab.h:596 [inline]
kzalloc include/linux/slab.h:721 [inline]
tomoyo_encode2 security/tomoyo/realpath.c:45 [inline]
tomoyo_encode+0x26b/0x530 security/tomoyo/realpath.c:80
tomoyo_realpath_from_path+0x5a2/0x5e0 security/tomoyo/realpath.c:288
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_path_perm+0x273/0x6b0 security/tomoyo/file.c:822
security_inode_getattr+0xcf/0x120 security/security.c:1348
vfs_getattr+0x26/0x360 fs/stat.c:157
vfs_statx+0x18f/0x3b0 fs/stat.c:225
vfs_fstatat fs/stat.c:243 [inline]
__do_sys_newfstatat fs/stat.c:411 [inline]
__se_sys_newfstatat fs/stat.c:405 [inline]
__x64_sys_newfstatat+0x12c/0x1b0 fs/stat.c:405
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1340 [inline]
free_pcp_prepare mm/page_alloc.c:1391 [inline]
free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
free_slab mm/slub.c:2015 [inline]
discard_slab mm/slub.c:2021 [inline]
__unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
do_slab_free mm/slub.c:3487 [inline]
___cache_free+0xe3/0x100 mm/slub.c:3506
qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
__kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
__kmalloc+0x120/0x300 mm/slub.c:4403
kmalloc include/linux/slab.h:596 [inline]
tomoyo_realpath_from_path+0xd8/0x5e0 security/tomoyo/realpath.c:254
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_check_open_permission+0x22c/0x490 security/tomoyo/file.c:771
security_file_open+0x5f/0xa0 security/security.c:1650
do_dentry_open+0x315/0xfb0 fs/open.c:813
do_open fs/namei.c:3614 [inline]
path_openat+0x2702/0x2f20 fs/namei.c:3748
do_filp_open+0x21c/0x460 fs/namei.c:3775

Memory state around the buggy address:
ffff88807e135680: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff88807e135700: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
>ffff88807e135780: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff88807e135800: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
ffff88807e135880: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================


---
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