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 DA29E26E165 for ; Mon, 18 May 2026 14:47:41 +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=1779115661; cv=none; b=b1XZNMI0mj21MKOa16s1DSfwJE1qZRT6BbkwApqcSIgbocLqg2sSH962PIsEz3kdSLwKQ9Fi1VfmUqLeB2KlPnXdzoHoxlJvqQJgMukzyTCxEsRcdItu/HpGcmrMAb3DI3ur1NmqSh8OKxy5utOFwYh6k887LSKqxIdLue7JQCI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779115661; c=relaxed/simple; bh=i4apSihmRUFm9B1btRn+1wyWvtmY74ADLuawihWxaI0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ELB4grV38gga2AOGjVJsY/z+Vxw81xfSEpJw43FkUBl16ylZ1roi0fI39LbU9jRXjE8M1c999p/TGptSE+V83kOtPDa+My6XyCGKBS7/vjru41A6v7yEJk3AWIivUwR+M+sAKf185zKmH7DokzLRpF32A5S4bB2jtNcUz2E6jxo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZqFi18HZ; 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="ZqFi18HZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24E0EC2BCB7; Mon, 18 May 2026 14:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1779115661; bh=i4apSihmRUFm9B1btRn+1wyWvtmY74ADLuawihWxaI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZqFi18HZ9FbMxHOPhJU4Goi2Qv3QCI0v1NNBgglnEJilJXe6MLHDCGygnL2NqPEjT tejlUShP/1/tAu1lNd7sOSLznB56ctjmwMUsAY3uAKwoaEUweS8Ce2pZQBmoW3cEQI LJfSgGx/C78LqHquakSwDhrC6a4Ai2wvQQ1bOuEX1aLAqXXbSe573XYyE+XFPyvLf/ qN2UExSd1DiKciv9WDAL2mDlN5uimcifSkeHu5CAhg40lVqmhMk2CJm0bj62KOVt2e Iny7TNiT5HJ6sxAIM+aPimMEiSMB5qlELlVCIMcB3vibpNPEjL1y1v8oibY8ZYvjEp 2xpMvNq+c0E2w== From: Sasha Levin To: stable@vger.kernel.org Cc: "Matthieu Baerts (NGI0)" , Mat Martineau , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6.y] mptcp: pm: ADD_ADDR rtx: free sk if last Date: Mon, 18 May 2026 10:47:38 -0400 Message-ID: <20260518144738.1381808-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026051242-guidance-marine-37a7@gregkh> References: <2026051242-guidance-marine-37a7@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 Signed-off-by: Sasha Levin --- net/mptcp/pm_netlink.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 28f8d7fb7bdf3..5469c038a71b2 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -27,6 +27,7 @@ struct mptcp_pm_add_entry { struct list_head list; struct mptcp_addr_info addr; u8 retrans_times; + bool timer_done; struct timer_list add_timer; struct mptcp_sock *sock; struct rcu_head rcu; @@ -314,8 +315,10 @@ static void mptcp_pm_add_timer(struct timer_list *timer) } timeout = mptcp_get_add_addr_timeout(sock_net(sk)); - if (!timeout) + if (!timeout) { + entry->timer_done = true; goto out; + } spin_lock_bh(&msk->pm.lock); @@ -329,6 +332,9 @@ static void mptcp_pm_add_timer(struct timer_list *timer) if (entry->retrans_times < ADD_ADDR_RETRANS_MAX) sk_reset_timer(sk, timer, jiffies + timeout); + else + /* if sock_put calls sk_free: avoid waiting for this timer */ + entry->timer_done = true; spin_unlock_bh(&msk->pm.lock); @@ -336,7 +342,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer) mptcp_pm_subflow_established(msk); out: - __sock_put(sk); + sock_put(sk); } struct mptcp_pm_add_entry * @@ -400,6 +406,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, timer_setup(&add_entry->add_timer, mptcp_pm_add_timer, 0); reset_timer: + add_entry->timer_done = false; timeout = mptcp_get_add_addr_timeout(net); if (timeout) sk_reset_timer(sk, &add_entry->add_timer, jiffies + timeout); @@ -420,7 +427,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