From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85B1F352000 for ; Tue, 19 May 2026 11:52:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779191574; cv=none; b=aLnGY8ibyRXA/X7Z7e0gDVlrRiS8LEsGDN99IxEYUd+jkmGRgBdoYtqT+ayIDl1n0O7HyHspUINVOKi69ujFTH6Y1Wmrf3/Kyn5t+cy6SzVPptxyMhz92sVd3fYgdLF5RvWSPRqcSq5LjPElJLyCqq+0W+pQOIoo6f3mmHjSdsY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779191574; c=relaxed/simple; bh=dHDjUj4oDqnstJV/PTSe+ZfvnzACIOiWRVglTYH5FP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ouoSGDPDdDicGr3w9hcyr7DDK7S044wsvD8rBYjg4dtYyyH1ABZtQ68k8BECH9EaQXMTrFhCwFmXABz5RZ1Mn+gs1aPmmYEJX7c2Lryi2wZWZxAyDV3kN/V4jaX69b+DvQEcyxVCoG15Mdfpf7V7RWY9IoVmRNVrIXNjCyaalbE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n4JvrFoF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n4JvrFoF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89A59C2BCB3; Tue, 19 May 2026 11:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1779191574; bh=dHDjUj4oDqnstJV/PTSe+ZfvnzACIOiWRVglTYH5FP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n4JvrFoFtaXZw/Xxe47E1CTStGtCab+CVQAiBO0vOFdhhhfmghTsF38r3tqYb3bZO 3AblsZKAW0Xcg5l95jz5VPrgxqOJRgv2lQLt4fS0vpTP47XagFPO25261bUPeUF0vT sX+ERsTQZMLTybCwmKlIIfi8EfpBg1U4+iHvoqjvW/vEb2v+o7iQTktJ8BfLdkPA67 PNVaaP0qj5pjYLzKZKKawnbN0vm1iL8ZdjmLQKgE2xf56AbUi9qSspx70LUUuQz1zW BvWwxqnl/bVRg3fY/UM0QGNayA+zPT1i2rfZLM/06tdD6bhL9p5BRN82DiokoKA85Y aoDdfQ5Q94pYQ== From: Sasha Levin To: stable@vger.kernel.org Cc: "Matthieu Baerts (NGI0)" , Mat Martineau , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10.y] mptcp: pm: ADD_ADDR rtx: free sk if last Date: Tue, 19 May 2026 07:52:51 -0400 Message-ID: <20260519115251.2241418-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026051243-blah-wound-3e54@gregkh> References: <2026051243-blah-wound-3e54@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Matthieu Baerts (NGI0)" [ Upstream commit b7b9a461569734d33d3259d58d2507adfac107ed ] When an ADD_ADDR is retransmitted, the sk is held in sk_reset_timer(), and released at the end. If at that moment, it was the last reference being held, the sk would not be freed. sock_put() should then be called instead of __sock_put(). But that's not enough: if it is the last reference, sock_put() will call sk_free(), which will end up calling sk_stop_timer_sync() on the same timer, and waiting indefinitely to finish. So it is needed to mark that the timer is done at the end of the timer handler when it has not been rescheduled, not to call sk_stop_timer_sync() on "itself". Fixes: 00cfd77b9063 ("mptcp: retransmit ADD_ADDR when timeout") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20260505-net-mptcp-pm-fixes-7-1-rc3-v1-5-fca8091060a4@kernel.org Signed-off-by: Jakub Kicinski [ applied fix to pm_netlink.c instead of pm.c due to pre-split file layout ] Signed-off-by: Sasha Levin --- net/mptcp/pm_netlink.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index b88246b8f21c1..1466634a38234 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -34,6 +34,7 @@ struct mptcp_pm_add_entry { struct timer_list add_timer; struct mptcp_sock *sock; u8 retrans_times; + bool timer_done; struct rcu_head rcu; }; @@ -241,11 +242,14 @@ static void mptcp_pm_add_timer(struct timer_list *timer) if (entry->retrans_times < ADD_ADDR_RETRANS_MAX) sk_reset_timer(sk, timer, jiffies + TCP_RTO_MAX); + else + /* if sock_put calls sk_free: avoid waiting for this timer */ + entry->timer_done = true; spin_unlock_bh(&msk->pm.lock); out: - __sock_put(sk); + sock_put(sk); } struct mptcp_pm_add_entry * @@ -296,6 +300,7 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, add_entry->addr = entry->addr; add_entry->sock = msk; add_entry->retrans_times = 0; + add_entry->timer_done = false; timer_setup(&add_entry->add_timer, mptcp_pm_add_timer, 0); sk_reset_timer(sk, &add_entry->add_timer, jiffies + TCP_RTO_MAX); @@ -316,7 +321,8 @@ void mptcp_pm_free_anno_list(struct mptcp_sock *msk) spin_unlock_bh(&msk->pm.lock); list_for_each_entry_safe(entry, tmp, &free_list, list) { - sk_stop_timer_sync(sk, &entry->add_timer); + if (!entry->timer_done) + sk_stop_timer_sync(sk, &entry->add_timer); kfree_rcu(entry, rcu); } } -- 2.53.0