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 BB9091BC9E3; Tue, 27 Aug 2024 14:58:45 +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=1724770725; cv=none; b=BexJrXyLc3zFskBV37OULUZlOriNB8PONIw9Ga5bDEQE33Zo1y20qNxMi2HJHm8yjp4A5TaBRDfPiS1Snmf29Z1xNeOgOjeglJ9Tddm2q8ytQiY3Zrxkb/rpyVKeezO4ipfU2/EGd8FcXYz5EOX4949MvF93UcJkbYaxzNPRRng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724770725; c=relaxed/simple; bh=MC6O1tERv/4nfiTmBULjpBSuHsNEiGU58BqlhQAmpaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aL7pEADQLNHmAfJmG8Y23gRyH/qBqdlLBrO89QOc7PVHnwz7htfvvSPUrmU4lpCN6MuK8z69OTy6EjPT1wDhe1KPr2gbosZecGVbAM71+jJruO0J8F2KcHhCFSf1dmFhYJE8XfeJeiZXrtttSp87u9p/rIZebtAYegTVYm7BFP0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k9fAl2rL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="k9fAl2rL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16D41C4AF52; Tue, 27 Aug 2024 14:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1724770725; bh=MC6O1tERv/4nfiTmBULjpBSuHsNEiGU58BqlhQAmpaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k9fAl2rLLmses78U+q7qp3VTCtGRyA7Esvll3ANpvq7KJ4stpRcBiNomBhTKM0fVW nMTrB6HtkyMsRPg/Ta/ygtuV2BagoaT+YUfYfp+EXyqVKMKCnZGAxsF0CKT07xx1Wl AocVyJ4yq7Qg4z8ghTU93nk3q6wzJyASAdKoEFuQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mat Martineau , "Matthieu Baerts (NGI0)" , Jakub Kicinski Subject: [PATCH 6.6 315/341] mptcp: pm: only decrement add_addr_accepted for MPJ req Date: Tue, 27 Aug 2024 16:39:06 +0200 Message-ID: <20240827143855.376899713@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240827143843.399359062@linuxfoundation.org> References: <20240827143843.399359062@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Matthieu Baerts (NGI0) commit 1c1f721375989579e46741f59523e39ec9b2a9bd upstream. Adding the following warning ... WARN_ON_ONCE(msk->pm.add_addr_accepted == 0) ... before decrementing the add_addr_accepted counter helped to find a bug when running the "remove single subflow" subtest from the mptcp_join.sh selftest. Removing a 'subflow' endpoint will first trigger a RM_ADDR, then the subflow closure. Before this patch, and upon the reception of the RM_ADDR, the other peer will then try to decrement this add_addr_accepted. That's not correct because the attached subflows have not been created upon the reception of an ADD_ADDR. A way to solve that is to decrement the counter only if the attached subflow was an MP_JOIN to a remote id that was not 0, and initiated by the host receiving the RM_ADDR. Fixes: d0876b2284cf ("mptcp: add the incoming RM_ADDR support") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20240819-net-mptcp-pm-reusing-id-v1-9-38035d40de5b@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/mptcp/pm_netlink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -837,7 +837,7 @@ static void mptcp_pm_nl_rm_addr_or_subfl mptcp_close_ssk(sk, ssk, subflow); spin_lock_bh(&msk->pm.lock); - removed = true; + removed |= subflow->request_join; if (rm_type == MPTCP_MIB_RMSUBFLOW) __MPTCP_INC_STATS(sock_net(sk), rm_type); } @@ -851,7 +851,11 @@ static void mptcp_pm_nl_rm_addr_or_subfl if (!mptcp_pm_is_kernel(msk)) continue; - if (rm_type == MPTCP_MIB_RMADDR) { + if (rm_type == MPTCP_MIB_RMADDR && rm_id && + !WARN_ON_ONCE(msk->pm.add_addr_accepted == 0)) { + /* Note: if the subflow has been closed before, this + * add_addr_accepted counter will not be decremented. + */ msk->pm.add_addr_accepted--; WRITE_ONCE(msk->pm.accept_addr, true); }