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=1796356001; b=lpHyhFwdAdyNFkARcEEIvGmySbRaMT8FIigQ/VRzODHotJvC2NoJAINhFfdxRfaNNf6w qqbki2xZlsZwwBMtj/Y0cDKI31bJS6xv2UXK9VZr/DZAlZMVfyQA33vZ3S0Fv+VY4ozAk cLdMOAMRvJcTPVDWBH/3JtBWIVQr3FOfWiy17TRxJh/UzYBXuoSVSzGdJWuq5YNhQpNJ3 gTwuWXWZgfiLjaY8gK8nL3r2P8j1YsaVMtFRCFLOeLHNR8bpIdGC0s1gLbqsEdQOgfkt2 KUPNMfjt1jwYU5CuziXFIZdgVY47nlac46OV7ufYw48LRtAL1MvBZAvJ7zWrnPU5Jkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796356001; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=Uvler1fIEcJTd4ddOAc1PpxponiKP+6mwAxfUaemnUs=; b=RB5sudOi/OEl9m57mSNeCvIITQzawNkswF75OnDtpCtXtkmyUqRrKquG/2gmjKPDG6NU sJZgSBXWiwvp/2fo1JkxriHoydXN8ps0oSszKf7qbS3wzd5PRU4W0sUu3CPsOZ2CP7JvW qVUs+ecbZtMve0L4VBDiIm2PVW/EBM9gv+gCJseJTmQnEXuLH+rkKMUO2W2LZIRa2SGAH SmodSgnbknoSnOTzuGj6h0AY2Sx3rra4YBRMF04HNXGYW/gXlEfZOyN7tGMoBYgSdgNIS E7xvNatq5tIvK1erI88iqFLM5wz8uojRREq8svV/x4Ji3vS0pZJHEQvOnwWLgLnZ4/w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MqhmDYUA; 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 04A35606A330 for ; Fri, 4 Dec 2026 03:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MqhmDYUA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 313DC1F000C2; Fri, 4 Dec 2026 03:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796356000; bh=Uvler1fIEcJTd4ddOAc1PpxponiKP+6mwAxfUaemnUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MqhmDYUARaTGNxlU/fxHTYitLMtf/eLC+bKp/92FhWE9IMHYhkeYRYWUQp6e38Rlk aztLCW/tVgKt+tgNlSaVZaIyZxsUkig1Csz2ZNb7t9wv/3VWozSwEwvyrMqt9+6vQe LAHw5YCBXDrgXjTLdI1+/4UbTWOKHzp6fTHEShqbPjAZSPvHF8oUUWvCdaOlnL3enU NWFKSk3W1U9FZ0zp44QZowVY7Dg1KBQr1OIeCHC5Cbpf2Jn8igFPwo0Dd9luBPp5DZ a/8I16wyMPP7mY/Zu4EZBnoUedxUyhn2vljO29fXgvjcl6eFoHk5B5NU5fUyPxONek kXD4ck9Ws3MYA== From: Sasha Levin To: stable@vger.kernel.org Cc: Axel Mierczuk , Julian Anastasov , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.18.y] ipvs: skip cport 0 connections in ip_vs_conn_out_get() Date: Thu, 3 Dec 2026 22:46:38 -0500 Message-ID: <20261204034611.2489004-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120221-blank-breeches-c72b@gregkh> References: <2026120221-blank-breeches-c72b@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- net/netfilter/ipvs/ip_vs_conn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index 1985c90c3aef6..46e9a1d2fa778 100644 --- 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(const struct ip_vs_conn_param *p) 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)) -- 2.53.0