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

4 views
Skip to first unread message

syzbot

unread,
Sep 25, 2024, 11:12:25 PM9/25/24
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3a5928702e71 Linux 5.15.167
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16e9699f980000
kernel config: https://syzkaller.appspot.com/x/.config?x=4d3fd5cca89ae935
dashboard link: https://syzkaller.appspot.com/bug?extid=5dc118a14eb58c6036d0
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/ef5025f3d708/disk-3a592870.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/776fbdad3aa8/vmlinux-3a592870.xz
kernel image: https://storage.googleapis.com/syzbot-assets/79541db5bd16/bzImage-3a592870.xz

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

==================================================================
BUG: KASAN: use-after-free in mptcp_pm_nl_rm_addr_or_subflow+0x6b8/0xcf0 net/mptcp/pm_netlink.c:792
Read of size 4 at addr ffff8880661b9250 by task syz.0.396/5583

CPU: 0 PID: 5583 Comm: syz.0.396 Not tainted 5.15.167-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 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
mptcp_pm_nl_rm_addr_or_subflow+0x6b8/0xcf0 net/mptcp/pm_netlink.c:792
mptcp_pm_nl_rm_subflow_received net/mptcp/pm_netlink.c:823 [inline]
mptcp_nl_remove_id_zero_address net/mptcp/pm_netlink.c:1453 [inline]
mptcp_nl_cmd_del_addr+0x85a/0x17e0 net/mptcp/pm_netlink.c:1483
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:2503
genl_rcv+0x24/0x40 net/netlink/genetlink.c:803
netlink_unicast_kernel net/netlink/af_netlink.c:1326 [inline]
netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1352
netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1920
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+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f83121cdf39
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f8310646038 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f8312385f80 RCX: 00007f83121cdf39
RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000000008
RBP: 00007f8312240216 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f8312385f80 R15: 00007ffc5d787268
</TASK>

Allocated by task 5583:
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]
kzalloc include/linux/slab.h:721 [inline]
subflow_create_ctx net/mptcp/subflow.c:1607 [inline]
subflow_ulp_init+0x8f/0x470 net/mptcp/subflow.c:1690
__tcp_set_ulp net/ipv4/tcp_ulp.c:143 [inline]
tcp_set_ulp+0x498/0x550 net/ipv4/tcp_ulp.c:164
mptcp_subflow_create_socket+0x64f/0xc10 net/mptcp/subflow.c:1572
__mptcp_socket_create net/mptcp/protocol.c:108 [inline]
mptcp_init_sock+0x114/0x790 net/mptcp/protocol.c:2579
inet_create+0xa35/0xd40 net/ipv4/af_inet.c:383
__sock_create+0x460/0x8d0 net/socket.c:1486
sock_create net/socket.c:1537 [inline]
__sys_socket+0x132/0x370 net/socket.c:1579
__do_sys_socket net/socket.c:1588 [inline]
__se_sys_socket net/socket.c:1586 [inline]
__x64_sys_socket+0x76/0x80 net/socket.c:1586
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 7:
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:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

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
tcp_cleanup_ulp+0x6d/0xe0 net/ipv4/tcp_ulp.c:124
tcp_v4_destroy_sock+0x184/0x700 net/ipv4/tcp_ipv4.c:2297
inet_csk_destroy_sock+0x153/0x370 net/ipv4/inet_connection_sock.c:1040
__tcp_close+0x890/0xec0 net/ipv4/tcp.c:2881
__mptcp_close_ssk+0x1ff/0x470 net/mptcp/protocol.c:2314
mptcp_pm_nl_rm_addr_or_subflow+0x4b4/0xcf0 net/mptcp/pm_netlink.c:789
mptcp_pm_nl_rm_subflow_received net/mptcp/pm_netlink.c:823 [inline]
mptcp_nl_remove_id_zero_address net/mptcp/pm_netlink.c:1453 [inline]
mptcp_nl_cmd_del_addr+0x85a/0x17e0 net/mptcp/pm_netlink.c:1483
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:2503
genl_rcv+0x24/0x40 net/netlink/genetlink.c:803
netlink_unicast_kernel net/netlink/af_netlink.c:1326 [inline]
netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1352
netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1920
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+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff8880661b9200
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 80 bytes inside of
256-byte region [ffff8880661b9200, ffff8880661b9300)
The buggy address belongs to the page:
page:ffffea0001986e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x661b8
head:ffffea0001986e00 order:1 compound_mapcount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888017041b40
raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 5437, ts 217040616240, free_ts 205260605264
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:5423
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]
fib_create_info+0xaab/0x2570 net/ipv4/fib_semantics.c:1478
fib_table_insert+0x213/0x1f90 net/ipv4/fib_trie.c:1231
fib_magic net/ipv4/fib_frontend.c:1093 [inline]
fib_add_ifaddr+0x47f/0x1730 net/ipv4/fib_frontend.c:1115
fib_inetaddr_event+0x12b/0x2b0 net/ipv4/fib_frontend.c:1429
notifier_call_chain kernel/notifier.c:83 [inline]
blocking_notifier_call_chain+0x104/0x1b0 kernel/notifier.c:318
__inet_insert_ifa+0x9f8/0xc10 net/ipv4/devinet.c:553
inet_rtm_newaddr+0x8ca/0x1840 net/ipv4/devinet.c:956
rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5618
netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2503
netlink_unicast_kernel net/netlink/af_netlink.c:1326 [inline]
netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1352
netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1920
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
__vunmap+0x8d4/0xa20 mm/vmalloc.c:2621
kcov_put kernel/kcov.c:417 [inline]
kcov_close+0x27/0x50 kernel/kcov.c:519
__fput+0x3fe/0x8e0 fs/file_table.c:280
task_work_run+0x129/0x1a0 kernel/task_work.c:188
exit_task_work include/linux/task_work.h:33 [inline]
do_exit+0x6a3/0x2480 kernel/exit.c:874
do_group_exit+0x144/0x310 kernel/exit.c:996
get_signal+0xc66/0x14e0 kernel/signal.c:2897
arch_do_signal_or_restart+0xc3/0x1890 arch/x86/kernel/signal.c:867
handle_signal_work kernel/entry/common.c:154 [inline]
exit_to_user_mode_loop+0x97/0x130 kernel/entry/common.c:178
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
__syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307
do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
ffff8880661b9100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880661b9180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880661b9200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880661b9280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880661b9300: fc fc fc fc fc fc fc fc 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

syzbot

unread,
Jan 18, 2025, 4:34:19 PM1/18/25
to syzkaller...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages