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 89AED281529; Tue, 25 Mar 2025 12:25:28 +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=1742905528; cv=none; b=WSqrrh/CF/B61t7Bryg7nHytWr3Ki3EJTfoa/Xvwk9UHRqMvWKNIdi/l3Z1t0J8YRJd2eSnabm+g1n4AfnRWgfPSMl7r2gxYOU4cSVzvXXBVcptq67o/eYwIQUP1T7reGY0waDm7xv4vlNyayHPLWucz0BJ6jHefGL8pC6FoigM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742905528; c=relaxed/simple; bh=QlP5A69xt2vaCERDK+/nAmEneXH1b9c0/rdkDR0AYQQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CHvaxiW13L4QCCGEhCurEkMOFnXpEyHdEKw4osLDxaL1tLYF88Pg30gtX6FPYR6x2SqLi4H9haPdAyVOpLyb+bMwuJJ2GhRiB96w5Sz3uFfjBw/unwM852nKnA+rcFW0Sfd9OtINWLFMMvV9Tx4sKLmiDvsQSoJHdPJ3T638iUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Gdmama6h; 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="Gdmama6h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19EAAC4AF09; Tue, 25 Mar 2025 12:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1742905528; bh=QlP5A69xt2vaCERDK+/nAmEneXH1b9c0/rdkDR0AYQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gdmama6hcViql5qmBDewLXdbQzdwj1ZZTUuTbcARhAUoT9PBZxDz844zS7KwOZoia DIDurpWCs3dDSVQdmv7sUZb+V8QElzwImviB5w+jxBgULfCsQCVWV142ILQblOL9iS YH2Cz5QOxcExDy7PB7UZrl2rSZsVtqZzUMy+XqHE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Julian Anastasov , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.1 024/198] ipvs: prevent integer overflow in do_ip_vs_get_ctl() Date: Tue, 25 Mar 2025 08:19:46 -0400 Message-ID: <20250325122157.274173654@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250325122156.633329074@linuxfoundation.org> References: <20250325122156.633329074@linuxfoundation.org> User-Agent: quilt/0.68 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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 80b78c39eb86e6b55f56363b709eb817527da5aa ] The get->num_services variable is an unsigned int which is controlled by the user. The struct_size() function ensures that the size calculation does not overflow an unsigned long, however, we are saving the result to an int so the calculation can overflow. Both "len" and "get->num_services" come from the user. This check is just a sanity check to help the user and ensure they are using the API correctly. An integer overflow here is not a big deal. This has no security impact. Save the result from struct_size() type size_t to fix this integer overflow bug. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Dan Carpenter Acked-by: Julian Anastasov Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/ipvs/ip_vs_ctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index 18e37b32a5d61..6cc50f05c46c1 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -2854,12 +2854,12 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) case IP_VS_SO_GET_SERVICES: { struct ip_vs_get_services *get; - int size; + size_t size; get = (struct ip_vs_get_services *)arg; size = struct_size(get, entrytable, get->num_services); if (*len != size) { - pr_err("length: %u != %u\n", *len, size); + pr_err("length: %u != %zu\n", *len, size); ret = -EINVAL; goto out; } @@ -2895,12 +2895,12 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) case IP_VS_SO_GET_DESTS: { struct ip_vs_get_dests *get; - int size; + size_t size; get = (struct ip_vs_get_dests *)arg; size = struct_size(get, entrytable, get->num_dests); if (*len != size) { - pr_err("length: %u != %u\n", *len, size); + pr_err("length: %u != %zu\n", *len, size); ret = -EINVAL; goto out; } -- 2.39.5