All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
To: mptcp@lists.linux.dev, stable@vger.kernel.org,
	gregkh@linuxfoundation.org
Cc: Florian Westphal <fw@strlen.de>,
	sashal@kernel.org, Matthieu Baerts <matthieu.baerts@tessares.net>,
	Mat Martineau <mathew.j.martineau@linux.intel.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Subject: [PATCH 5.10.y 1/3] mptcp: hold mptcp socket before calling tcp_done
Date: Sat, 19 Sep 2026 22:40:04 +0200	[thread overview]
Message-ID: <20260919204002.2106015-6-matttbe@kernel.org> (raw)
In-Reply-To: <20260919204002.2106015-5-matttbe@kernel.org>

From: Florian Westphal <fw@strlen.de>

commit ab82e996a1fa1b9ae514fa357d9ce8df62321157 upstream.

When processing options from tcp reset path its possible that
tcp_done(ssk) drops the last reference on the mptcp socket which
results in use-after-free.

Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 2b0f561f21b2 ("mptcp: avoid unneeded actions on subflow reset")
[ Conflicts in subflow.c, because commit 3ba14528684f ("mptcp: avoid
  setting TCP_CLOSE state twice") has already been backported and also
  had the same conflict: this commit here should have been backported
  first. Fixed now! ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/subflow.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index c9cf0fdbfbdc..77cc4f585cd8 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -279,11 +279,16 @@ void mptcp_subflow_reset(struct sock *ssk)
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
 	struct sock *sk = subflow->conn;
 
+	/* must hold: tcp_done() could drop last reference on parent */
+	sock_hold(sk);
+
 	tcp_send_active_reset(ssk, GFP_ATOMIC);
 	tcp_done(ssk);
 	if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags) &&
 	    schedule_work(&mptcp_sk(sk)->work))
-		sock_hold(sk);
+		return; /* worker will put sk for us */
+
+	sock_put(sk);
 }
 
 static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
-- 
2.55.0


  reply	other threads:[~2026-09-19 20:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 20:40 [PATCH 5.10.y 0/3] mptcp: fix recent failed backports (20260919) Matthieu Baerts (NGI0)
2026-09-19 20:40 ` Matthieu Baerts (NGI0) [this message]
2026-09-20  7:36   ` Patch "mptcp: hold mptcp socket before calling tcp_done" has been added to the 5.10-stable tree gregkh
2026-09-19 20:40 ` [PATCH 5.10.y 2/3] mptcp: avoid unneeded actions on subflow reset Matthieu Baerts (NGI0)
2026-09-20  7:36   ` Patch "mptcp: avoid unneeded actions on subflow reset" has been added to the 5.10-stable tree gregkh
2026-09-19 20:40 ` [PATCH 5.10.y 3/3] mptcp: close race between scheduler and state change Matthieu Baerts (NGI0)
2026-09-19 20:53   ` sashiko-bot
2026-09-20  7:36   ` Patch "mptcp: close race between scheduler and state change" has been added to the 5.10-stable tree gregkh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260919204002.2106015-6-matttbe@kernel.org \
    --to=matttbe@kernel.org \
    --cc=fw@strlen.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=mathew.j.martineau@linux.intel.com \
    --cc=matthieu.baerts@tessares.net \
    --cc=mptcp@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.