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 DDD1E1C5F26; Wed, 19 Mar 2025 14:34:16 +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=1742394857; cv=none; b=QCs2MhZNKIpxqaCtXGsTeGe0m9fgz/S2vltCmn7pTv3iCBsuGMLmQSXJNA6iaC29fSk4NnsyPOa2TKW9yBnYUpBNVhYyiVWuT68udcML2rtnU+it1fkXo29Kf8h9gq8vbvwhrvUNQbMxSb197XhcZafHF3HWbM1lsXsW0sDWr6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742394857; c=relaxed/simple; bh=ulLwxkscGtLiDwKGt4jAC777deW5Wjm8poFLavZNWQA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sn0Owx2aFRxv3kXeAOgFWe23ILlxcnO9TzippL55nelpCCiycKUw4jWWSDd5lTxa6441ml6L6sa2y9CeLsSvgE2rKVcYK4HsqSz41YYqLDHI+nTF2+9+61Vhz9aKO3N+qS6kCe4gxWO6ytCBXjSh+jpSBwXVucT2w7Tt5n1Aj8o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IMBC+wl6; 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="IMBC+wl6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3F36C4CEEC; Wed, 19 Mar 2025 14:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1742394856; bh=ulLwxkscGtLiDwKGt4jAC777deW5Wjm8poFLavZNWQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IMBC+wl6lsZfB4xNQuCGrt1X0O3FcaoGfnVdRK/fpeDQQzPkKkFkGrYf6HMcOIxVQ 9CGjqM/aDKgNeMVP0jrwWN3Ye4ImgJ57X0mD7wlGuwh+PdsGHiRBHNMTLpY82iRB7o TwD5wgcukF0BhqHdbLSNL375BLabQ2CjHVcJ/Wxs= 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.13 045/241] ipvs: prevent integer overflow in do_ip_vs_get_ctl() Date: Wed, 19 Mar 2025 07:28:35 -0700 Message-ID: <20250319143028.835592846@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250319143027.685727358@linuxfoundation.org> References: <20250319143027.685727358@linuxfoundation.org> User-Agent: quilt/0.68 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.13-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 7d13110ce1882..0633276d96bfb 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -3091,12 +3091,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; } @@ -3132,12 +3132,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