Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1277892pxb; Sun, 12 Sep 2021 13:41:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5KQE8INx3Vtgex35hA5WLVzVm4RCR4QBHhs9Q0WucvPTHE0qk+12NnOVCfuSYvmiuGsDn X-Received: by 2002:a92:db0b:: with SMTP id b11mr1587220iln.275.1631479263061; Sun, 12 Sep 2021 13:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631479263; cv=none; d=google.com; s=arc-20160816; b=SiFe96mPbY/u/780lHvhCm6gJckSzW+szshxKmB/UsdoRhvgkTwsxVhDZG4L0s02Nj 3ifTaG8A9NUU46zKXLeEOuzfWfXIPMps9puUNIdkY1cQKy0V0wfczm+JSblVYm809hBO NoU5knOIopiiisCg8etNe0AK4e7wAl6wm+2JwFP/gJ/9kN5b85wf71AL0TXa5DHC7Yog daIj74B4UeVwKDG/Y+YXLIcriUfU9HnBeb4bnjCq3DAQSPILnqk8wwGfS4B7Fpq5sJGA TIxgSfzY6l3PblOFaiWRw1wZgpBl1KgOv+rg+C2tpFsXUgahTiRvHycP7PqGL8lg5yq9 kj4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=bTvHNmRto0c3Q12aHNZXcfzC8RmgCTvLXG0gbaQDzZs=; b=kSjmUBl+ggob6LX05bFykse+Akg9rRR2X4INpzjmG1NZZFjIoBBOUU9dXVSFXP+Rul g+Ij4SUIN7s+UvXOHx0gOVAY+mwqQILYFH5gxKs5QGFb0QjdmVMLEudgcGargWKKS59/ fLp4wdIlxa1mxpGAD3MruyVn7HdkckA2rdfNvOTRA8btKeKPtvB/Zq8qxu+oJJ7sf6+0 ungTy2qwDweommcN1TeugAqee61IVD3MHLL2wAY4iqLlZ7tJp1orTT7/gXlcoFDuApM6 X59hxADAk1SsPycZ/vLtsehSDCBFOJpcBwlMojCYXUCAC1rrkVEbHPH7nPY/ztrydK1+ G5Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=fAFqb0Rb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si5067319iow.31.2021.09.12.13.40.51; Sun, 12 Sep 2021 13:41:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=fAFqb0Rb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236273AbhILUj0 (ORCPT + 99 others); Sun, 12 Sep 2021 16:39:26 -0400 Received: from gateway22.websitewelcome.com ([192.185.46.233]:39442 "EHLO gateway22.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236410AbhILUjX (ORCPT ); Sun, 12 Sep 2021 16:39:23 -0400 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway22.websitewelcome.com (Postfix) with ESMTP id B2436CF59 for ; Sun, 12 Sep 2021 15:38:06 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id PWEomujeWHlR1PWEomKddR; Sun, 12 Sep 2021 15:38:06 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bTvHNmRto0c3Q12aHNZXcfzC8RmgCTvLXG0gbaQDzZs=; b=fAFqb0RbOxCoSFvl4espjd21av 6BKxxHMhumwxxYvF9U5YBgP72ZOBqSQ/OTdemj8UD1PxU2WU1+6K7LSMDZ9SmSUGwZ2MikTf6wBgu e6/yNw+EuSlEPl8YCr9RdLOg0pr39n1V55xqvIpvQKp75J9VghU4Q3xGfxXVzk0BhHvcoDcH+usbJ qtGFv0dDw8I+aylk5RKvmHON6lX5EJY8ZVdGk7ZxshOyR3y7pS74+YAtiBEf7jEUYieGrtilq7qSl LFfCoT1il5VxYWOQAdxkTSlrSkiGOSKoco4vv9hj3WQynZKVA0uKbHv3mZgJIAcZzq1PVwJQs4GRW OLDyRstA==; Received: from 187-162-31-110.static.axtel.net ([187.162.31.110]:57174 helo=[192.168.15.9]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1mPWEo-000Mwx-5W; Sun, 12 Sep 2021 15:38:06 -0500 Subject: Re: [Intel-wired-lan] [PATCH] ice: Prefer kcalloc over open coded arithmetic To: Len Baker , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski Cc: Kees Cook , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-hardening@vger.kernel.org References: <20210905065020.8402-1-len.baker@gmx.com> From: "Gustavo A. R. Silva" Message-ID: <8cd5adaf-6f83-d3df-abd2-b668d29b50a1@embeddedor.com> Date: Sun, 12 Sep 2021 15:41:49 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210905065020.8402-1-len.baker@gmx.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.31.110 X-Source-L: No X-Exim-ID: 1mPWEo-000Mwx-5W X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-31-110.static.axtel.net ([192.168.15.9]) [187.162.31.110]:57174 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 8 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/5/21 01:50, Len Baker wrote: > As noted in the "Deprecated Interfaces, Language Features, Attributes, > and Conventions" documentation [1], size calculations (especially > multiplication) should not be performed in memory allocator (or similar) > function arguments due to the risk of them overflowing. This could lead > to values wrapping around and a smaller allocation being made than the > caller was expecting. Using those allocations could lead to linear > overflows of heap memory and other misbehaviors. > > In this case this is not actually dynamic sizes: both sides of the > multiplication are constant values. However it is best to refactor this > anyway, just to keep the open-coded math idiom out of code. > > So, use the purpose specific kcalloc() function instead of the argument > size * count in the kzalloc() function. > > [1] https://www.kernel.org/doc/html/v5.14/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments > > Signed-off-by: Len Baker Reviewed-by: Gustavo A. R. Silva BTW... Len, feel free to CC me on all your patches related to KSPP work. :) Thanks -- Gustavo > --- > drivers/net/ethernet/intel/ice/ice_arfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_arfs.c b/drivers/net/ethernet/intel/ice/ice_arfs.c > index 88d98c9e5f91..3071b8e79499 100644 > --- a/drivers/net/ethernet/intel/ice/ice_arfs.c > +++ b/drivers/net/ethernet/intel/ice/ice_arfs.c > @@ -513,7 +513,7 @@ void ice_init_arfs(struct ice_vsi *vsi) > if (!vsi || vsi->type != ICE_VSI_PF) > return; > > - arfs_fltr_list = kzalloc(sizeof(*arfs_fltr_list) * ICE_MAX_ARFS_LIST, > + arfs_fltr_list = kcalloc(ICE_MAX_ARFS_LIST, sizeof(*arfs_fltr_list), > GFP_KERNEL); > if (!arfs_fltr_list) > return; > -- > 2.25.1 > > _______________________________________________ > Intel-wired-lan mailing list > Intel-wired-lan@osuosl.org > https://lists.osuosl.org/mailman/listinfo/intel-wired-lan >