Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5761389rwb; Tue, 22 Nov 2022 04:44:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf5UtJhE9SHuIIxyqgh7xiJrT9pWLpQuc/fAbbhnG+olPRVV3yMaT0/VkfypIc3r8SqfyTXy X-Received: by 2002:a17:903:26ce:b0:187:31da:a27e with SMTP id jg14-20020a17090326ce00b0018731daa27emr3570096plb.111.1669121066106; Tue, 22 Nov 2022 04:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669121066; cv=none; d=google.com; s=arc-20160816; b=LdiswPO3uDMGtkhTHmDW8XrjVf4dOgPlGX5jS+bXLmCzVnkWD/dU91naaSbvXsP2/0 Cw3+VWksD+tSEcosu58uVOTSbTyevXpxwQkSWPj3lYUrZIHpihf2Q4sTOQ9NpessMIxE s+8RYZNbEoeFcMMi5FCRAB7GwaRr5DJXMKzT0VkALHiDYQZKhNfspzScpMpUkwOdcw8H c8BkFgtyYt9MQWbefqypMt8ue0P/GQ8ar9XrJvCqYaTi7rfvjYCyXq/knPWhn7kD+sbw Britxi8EfcrApuBC949N193OxzNUiww35CESEf/zrxCxC3sXdC8sNCpOci3ZVORGKqmA lS/A== 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=bjmgvTgjUXXCynPtn3sA8OC7zyS+PcX+nzvXu9ANdVY=; b=DlV0/yuwV7sbjBMpbuXchU62JK8hnh+sGJ2gUeR4MMbCXdcZrAfG6bdvJzPyw+yoHZ haJuwD4ILDPVw4swJ3tpvJmUvNdjfXDEl+dwnaiOjizuGscGK04danNryCtf4xIztzC2 1evAWf3R0nH6kG2FF2MHKQoIO3isn3ocy0+YrQdQ+Nv3m+mA8BwFNXqBr9oYftZbfHw5 b+kwo8v60MONS7CY8VowBI4e4d8s6hjCxtTl9qfwnwZAQZIK0FMV41j20EHxpy4Ps9n1 E17yxY32Y+T7JZcdTI3tVITjhVUakGWiSSaZNdABXBeYLC4sVwxGDjr6Md7kw6hcZRsr 5Zvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KqegwyE6; 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 y7-20020a17090a474700b00213213d63bbsi12374107pjg.41.2022.11.22.04.44.14; Tue, 22 Nov 2022 04:44:26 -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=KqegwyE6; 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 S233640AbiKVMOl (ORCPT + 91 others); Tue, 22 Nov 2022 07:14:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233643AbiKVMOi (ORCPT ); Tue, 22 Nov 2022 07:14:38 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42E0B30553; Tue, 22 Nov 2022 04:14:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669119278; x=1700655278; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2iUJ6MdJMZ9QlczJ7Cl1gn/iA/sB8KkCg0L+jD78/hw=; b=KqegwyE6aWcwQpu18jsaRNFCbmAOI9RFN0g5XoliZaadh5ZaFkcMrmUX oS+2nZUWyhgxyJsejj6Au/1+MR3HBWku3+JS5dWnEqBXTelzIjrrhql5N VqxqqqqFCRtc4K3QArhVc01yJc5m5CLNqMyHT/O3WNfdBXkifNxRcpPcc TD2y5PuWzGsucvgnfHqUf9rAuPUKRmKhpZpFNsgxm2LkcJeALYXy6uytk WtHQPFjI3d7xN6/ZHLAzqSlX51v0J7Wqusc/8qNBtHui+y+VacPLb3gO9 K8gNBCg3JI5VgnTI6pYf70E9kN8cYPwte2ABrKnXHdwJ2bbzOz+jkazRa g==; X-IronPort-AV: E=McAfee;i="6500,9779,10538"; a="340669177" X-IronPort-AV: E=Sophos;i="5.96,183,1665471600"; d="scan'208";a="340669177" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2022 04:14:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10538"; a="730373146" X-IronPort-AV: E=Sophos;i="5.96,183,1665471600"; d="scan'208";a="730373146" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by FMSMGA003.fm.intel.com with ESMTP; 22 Nov 2022 04:14:27 -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 2AMCEQxo009047; Tue, 22 Nov 2022 12:14:26 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 v2] ethtool: avoiding integer overflow in ethtool_phys_id() Date: Tue, 22 Nov 2022 13:14:00 +0100 Message-Id: <20221122121400.420417-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221122065423.19458-1-korotkov.maxim.s@gmail.com> References: <20221122065423.19458-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 09:54:23 +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 > --- > 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..f845e8be4d7c 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); ^^ Meh, you forgot to put a space after the comma :s Other than that (please add it to a v3): Reviewed-by: Alexander Lobakin > + u64 i = 0; > > do { > rtnl_lock(); > -- > 2.17.1 Thanks, Olek