From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383008; b=Pdvr1MTyW8UVpQOmKwEMlmSmoK7meuM/0+j53GjJGBurNADCQzv8+lACWa5QPXEg3E5v pIkffbvTLyvpPAmUV8iEgumce2aYA7+b/ZCe/8+jxPAa1iaAGeYpbLC767ps9YVbKkzig XW317yuJept5580DJs8oRvTNJcB8IcjDmRyQ8JAUZBt4d8KR7UXd6cGHRkg03kzTXn0KV TfkS829hvw6b0UBDkCGc39Ped6I6e4ybRMc3gaathgXcnuuT8F4cSHcF/Zj4bsdBi4WtQ 98cpVyq0CEFMocY9L2V9xLsk97DrzUy35lRBFnSbMqmYOoWBBxXcSqpdw4/rhTASlBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383008; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=wuSYNW46tgJHbad9/Xr++UolYFifQkz+utQv7wds+mc=; b=oP78Ix4jyp+egmX5x/ktXMYi4ZWpcvFhYujZY0kbayS5tUTtuTRpntjuj5jxqvsK8jeZ aUgFZlK+8oRIgGJgqo4yEouUfNUn0vNeuvRIKiU6vKspsLwLxOou2AWn8Rpyi+UCCmDuQ t3AgTw+OnwEjWfw4viGtMFTwN63TIdQ98a8AnEOYY1nIq0Fiozmld52ZqSSFyBgfkkPqc BFlsvbDvx5ziIjiZjidb7ZOwnuF6PZRIfp43Gp05CkbAVqGQsVAp+pdYgMBUVtMhfEknI J1vw6bzDUyXjw5NlZuj0TCPBSAP7yisvV27AlqnWBKD72DeHkmbm6RTBv+CBIUycaGw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=akNKbcA+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B22F606A322; Fri, 4 Dec 2026 11:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=akNKbcA+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10F051F000CE; Fri, 4 Dec 2026 11:16:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383008; bh=wuSYNW46tgJHbad9/Xr++UolYFifQkz+utQv7wds+mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=akNKbcA+TzOvg5aJ4pYP68VMyiWro2RMZ7vUbTYxgyjSkFUYJm7+D5DJBrnwfW4JC nBmIiasSGhBQdLso5v0FxVj1O9LtEcA99xmaZv1kmwhex7bgpTAvDVRMWt6138Rly6 4jK+eSEX/polQj0kP5OEFaWlDMrkx9tmD8k6GEMc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Julian Anastasov , Axel Mierczuk , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.18 671/703] ipvs: skip cport 0 connections in ip_vs_conn_out_get() Date: Fri, 4 Dec 2026 19:09:30 +0900 Message-ID: <20261204100645.651283081@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Axel Mierczuk [ Upstream commit 5c8d6e2596e0935e2ace0b94e86ffb99e8434cd9 ] ip_vs_conn_out_get() does not filter templates. A template with cport 0 is matched by a packet sent to client port 0 that traverses the out hook, and handle_response() then runs ip_vs_set_state() and the timeout update on a connection that must never see packets. A backup server receives such templates over the unauthenticated sync protocol. An ordinary connection scheduled for a client that uses source port 0 has cport 0 as well and is matched the same way. Apply the rule used by __ip_vs_conn_in_get(): a lookup for client port 0 matches only connections flagged IP_VS_CONN_F_NO_CPORT, which still wait for their cport, and a lookup for a nonzero client port matches only connections without this flag. Test p->vport, which was already compared with cp->cport, instead of reading cp->cport again. ip_vs_ftp_out() relies on the first case: it looks up the data connection with client port 0 to find the IP_VS_CONN_F_NO_CPORT entry created for an earlier PASV or EPSV reply. That lookup keeps working. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Suggested-by: Julian Anastasov Signed-off-by: Axel Mierczuk Signed-off-by: Pablo Neira Ayuso [ sashal: Adjusted the match in ip_vs_conn_out_get() by adding the new NO_CPORT condition to the tree's existing flat if, since the nested-if context in the original patch did not apply. ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/netfilter/ipvs/ip_vs_conn.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c @@ -427,6 +427,8 @@ struct ip_vs_conn *ip_vs_conn_out_get(co if (p->cport == sport && cp->af == p->af && ip_vs_addr_equal(p->af, p->vaddr, &cp->caddr) && ip_vs_addr_equal(p->af, p->caddr, saddr) && + (!p->vport ^ + (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) && p->protocol == cp->protocol && cp->ipvs == p->ipvs) { if (!__ip_vs_conn_get(cp))