From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0132C39DBC9; Sat, 12 Sep 2026 20:02:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789243368; cv=none; b=OFqagHvd1smptf2lxNdKF8hmfEOIPvg+WgtbRwQ00918aiOInhrFE4cI04n0YW2FK4bXaTqWu0EUK8DO6aNqBNpMiN8+yRNEZvq6CkWnEPYFbeFIoDoHtlocwjKKHFeaiYoY27cOVYfzVs8/kh811aT97U8gRKBXdFDwCoF0C4U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789243368; c=relaxed/simple; bh=KuC2lvyRGzWnFV7uaYRDSImoGdD3bhyRwwB77S/sE4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zb97Yr+gBL38rcz9lzuo/+f/vdK1pBczCbarImgD2hZpSeFnVcIh3TzKQfga3ZmcQ8ooa9ptsU+YlWCLnbTM9aiWJeTSAR/qoIgJCC9gDSwzFCZiBhgpWwe03r3bXxiL8/nzP2vn2bt0tLaZY4LJqfs+z/fxR1yBB6uFtGTpJqM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jx+EWzmO; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jx+EWzmO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47DE01F00893; Sat, 12 Sep 2026 20:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789243364; bh=7G63AV1ELVKdt4d7LjJgEwiPg9O3Wkt4WxzzeFr3jHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jx+EWzmOyTJ46WCxejVjFY6yWtpoCsVPSH8BYXJztUmLJKK0nfrGtqP72NqlAelw2 WsbTdsyjizX/rA/cCJtdCqGhm8UhDinWV3gdUu1HXQBbeJgdbpeb6gbS40cbFIpiGr UdZTqnBQBSs/le0KVNWLNdhRmvly6qU7EvfgYSPg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joas Antonio dos Santos , Julian Anastasov , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 729/798] ipvs: fix integer overflow in ftp helper port/address parsing Date: Sat, 12 Sep 2026 09:05:57 +0200 Message-ID: <20260912065533.787980574@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065516.948645775@linuxfoundation.org> References: <20260912065516.948645775@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joas Antonio dos Santos [ Upstream commit e625a9477d12baaff4025c5f9989184a907ea8fc ] ip_vs_ftp_get_addrport() accumulates decimal digits into a __u16 (hport) and into unsigned char (p[]) without checking for overflow. A crafted FTP PASV/EPSV response with an over-long port or address octet wraps the value, so the helper configures the data connection with a truncated port/address. The netfilter conntrack FTP helper had the same defect, fixed in commit 2b413fc689ba ("netfilter: nf_conntrack_ftp: avoid u16 overflows"). Apply the equivalent fix here: widen the port accumulator to u32 and reject values above 65535, and reject address octets above 255. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Joas Antonio dos Santos Acked-by: Julian Anastasov Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/ipvs/ip_vs_ftp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c index 67d0d4f1f0db1..aacb1675db9c1 100644 --- a/net/netfilter/ipvs/ip_vs_ftp.c +++ b/net/netfilter/ipvs/ip_vs_ftp.c @@ -103,7 +103,7 @@ static int ip_vs_ftp_get_addrport(char *data, char *data_limit, char *s, c; unsigned char p[6]; char edelim; - __u16 hport; + __u32 hport; int i = 0; if (data_limit - data < plen) { @@ -145,7 +145,11 @@ static int ip_vs_ftp_get_addrport(char *data, char *data_limit, return -1; c = *data; if (isdigit(c)) { - p[i] = p[i]*10 + c - '0'; + unsigned int val = p[i] * 10 + c - '0'; + + if (val > 255) + return -1; + p[i] = val; } else if (c == ',' && i < 5) { i++; p[i] = 0; @@ -223,6 +227,8 @@ static int ip_vs_ftp_get_addrport(char *data, char *data_limit, if (!isdigit(*s)) break; hport = hport * 10 + *s - '0'; + if (hport > 65535) + return -1; } if (s == data_limit || !hport || *s != edelim) return -1; -- 2.53.0