Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18061711rwd; Tue, 27 Jun 2023 11:02:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ466x16KapJ6m3/OWJMxfpNp5mMeAVG43MUogHx9ruGkG9by9TaxGI6hBc8PNK2wKIU7TGO X-Received: by 2002:a05:6a20:7196:b0:10c:7676:73af with SMTP id s22-20020a056a20719600b0010c767673afmr15940720pzb.53.1687888975427; Tue, 27 Jun 2023 11:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687888975; cv=none; d=google.com; s=arc-20160816; b=GA+UY/0Ra8aBoYQKhZWgPpzrr9J61RX8fHT2rBrV5mI+NCR93P4XbZQ96/wPpaWX2Q oJiJJ/TVf3fMbsGcraEDkAOr468zhLQYU23JthQ4oihU0qiHnRDRpHdv+Lyjfn8xE4uf 2hpguT4a9r0xOWamy8g3be0wA9R8D/nV4v16OxiWAn0UjNR/wcXqx55B86McyWuBUnTM dKbh2a0eEBdT1v6CGyqHbKdlWd/z2BjONRAuZCY3bHDorYADKO20u0l21vQ3ElaEW7IQ F3wcskDgewNLyi4mWVvHOh5psV8i4xYfD/W1eykm7WX/7KibEVryXzVYtOmL/0eC5Znh 5gXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=WOIqmxjaW3P+LlRmbZ49O1gHpta/KA6PE6kRYNWDh+s=; fh=DE1wrYw37yRMyqW9rtnAxlFdtA+6nyPKla9TFht66fc=; b=TOKfeNxlcZtpMtRk7MxeJQopgI5A2fd9R22DEcNu1ys3+UXxF84xIjR7AJc14SBMjk oAzrynAXb5jU1/xpzo/AMpqWrHXfHzvnFvjX1uexHZH/OosT07JsUBRwIpXqisMUGMnM wCaj/zXhBedjUTM6F+wBF7jexYWLMTFhd/BjtqJHeKkoxmWNa85hzjr/m1zoUC0pxFN2 0CoOUVbLHhwKMwpJQAN/UdF4SXLxXoSi4pGGGaJGDZi6u22d3O2MNS5WAywlnFpTs8+/ YsPiI8ByJAgAii7Ha8CipRaWlAfRvna1wJr7qMnjC7PS/XfXQ0ZDel3XHrkpob9CIIC7 0Y7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=a6tzBkBp; 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=inria.fr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a65664f000000b0055395ce5ba7si7884823pgv.571.2023.06.27.11.02.40; Tue, 27 Jun 2023 11:02:55 -0700 (PDT) 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=@inria.fr header.s=dc header.b=a6tzBkBp; 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=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231536AbjF0Rdc (ORCPT + 99 others); Tue, 27 Jun 2023 13:33:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjF0Rdb (ORCPT ); Tue, 27 Jun 2023 13:33:31 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBD78268C; Tue, 27 Jun 2023 10:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=WOIqmxjaW3P+LlRmbZ49O1gHpta/KA6PE6kRYNWDh+s=; b=a6tzBkBpxC8oq97AbAMWaSxDW8p/GB0PXPcdPfcCqr4TyCgupz07swlh M4ZS8GYPv3YD9upAASVAz0Z1at37LZN0s9CWrpRFX8AXwOV1KrBWsRQ6S 5f10tQA/a97SQQ3Aeo9XsLr0IBvZ6fucjbD+WCpS6199B5rHnOUtAgeoQ E=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.01,163,1684792800"; d="scan'208";a="59972556" Received: from 231.85.89.92.rev.sfr.net (HELO hadrien) ([92.89.85.231]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2023 19:33:28 +0200 Date: Tue, 27 Jun 2023 19:33:27 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Zack Rusin cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, VMware Graphics Reviewers , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 20/26] drm/vmwgfx: use array_size In-Reply-To: <20230623211457.102544-21-Julia.Lawall@inria.fr> Message-ID: References: <20230623211457.102544-1-Julia.Lawall@inria.fr> <20230623211457.102544-21-Julia.Lawall@inria.fr> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 On Fri, 23 Jun 2023, Julia Lawall wrote: > Use array_size to protect against multiplication overflows. > > The changes were done using the following Coccinelle semantic patch: > > // > @@ > size_t e1,e2; > expression COUNT; > identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; > @@ > > ( > alloc( > - (e1) * (e2) > + array_size(e1, e2) > ,...) > | > alloc( > - (e1) * (COUNT) > + array_size(COUNT, e1) > ,...) > ) > // > > Signed-off-by: Julia Lawall > > --- > drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c b/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c > index 829df395c2ed..c72fc8111a11 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c > @@ -88,7 +88,7 @@ int vmw_devcaps_create(struct vmw_private *vmw) > uint32_t i; > > if (gb_objects) { > - vmw->devcaps = vzalloc(sizeof(uint32_t) * SVGA3D_DEVCAP_MAX); > + vmw->devcaps = vzalloc(array_size(SVGA3D_DEVCAP_MAX, sizeof(uint32_t))); > if (!vmw->devcaps) > return -ENOMEM; > for (i = 0; i < SVGA3D_DEVCAP_MAX; ++i) { Hello, I think this patch can be dropped, since it's a multiplication of two constants and no overflow should be possible. julia