Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp20361424rwd; Thu, 29 Jun 2023 00:58:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4WK/UH8ooQrDvbD3RjHhKTSN8MjTHSE8EzQcyXb2Ri8J57KD/VUarqPa1gV1FuLuC3KJrG X-Received: by 2002:a05:6214:20a4:b0:623:690c:3cd7 with SMTP id 4-20020a05621420a400b00623690c3cd7mr41022282qvd.47.1688025500521; Thu, 29 Jun 2023 00:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688025500; cv=none; d=google.com; s=arc-20160816; b=NdPUymBpfj1q2TxnhGEALLyCcDYRkqz/xWtVyAshhVdh5tZ602GbiOGiUtMN05ZULP ASGgzZgSnLBP3S06GZu4HZYMQtQjt8aM5MEC7lCaRdzjsppjSG3LPrYr38NHY0df1mSd D/XH8oF2t7mfg/vsySN4+eIbfIjJJTqKWagu84W2zdxInWPKzCWy3PhtggJT0Uy9rtxH oNXf9kLNhGPUeIg3n3YU/WRho/15rxf1xx90tKYhfjHieYSDO5oAEkc2mqsbMmpTHCSS eHWremWkNahhxyuXprgn9pPDu7LCzD+NYbjiqsLAw65xO0TG9+uAjUEmbOotA3C8Dx01 0JdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C179SjF+m5a8y5Se/HdflgUeTt6CWGtqMWhhImUY8EY=; fh=63Ww/gAfL4D8rY2qTNf4focJXsWobuWw4Wd8FWkFKn8=; b=InSdkAT5LyPEzJjvOU7OQullr91m1pr2F87ohkOYRvzzpEE13BgrHMUK1uWdwQVe5R xK467a1w2lkbXRCl9RpnIwVNr7sLnsEWr3wxpuTd3FNmptAJgKzzWwVUB6zTULPZgNFi 0stsfc6yZWmqipV9Z7wIgWh1NkNmBO0tHKnfPyZocfET6IUcUsY46uMzBfg+Tnk12xQn +K9GEvQJAvr9Xtw9U//+hd6YjpdhM0DVE4xV1/V5JToZKoN0eyGkCohn0wTQy3asTq1j rbZFO3XrtZq0NwnjDNIfGAP+SKNwXSOAJDNy8uAIogATTb2VcDVFOQ1gw17VZSVoTmNb H6YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KoUp4AER; 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 nl6-20020a17090b384600b002536f332d07si13546402pjb.149.2023.06.29.00.58.05; Thu, 29 Jun 2023 00:58:20 -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=@intel.com header.s=Intel header.b=KoUp4AER; 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 S232252AbjF2Hfy (ORCPT + 99 others); Thu, 29 Jun 2023 03:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231430AbjF2Hek (ORCPT ); Thu, 29 Jun 2023 03:34:40 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DBBFE58; Thu, 29 Jun 2023 00:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688024079; x=1719560079; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/axrSWOdtVz/Ckd0cZbOJm+/YGfdBtp+s+fpBkWAL+M=; b=KoUp4AERObC8dxqV0BgNgGgyeSBE0QSqfXdwyzAKGjUdthoUTRo1xlUR XZs8iienuP3RNCLaebwZxtR6rGZJkMSTuzYNKBU5aYyteF2wKz2pXvEQP SoOgQj7FgDwsmd+tdm2s/OUqf5n8zZR7O/Nkg8UeRHJJ17gyRYtuN51Wo 3bxaNXybVzhAXPecuOJxTw+rQdfahYkuBVYBjz79VW725l3bXagqjBszK 27Gz4Q+zT8l1sHMQE95VIeb1KfrbGe2n+RZlDGpvfPgDQtYraAfJmh2uE b7cCs0Q5+DSsQIQ4HkKcw6z1spxQtSF6e0MXMNffO9eiTixu1EupJ5mE8 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="364592006" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="364592006" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2023 00:34:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="720472979" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="720472979" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2023 00:34:36 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id E0FA01207EB; Thu, 29 Jun 2023 10:34:33 +0300 (EEST) Date: Thu, 29 Jun 2023 07:34:33 +0000 From: Sakari Ailus To: Julia Lawall Cc: 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 Message-ID: References: <20230623211457.102544-1-Julia.Lawall@inria.fr> <20230623211457.102544-24-Julia.Lawall@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Hi Julia, Bingbu, On Tue, Jun 27, 2023 at 07:35:47PM +0200, Julia Lawall wrote: > > > 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? Indeed. vcalloc() would be perhaps nicer but the original isn't wrong either. -- Kind regards, Sakari Ailus