Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5877747rwb; Tue, 22 Nov 2022 06:09:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf4FaoJWgLM8QWS+nodJoRoWueN8GGB/TYSZpV8qZnLjU64Oj7hrIRb7sBmyA43r3OHgI4qP X-Received: by 2002:a63:ec50:0:b0:476:df9e:e792 with SMTP id r16-20020a63ec50000000b00476df9ee792mr6717417pgj.210.1669126165983; Tue, 22 Nov 2022 06:09:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669126165; cv=none; d=google.com; s=arc-20160816; b=dxj9UH9Y2U/bvX3rNli4wt3MGNx2E2WB8CbaAsZth8q+8JXH1dkruaBkDYAiUHOSE+ DK6P6/p48BetgtoA/A/nfnl0AwsrrcOc6V0HxmCyIcbee5FhrGwvrKY9d9XrUsAs2vOC dk0mOOVpa+5t0qLaxZK+Lpwxy21En0FNxMYieX829848yFqGTA1NpEKqwPQDjLyW2qo2 GWaHboZ0NfR12cL26gorHQUhJ5AtMzpJG+joUwsxdi044pWIJCTahy9iQ/IVIv3Mc87L 6enFQN5hSIHmKMmVRrv8mY/Qt16k/LUXmLJNsjlBY5ayRaY4tzAdfMmNrgUq/v7koBJ9 s7Xw== 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=7o4pD14do3PwtUywpszD4F3Mfwgc3x+giZDWeJfhizY=; b=hn/JmdVgpJ4bV1KSdSZw5a3C7veGiaan6z8GK8pGz0shAqDxpnyMgas2EudajcdsJf SPKBXyMpwddcFhB/U2sZg9WM2KVBI9XsE/DYjIqGPrRcPrts/jgHauLSbYDF3x+gVWnb YQnXlvf5IkL5q03yZgpHbFJVGGysw1AmY73UzSLenLjF2/S+nQektNyfXnU51et7n1Gg VOtEWcuKgUXvkKvqfwA8YklC3XTFBgJPsvR6W7KMez2+kMq/ZMJA45a4WqVUw+zBn7Gf 1NG6ZTiTbRhmABAYzsGJ09DZ01jUN0Jk3f5145v4mAzX1wEOZ31m0DZpyXSa0Xt5PahR yFgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OwU79Ol2; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a170903019100b001868ee3e594si15812631plg.409.2022.11.22.06.09.13; Tue, 22 Nov 2022 06:09:25 -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=@intel.com header.s=Intel header.b=OwU79Ol2; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233320AbiKVNjT (ORCPT + 90 others); Tue, 22 Nov 2022 08:39:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233836AbiKVNjP (ORCPT ); Tue, 22 Nov 2022 08:39:15 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DF185A6C2; Tue, 22 Nov 2022 05:39:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669124354; x=1700660354; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=baUu216IUMMxROK88p879RcNlQI5RcX61iVIIKzbJhQ=; b=OwU79Ol2ujy/AVOnwaBtc7FBMh0+gf3D3NQLJYPLBOV/gJXX+4HQh4d0 dp6deNDrQejRwbDsN6iMKIoRcPyzSM3LdcBSOeHNcGIRvX2CnbOEgyu1o 7ANX2L7OxI3MXiGu0QO+tKUBTMpJV+O0pBAeLhszx5LQW11v+V9b9uxuO ZGmauEX9bN5mHFd78l6EkBE7iJumg4eqk7uVPl/cEYGRaSOnh8GYOCjZl GEgnLyD2ZbgUQrs0XHSBGDOED6hBomNQl1EuB70pnMn6VkYemsRrpj2wT vmRj5rsMwkG6NcVwlL7tciCxr63DbLjbD2/V0e6+jRmcJ9oBqEeu959Sx g==; X-IronPort-AV: E=McAfee;i="6500,9779,10538"; a="340684535" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="340684535" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2022 05:39:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10538"; a="643723081" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="643723081" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga007.fm.intel.com with ESMTP; 22 Nov 2022 05:39:11 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 2AMDd9CW026835; Tue, 22 Nov 2022 13:39:09 GMT From: Alexander Lobakin To: Maxim Korotkov Cc: Alexander Lobakin , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Guangbin Huang , Andrew Lunn , "Keller, Jacob E" , Tom Rix , Marco Bonelli , Edward Cree , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [PATCH v3] ethtool: avoiding integer overflow in ethtool_phys_id() Date: Tue, 22 Nov 2022 14:39:08 +0100 Message-Id: <20221122133908.422677-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221122122901.22294-1-korotkov.maxim.s@gmail.com> References: <20221122122901.22294-1-korotkov.maxim.s@gmail.com> MIME-Version: 1.0 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 Date: Tue, 22 Nov 2022 15:29:01 +0300 > 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 > --- > 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 Some notes to the process, not the code: 1) I asked to add my Reviewed-by to v3 in the previous thread, it's mandatory for authors to pick-up all the tags before publishing a new revision; 2) when sending v2, v3, ... vN, please have a changelog in the commit message or right below those '---' after your SoB, that makes it easier to review. Thanks, Olek