Article View: linux.kernel.netdev
Article #18512[PATCH 5.15.y v1 0/1] minimal mptcp UAF fix for 5.15
From: Jiayuan Chen
Date: Wed, 18 Nov 2026 12:50
Date: Wed, 18 Nov 2026 12:50
113 lines
12663 bytes
12663 bytes
We encountered an MPTCP-associated use-after-free in kernel 5.15. The
affected applications do not enable MPTCP on purpose: Go turns MPTCP on
for listening sockets by default, so any Go service that calls Listen()
ends up with an MPTCP listener without the application opting in, and even
when the client speaks plain TCP.
In mptcp_close() the listener subflow is orphaned (marked SOCK_DEAD) before
__tcp_close() -> inet_csk_listen_stop() runs on it. A connection whose 3-way
handshake completes in that window is cloned from the already SOCK_DEAD
listener subflow and inherits SOCK_DEAD; a following RST then frees that child
via tcp_done() -> inet_csk_destroy_sock() while it is still linked in the
listener accept queue, and inet_csk_listen_stop() later walks onto the freed
socket.
time line:
close(listen_fd): 3-way handshake & rst (plain TCP client)
mptcp_close
// mark ssk as SOCK_DEAD
sock_orphan(ssk);
__mptcp_destroy_sock
// ssk in conn_list is listen sk
__mptcp_close_ssk
// in 3-way handshake
tcp_v4_syn_recv_sock
// inherit SOCK_DEAD state from listen ssk
inet_csk_clone_lock
// process RST
tcp_reset
tcp_done
// sk is SOCK_DEAD
inet_csk_destroy_sock
sock_put(sk); // freed
__tcp_close(ssk, 0)
// free child
inet_csk_listen_stop()
process child <==== process freed sk
Upstream closed this window with commit 57fc0f1ceaa40 ("mptcp: ensure listener
is unhashed before updating the sk status"), so that would be the one to
backport. But it does not fit 5.15 well:
1. It calls mptcp_subflow_queue_clean() and mptcp_event_pm_listener(), which
are not in 5.15.
2. Its mptcp_disconnect() hunk relies on commit b29fcfb54cd7 ("mptcp: full
disconnect implementation"), which is not in 5.15 either. Without it,
shutdown(SHUT_RD) on a listener leaves the msk in TCP_LISTEN with the
subflow already in TCP_CLOSE, and the WARN_ON_ONCE() in
mptcp_check_listen_stop() fires on close().
3. It needs the follow-up commit 3fffa15bfef4 ("mptcp: ensure subflow is
unhashed before cleaning the backlog") to get the unhash order right.
The simplest fix for 5.15 is this patch: in mptcp_close(), unhash the listener
subflow and drain its accept queue before it is orphaned. A better backport is
welcome.
This may become much easier to hit once services move to a newer Go.
A reproducer (written by an LLM) is at:
https://gist.github.com/mrpre/053f1849b5accec13c0fe9c569739fd7
------------[ cut here ]------------
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 59 PID: 404175 at lib/refcount.c:25 refcount_warn_saturate+0x12e/0x150
RIP: 0010:refcount_warn_saturate+0x12e/0x150
RSP: 0018:ffffad3c8a2d7b68 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffad3c8a2d7b70 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff88f3421c2300
R13: ffff88d43e13b508 R14: ffff88f3421c26f0 R15: ffff88d3df5d4900
FS: 0000000000000000(0000) GS:ffff89127fd40000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000c04e5f8000 CR3: 00000005dfaba004 CR4: 00000000007706e0
PKRU: 55555554
Call Trace:
<TASK>
inet_csk_listen_stop+0x3e1/0x530
__tcp_close+0x3bc/0x440
__mptcp_close_ssk+0xb9/0x210
__mptcp_destroy_sock+0x11c/0x280
mptcp_close+0x25d/0x3b0
inet_release+0x44/0x90
__sock_release+0x42/0xb0
__fput+0x98/0x270
____fput+0xe/0x20
task_work_run+0x6d/0xb0
do_exit+0x1e7/0x3c0
do_group_exit+0x3b/0xb0
get_signal+0x17a/0x940
arch_do_signal_or_restart+0xba/0x130
exit_to_user_mode_loop+0xae/0x160
exit_to_user_mode_prepare+0xad/0xc0
irqentry_exit_to_user_mode+0x9/0x20
irqentry_exit+0x21/0x40
exc_page_fault+0x93/0x190
asm_exc_page_fault+0x27/0x30
Jiayuan Chen (1):
mptcp: fix UAF of child socket on listener close
net/mptcp/protocol.c | 10 ++++++++++
1 file changed, 10 insertions(+)
--
2.43.0
Technical Details
Message-ID:
<20261118125032.200934-1-jiayuan.chen@linux.dev>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366120-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366120-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: [PATCH 5.15.y v1 0/1] minimal mptcp UAF fix for 5.15 Date: Wed, 18 Nov 2026 20:50:30 +0800 Organization: Usenet Network Message-ID: <20261118125032.200934-1-jiayuan.chen@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2596485"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:AgyF/2Pls+4ugyLWqV8t+X+hTtg= sha256:2mF2BtdC9F8hM2RflzL/D4qeeO9EQWnsI4kwF/PnhfM= sha1:YRA4P6/YKfNzC54hMDgUgOjtDyI= sha256:9V7QI22jMH23SQJCi6RaL6dVVap5CQD1WLDBklpbil4= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 27C0E115299; Wed, 18 Nov 2026 15:51:41 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.05 X-Spam-Status: No, score=-2.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HK_RANDOM_FROM=1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FsX_P5YB1mdX; Wed, 18 Nov 2026 15:51:37 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366120-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id EFDA5115285; Wed, 18 Nov 2026 15:51:28 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id AC42932075; Wed, 18 Nov 2026 12:51:26 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795006286; b=qnNO8f93Ngs468EoBoXUJGs1qJQeKBoSoIKjzIGlOXnw14wM28ZTfhUFnaaGa1cIOyJW 6XrwH8AzB4qsG+YC+AUAi7QrwppKglJK5wQAKHo5g+y8GtD2uv+C6UXQd1S3wznEZRu7j F3LFQyO7DU1+c0d6xzPsy7I0CzzFqw6djbcCMOC0DM313mAqg7wpJy4BA+Qz2yIs6qbrk x2VBobWc2Xy0M3brWZZCCceD6owdrYpgDLVAeQBB4TqKybAVc4meL3wZK+4IJ6Bbh0lEi rfC309ID1HKqwcshU+EBJgT7/E9/tlNpKzcj5HPDu5XSKOOu7lz+kETfVCZNVYJIxAA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795006286; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc: Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding; bh=nYuOjm8xQJMsBWaOOrKGxnekKQWVnD5kRNJ5Ku24pwI=; b=aVLkshWnPL9ku1ovaayMqA5oGfT6+b7nh7J0QjchB3WLjfzvHeiwkOOnOoEtU0F6R3vQ 0FeLygkLnfTwavJH6yqbxw2Fdhk4dKteUPzOuBQa4muYX+2Wbu2scNC5IMwlv8/8UgYUv G/jqxmcfJEqnuXjurnp0RvWPaqU/T+EjFDWnuljxU6JWfdY07WwkfPGx8uIl207CGOmEZ 6v2QY7kpV641qXzCuam/kQz2oElIwY/FDu47rPxB+t+DEvMKQGT7XUBPmba5CmgU+bOXy 61sSDj/eePdq8pzkY+ql477AtUlsPjoOh7Vf7VipR6ygjt41LLUiVPVH7IlYV55qKNQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=IVNLBgFz; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 218D9606A338; Wed, 18 Nov 2026 12:51:26 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=IVNLBgFz X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.11 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795006285; b=wtYyECvJITLMeQdixMwQXp5aadMKhg735XDarOOv7PI0wAe0aZSf90kjUkwYsAwd+leh /PC8KEp/puJ6qAJRwj1EGuQ/TLPPdEetTYEZHuxo9UefBeRCHC3FcW3esnO7IyWz9ZCyp GHx5IMPz8/tS2o0i5aNrc69PJXE/nv8h54raJLrA2+nlNqy1SmPcbIMoAgcHQ1eh+/MSZ jFgNXgjOALoU37mhBH29RMRVPA2mNxthozQP5OurWdF+zBeJdFHZ2r6C8p3YDFajOInxs IiqosSDmnBlrl2ZwJkHsjjsY5KjfbHQmOq5P1wxd0sRpHeFuECyobpSUA2L+ZiJeAfQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795006285; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=nYuOjm8xQJMsBWaOOrKGxnekKQWVnD5kRNJ5Ku24pwI=; b=p0I5SbVJtwGsYF8qMnk1LE4EIdVhNGma2Hic4eLeALeII9ZF6tt86Kz1sgzIG5mZWabo W3HO26F4qLvlanQ9oa7KZd/Yvgi1ZfH9l7mWgKTMc6Mc4pnuuPqbk4+S8tmfURKjcan4j KMqFc2AxQq17aR/5eUXJ8xghoKDK2uSApHRT3A1Sq5Yd63y2jtaz4o5EwiIx8neSSIeYK fWzY58k4KwNO+NxghrzmREdrE1ttxudO1KUaxfxid7YTr1P5fFSG6riFXLOLPH8e13P+Y vQNLkJsfIIa/EdlJvGjUgeDdjojPE3pEo/g/wHudQ2LNRxW7vAwfEmBnDLyQb4064Jw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=IVNLBgFz; arc=none smtp.remote-ip=91.218.175.11 X-Received: from mta0.migadu.com (out-11.mta0.migadu.com [91.218.175.11]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EFFB606A32A for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 12:51:23 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4EFFB606A32A X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=S4tIs0eXTP8/ESlTI3EDlKJDy7qEJ4aWifgLG6CtFzY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795006282; v=1; x=1795611082; b=IVNLBgFzmRuyK7s18N4RsxnDzheqIxrl0fZ9T2nZNi5FOD5Q9zBdnc2YDgdZY1E336446/ny +jBxgZoZAumntV9/mRzfLpWHoVOkIwt0E11iG2oJdfRGPXzqgM/Nkarlc/ya/b+WRxKRVdBT0hB aOo+87CphSW7QQyhCTwb1vKk= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id f2a36f7fe13e4e18; Wed, 18 Nov 2026 12:51:22 +0000 X-Mizu-Trace-ID: f2a36f7fe13e4e18 X-Migadu-Flow: FLOW_OUT X-Cc: Jiayuan Chen <jiayuan.chen@linux.dev>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: git-send-email 2.43.0 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list