Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5762188rwb; Tue, 22 Nov 2022 04:45:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf7LzQ2LghUP10AN7ZIWjWT0KEjwbz2wwU8gRK/WYkXWB+UboGCBt1l23ptQuBgf1cKR2v8F X-Received: by 2002:a17:90b:4d84:b0:212:9b3f:dee5 with SMTP id oj4-20020a17090b4d8400b002129b3fdee5mr31128663pjb.62.1669121111407; Tue, 22 Nov 2022 04:45:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669121111; cv=none; d=google.com; s=arc-20160816; b=kgDEZWNT5yHrSuFSvu43LGNv5qeetpFpAcYHR4rL0hHxccPULAEm/ScKOgChjA/jrM n2YZbrcfrqoCZCSh7DyDtfu2Bp7nb4+yFJOI7qcWnfWWNyBMIKY/CDAXEfzFkjcVJfPp VCbiUtOQH1t5E0SpTX6BYCSLNLFAeHwitg08QcU97VdwzaZHhwrVnUIQEZZb0NofOFBw Le9LTPkHk4DjZNmMG1f/rlKy5uusIv/Vi6cl5EzB2Ys+sNm8VVnHs4F6TNBG9Ar9yBvQ W6S2DMdpMJagD9c+HPY1ljVGB0KLLDod0Xz+Ns/u1YGJN0i21BEK5QxZPAoDFtbIj62l L8hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=qG9k0HLJtBKzDnSY86wVSnvV+i9S7/oBKCID23f+3EQ=; b=wyyOh2ueW5tyjBIg0RKH9Yhu4T8ZMges1yyWOXYh7fkTi+t+JJ8yCWf2PLor2trZqK VzF31kSre9Ly7g8SFpyeplBVO/mKMcWi8cY+7AV4d6Uxr7iJf+dbPMPa641n3Wr8+bkA YkPFM01SkdkQP4eAsGk8YZxuUggjbcJFdIAeqM9hZuFMdGhOi8mljRhbN5EP777d0yao 8bIFINp5u4WJxyQ9XQvuYMJXtfQlTL7QvWUnSqAQjE/5yemYr0YhYRrHUJvmne09eKxr /VllibuPGcqCQ22BnpIE9+zgiWmYheQ6plHLMV2OV2Nf/kkIhqs6fB/dMA4tLgaVUz9g F6hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZfERH2OQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k188-20020a6324c5000000b004769f0fd662si15297509pgk.362.2022.11.22.04.44.58; Tue, 22 Nov 2022 04:45:11 -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=@gmail.com header.s=20210112 header.b=ZfERH2OQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233147AbiKVM3t (ORCPT + 90 others); Tue, 22 Nov 2022 07:29:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbiKVM3q (ORCPT ); Tue, 22 Nov 2022 07:29:46 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36343450BF; Tue, 22 Nov 2022 04:29:45 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id f13so1818958lfa.6; Tue, 22 Nov 2022 04:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qG9k0HLJtBKzDnSY86wVSnvV+i9S7/oBKCID23f+3EQ=; b=ZfERH2OQIOYLGULfO5tULnn8BtI9Fxe1ZQdtKpjLnpoasPcc5Dd0xOcUnXDO7AJkFQ OZz+/9xuK8faMsN9dDPK+6vuxhwAHyXVW8D7tasLXUzhs4oZoAAkzfBwOZEQ0FN5KRAl qopbsX2DVWqApQozSK48JzE36zHBhb7ImQTSBvx5iONwTGWGQgfrqEiFbxsfML/NFl/b DmLlzoeqbqiID72ASK5EacsK4ZuP322rOi4XN2NgO99PL/zQxje0ACpGrnM3+IwrCg+m SkH0t5wwS0m5mS1/mQuJQ4s6Ghf0cn2/bi4IS0QaE2ST3O6EUYgmxCEZf/165VhB8iNV wYEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qG9k0HLJtBKzDnSY86wVSnvV+i9S7/oBKCID23f+3EQ=; b=OsD9v6n7jau+O08bzO9wWqXEgXgMIsgSiJajeHibqT0HjlOf9Bsyc7zzjCTvBHBL77 FRP8c2HiWkYSYATWb6heeZzm6qGdKsW/jQtKtJka1pDLDe3NvbQcQ9RFlW6Qx7gbJXso Si1RrhDK7TWQF2AZ2GbBG8u+Z7aojFzj9aIdTxtgDWIQSTrFQkwVoJGkb7ZASAzGu7VK K9gtJ6c+hdrpPh1y7T0kZU9x3axS7ywvJsF07zGq8+hJs/JPREWTXEu46IxlPh14OC4t IcsgP7lx0r/ll4O1dtGCIK2LpN1kN+yrMIHB+XYvcUHxDJoQ7hvA/sFctrWxM3ZqVsRM 2WWw== X-Gm-Message-State: ANoB5pnILMwjBFVbK2o9ARzDKljuO8l90i568WBY744wUadwQCt7df6H mmV4SF6rxEqkJo07xvzuoB8= X-Received: by 2002:a05:6512:489:b0:4b4:9193:1caf with SMTP id v9-20020a056512048900b004b491931cafmr1422091lfq.300.1669120181759; Tue, 22 Nov 2022 04:29:41 -0800 (PST) Received: from mkor.rasu.local ([212.22.67.162]) by smtp.gmail.com with ESMTPSA id c16-20020a056512075000b0049462af8614sm2462897lfs.145.2022.11.22.04.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 04:29:41 -0800 (PST) From: Maxim Korotkov To: "David S. Miller" Cc: Maxim Korotkov , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Guangbin Huang , Andrew Lunn , Alexander Lobakin , "Keller, Jacob E" , Tom Rix , Marco Bonelli , Edward Cree , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v3] ethtool: avoiding integer overflow in ethtool_phys_id() Date: Tue, 22 Nov 2022 15:29:01 +0300 Message-Id: <20221122122901.22294-1-korotkov.maxim.s@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 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 --- 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 6a7308de192d..6b59e7a1c906 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2007,7 +2007,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.17.1