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 8A2EC268C43; Tue, 8 Apr 2025 10:54:48 +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=1744109688; cv=none; b=kQ3iwO2Yd2YSqUzfZZ3BNkueRKDJNC6IeyufvG8Jiy7uDQJi90S6ohQNX07ym1SJqE6jwea923jWeAmbQ2HHAmj+omt/MSRKXWdnVOxl5Vh1wnlh7SzGTuTsfxmn4wICS3tHkH2LoJZ10kWljVNQInJ5prcLytKPXUFEf2rZ7VU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744109688; c=relaxed/simple; bh=7/1kARzhQvV5gnwFgRNkwNl3O0m0PwXsI/oyNrZEQsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RV3wHZkJVcMFt2Bd5bexhQ3Ro81bFeRG8lhZ0xnP+j7ZhOpiyD8kBwsn6mLnfdRgTqqCvGGJrllq2dxHiNBN06ZfAR4LIeN/1cfrAfuBgwmZvLxH8dUlsdDC6ojdqNdLXtXoj5X/H4YssjYVdiwDMIN6+KJYoCc7FV8biWNBM8I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UE5w6Qwg; 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="UE5w6Qwg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3D1CC4CEEB; Tue, 8 Apr 2025 10:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744109688; bh=7/1kARzhQvV5gnwFgRNkwNl3O0m0PwXsI/oyNrZEQsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UE5w6QwgX1xvsojS2kMIYifwP3K1m7xRBMLS5pJbB5Btqb/2ZCOtogNVUUT3ryOmo gdGTfrgkY47/YhVaGwhGhiC111mZoiTK5TlXM4f9lEj7JS4A0euyBdRz3/sNAxkuNx XhU0emoOrjDIMiNRSvywGrrVZrE6YzHRqghWmMy8= 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 5.10 017/227] ipvs: prevent integer overflow in do_ip_vs_get_ctl() Date: Tue, 8 Apr 2025 12:46:35 +0200 Message-ID: <20250408104820.913603316@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104820.353768086@linuxfoundation.org> References: <20250408104820.353768086@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 5.10-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 d0b64c36471d5..fb9f1badeddbf 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -2852,12 +2852,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; } @@ -2893,12 +2893,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