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 541631C08 for ; Wed, 28 Dec 2022 16:52:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C09E1C433D2; Wed, 28 Dec 2022 16:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672246323; bh=PQTkkO2TEez+Hevl8IFWz7Fj4RaHB0oBJSP09rZ7HLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YAsIN9iThNwJKaxkGFQpJV1pJ32H6v0ITqAmwmCTU9au1Gsw/viYgq3ezJncoW63v QOxw2lXJ8Mgke+s/0QrSzv89aCyPwk3EoarDK3854qtXNmyev4rjUo8U/IcLnj8YM+ KiV+NFcH1pGObec4CdL363mEDOffDNUR+xefhu4E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Maxim Korotkov , Alexander Lobakin , Andrew Lunn , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 1021/1146] ethtool: avoiding integer overflow in ethtool_phys_id() Date: Wed, 28 Dec 2022 15:42:40 +0100 Message-Id: <20221228144358.102950763@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144330.180012208@linuxfoundation.org> References: <20221228144330.180012208@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Maxim Korotkov [ Upstream commit 64a8f8f7127da228d59a39e2c5e75f86590f90b4 ] The value of an arithmetic expression "n * id.data" is subject to possible overflow due to a failure to cast operands to a larger data type before performing arithmetic. Used macro for multiplication instead operator for avoiding overflow. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Maxim Korotkov Reviewed-by: Alexander Lobakin Reviewed-by: Andrew Lunn Link: https://lore.kernel.org/r/20221122122901.22294-1-korotkov.maxim.s@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ethtool/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 57e7238a4136..81fe2422fe58 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2008,7 +2008,8 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) } else { /* Driver expects to be called at twice the frequency in rc */ int n = rc * 2, interval = HZ / n; - u64 count = n * id.data, i = 0; + u64 count = mul_u32_u32(n, id.data); + u64 i = 0; do { rtnl_lock(); -- 2.35.1