Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18046719rwd; Tue, 27 Jun 2023 10:49:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7OKolmVHXzDUAY9nDseGbqYtl/9y9hbbzuW6zV0fmwX45Hry54rYDCorNIioHM4CLaYGQH X-Received: by 2002:a17:902:f54b:b0:1b6:8a99:4979 with SMTP id h11-20020a170902f54b00b001b68a994979mr7502938plf.22.1687888188561; Tue, 27 Jun 2023 10:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687888188; cv=none; d=google.com; s=arc-20160816; b=qYMg6bGYZjT3ZLpKapGEERc7uT2nx2RIE0qexizAiMdwpPf4F2qJHkM9up1nbQAxmh U4dxXvF19J75oZkREwCSURV/p529cX2iqUVITmq6oS+a5OqVK3sUyrd6CVeA1AnPHMiM 40oBGQd6iMjKx36CajBD8+JHIhIKgedc+ypc4s2UQVC5TGQR0dVOQWqUbFZzzqC4BaTE IL6BmuAmsUHuyhcLNPPPt6hmXjCEBox3z5qe4LR/kO11rJ2cmXSyW2l370LB/kdHEQNr Lr/KQnIvg4En5uizr1AFh+1LxzQaeZ/ol+4jSTEKvDHon5XHMCbnwV2dJ8/mwUR91C+T UwOA== 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=iIHKX23DruyWxNvBPEkGuI6LxtvA8lzHrP07ul+XeWg=; fh=6ck0YXXnRJ19//ghdBv9OV2JguUi8iNQUskZ6PG0gdQ=; b=fsHcEWu/fUkJtqfMeChhCfMX4Bbh5ix7TTlfIWbNnE7x42MYy+tAJJ0zSgHA7p70xx Gf6mnympretxDwaX5gihSXI3kjBX10SiJ4w6YF1ZTytECJ0CToBCHdeyvKmdxY4BVM2k Kgz10NUayTDtXeXto1p14qiI01fngOfXFX7RhzTmcVfteg7hUUSe2Xp1RyGirJQ44O+H LGrRBK15abtvc0jSY8QS537aZpGeDmSYAofCW08NbHVAR0LciqETzLgvdfjqS4VAMkpg pUw8xQT4d9ku76dTSgj3/LH7O2TO85KVuZndl9MSOR9SOxDtBN3GGZN5c/G0Ps3nXKBw 7zag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Ixk+uerC; 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 p11-20020a170902bd0b00b001a4fc13dfa5si7155780pls.276.2023.06.27.10.49.36; Tue, 27 Jun 2023 10:49:48 -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=Ixk+uerC; 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 S231584AbjF0Rfx (ORCPT + 99 others); Tue, 27 Jun 2023 13:35:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230482AbjF0Rfv (ORCPT ); Tue, 27 Jun 2023 13:35:51 -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 510E4269E; Tue, 27 Jun 2023 10:35:49 -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=iIHKX23DruyWxNvBPEkGuI6LxtvA8lzHrP07ul+XeWg=; b=Ixk+uerCSeTIr9ry6BMbctwfqD/cZnATnAx+lIta14URQK6WCY5xHjGm o3KZXqW1gNajuttsDVa436Hys12QuNPP2txSbbx2HNdh9pIRN48Mulca3 yAySyKmwGTMzvh54rhJs1cScpvyPiplespvWI9GEO7/NX4JgVXoWk5zMN 0=; 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="59972658" 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:35:47 +0200 Date: Tue, 27 Jun 2023 19:35:47 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Julia Lawall cc: Sakari Ailus , keescook@chromium.org, kernel-janitors@vger.kernel.org, Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab , Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 23/26] media: staging: imgu: use array_size In-Reply-To: <20230623211457.102544-24-Julia.Lawall@inria.fr> Message-ID: References: <20230623211457.102544-1-Julia.Lawall@inria.fr> <20230623211457.102544-24-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: > > // > @@ > expression E1, E2; > constant C1, C2; > identifier alloc = {vmalloc,vzalloc}; > @@ > > ( > alloc(C1 * C2,...) > | > alloc( > - (E1) * (E2) > + array_size(E1, E2) > ,...) > ) > // > > Signed-off-by: Julia Lawall > > --- > drivers/staging/media/ipu3/ipu3-mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c > index cb9bf5fb29a5..9c4adb815c94 100644 > --- a/drivers/staging/media/ipu3/ipu3-mmu.c > +++ b/drivers/staging/media/ipu3/ipu3-mmu.c > @@ -464,7 +464,7 @@ struct imgu_mmu_info *imgu_mmu_init(struct device *parent, void __iomem *base) > * Allocate the array of L2PT CPU pointers, initialized to zero, > * which means the dummy L2PT allocated above. > */ > - mmu->l2pts = vzalloc(IPU3_PT_PTES * sizeof(*mmu->l2pts)); > + mmu->l2pts = vzalloc(array_size(IPU3_PT_PTES, sizeof(*mmu->l2pts))); > if (!mmu->l2pts) > goto fail_l2pt; I think that this patch can be dropped. Since it is a multiplcation of two constants, if there is an overflow, I guess the compiler would detect it? julia