Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1470748rwj; Sun, 18 Dec 2022 08:49:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXtz+D/x0zWHCICSnmDMAgpizcdJs/hZ1YB3yZSPKHxC8Q1ZU1TDm0p4LQOPW416iE8BnEUU X-Received: by 2002:a17:906:278e:b0:7c1:31b:2181 with SMTP id j14-20020a170906278e00b007c1031b2181mr7504730ejc.19.1671382152779; Sun, 18 Dec 2022 08:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671382152; cv=none; d=google.com; s=arc-20160816; b=MVwQU1kQeWI9dlnZ9MKSeqtCxuT1eyV+FaQtE6e7mvPk9v8wyVqOcXbXEa5LsMOnHh n/C7mZgZMvuoLYVNUVT6S9oMpMU3ag+WpUJFq0GnVw91I5odwYvDJKyYEC/RcKcrl48k Wew/3d4L/6uZmHXsKoVM2Rre884XRWNdKkV2542GGH+Aqz2VbR8sj1CcGMhRK40SepZD qtoWUCJYwbRcXl8FIpfgWl+mfbXK6V0ZniU612I53Ghs95ugNlAHVd2ChzDqZBclWhS3 UYjJGjwFf7uFIsNXbZHZSNKc4SRLdlgwECOP/c38/isOX0mOE3jFWZFmmoDwBcc2x+Ev TL9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8tQqQzzpSwhowg2AEJB/FgIrORpqolVoA6xL+gzrCzA=; b=0m5+Cwxc0AbXeHyOl79InsBWN+XDbfA9i2uAZ5ISthMuuGG7PNL/VfTe114c37OVIt HG3wqida2gEpkoV7hjIujnQKuczW8Wl3hQNbCzLeVxTiGf3EGdxl+Td2iceua8SZ1izb sOdiJ9U95k9ej9qXTdbxFBzhU1mwNU3mjbbmshxelqXQShvlTJSRrfw7WPKG8gylLvZK g7b2qgAw04cFDKIyoVo3dwTFi+KdwtJJ07G3Fvfszhw3ix9/yxHB+wYSkV5/KtE+4TP3 BTEC1WuSlvmR1Og27SZFm+mhM6idvDeHRpqIrQIQpQs7XZd0muG9TGheqAvdenyXvVmH nxkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="V4FpC/az"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020a05640226d100b0046b21c5f201si8003423edd.386.2022.12.18.08.48.56; Sun, 18 Dec 2022 08:49:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="V4FpC/az"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232609AbiLRQnK (ORCPT + 70 others); Sun, 18 Dec 2022 11:43:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232563AbiLRQlW (ORCPT ); Sun, 18 Dec 2022 11:41:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A819FF5B8; Sun, 18 Dec 2022 08:15:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 46F1160C99; Sun, 18 Dec 2022 16:15:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B521C433EF; Sun, 18 Dec 2022 16:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671380099; bh=zj4Qla6FW38MAVqVWW2OZCFZVQ7hi5ig+svWj3pUsPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V4FpC/az2dBLGt0j3Fs5Snuz5yuvuh27IC81wQzxM4XYOWY5Xiqa3DrDBh07gfiDM cvyT/7oafMHhU/ZrP6UkQr48FYCqcx1cWXvwEn4E1ZNUrvZRErmJ1Bi1JvECFnw0r3 QFgDkfwZfSKdpsQI4jpwdpANt8Audq3ft8Y5OKKuLDpfXiaNeJnwYG2GBTIiobbCC+ dhiNNBKXpLUnOAPh3BO3RC7wTnut6mWfuU8drBSrqq2zay40vfzupXbnq6VPxS1NpB AojgEAOGHtoLfMKoyN9LmhumxF35bhmQWayyaO2/jQDziwIh/2W+qc7josjn7GaR5X bH1LZLPDpWvcw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Maxim Korotkov , Alexander Lobakin , Andrew Lunn , Jakub Kicinski , Sasha Levin , davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, f.fainelli@gmail.com, trix@redhat.com, wsa+renesas@sang-engineering.com, sean.anderson@seco.com, marco@mebeim.net, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 33/46] ethtool: avoiding integer overflow in ethtool_phys_id() Date: Sun, 18 Dec 2022 11:12:31 -0500 Message-Id: <20221218161244.930785-33-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221218161244.930785-1-sashal@kernel.org> References: <20221218161244.930785-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 e4983f473a3c..6991d77dcb2e 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1988,7 +1988,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