From patchwork Fri Jun 23 21:14:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112310 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6045698vqr; Fri, 23 Jun 2023 14:17:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6T/fgECGc7auYnJoOhbf6XF59zPl5GbeoDoR3wnT8XbY1beJkIn/AyJBjeqdNAqqj8puLm X-Received: by 2002:a05:6a00:2e9b:b0:64d:5b4b:8429 with SMTP id fd27-20020a056a002e9b00b0064d5b4b8429mr25692992pfb.18.1687555059440; Fri, 23 Jun 2023 14:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555059; cv=none; d=google.com; s=arc-20160816; b=CP4/FFRrJ74UH18WnOE9z+uuOJUIFuAdUjS/i2R3DSSgIfmkz7nihsEtq0KIY/zGzg ibUZYrVOk599hStesgOqHGyzhPweZs7tTpKTMJawSX4lkXSeJHFAdI8DsFR+EQ8pEh+t J8x227zq+kDL3+PBBMP/sfHTl0LSPDgiRTzJ9iJ2RxxDV2LfQmnzq9Wl4CfASX4x1gHy FG9MDQZFuo3MYVfCQGmaMjN2UxyWzKAeH1hJ9FzPea4rLOUfVZPABCp/XQ5AHt/AtTvN dGm1SCpcS7+571OZEk0xo5NR/7EFhhgfT07t6F3rGjW9KI4IroqWapxm+eJNs50wmxdg z6Kg== 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=1HkDEW7AxSHLZvHADInYpWBN1+Bsf50V6Er9x8KFaJk=; fh=yHGuOWQHbttm9lF3oiSFhqz9m993m7B7c90zxZrRrzA=; b=MCt9/W2TVBdpChF/kmA+I1QeKuiCp7R7pJT14HGPCuQjyXkrhJkKT2PAioJNPB2Zeh nVNKWxUL/uOiSE/avacAdNLYcdRbLOmp4ns+ZeZxtR23qtNoLGbDiJ0Hz3WMOBDil3bo z3jCt5YBUF+oF708ebgJMrX7TxalsWfUU9LMwFF80ml8IKwDfJoEqOCPebADMwhP66Jw jxD97oilyq7TCAI8ia3A7am/mqYDH8SbwPTq0nPSzCg1R3q3fqhR/tzdq5w2nGmQbuhQ pMBhv9koONWQWahgHB0gZBlrxJWrr/ifsKunsQCGo/Y3rV5cqzDnL35KWEjMzrpdTq09 6IJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=BfrIEUyQ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s17-20020a656911000000b0053fbacdaf5asi199979pgq.759.2023.06.23.14.17.27; Fri, 23 Jun 2023 14:17:39 -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=BfrIEUyQ; 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 S232629AbjFWVPv (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbjFWVPV (ORCPT ); Fri, 23 Jun 2023 17:15:21 -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 9C8FD1997; Fri, 23 Jun 2023 14:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1HkDEW7AxSHLZvHADInYpWBN1+Bsf50V6Er9x8KFaJk=; b=BfrIEUyQFLrGM984hWuTDVJ9BMp+YgtR3JEATuk5EkoZBafGGqyDRXjy GAn3Um4ZVQx9UGrkJUHaG/3M/yr6kZYJ19tAksbvEPhtIVa8nQg5SsDSO jtf7phSjQezrORoUWJ63Ez5TVQ12NuIb2JdR80iGNsvJm0dJOPwU7L6oG U=; 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,153,1684792800"; d="scan'208";a="59686171" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2023 23:15:12 +0200 From: Julia Lawall To: Thierry Reding Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Krishna Reddy , Joerg Roedel , Will Deacon , Robin Murphy , Jonathan Hunter , linux-tegra@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 13/26] iommu/tegra: gart: use array_size Date: Fri, 23 Jun 2023 23:14:44 +0200 Message-Id: <20230623211457.102544-14-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230623211457.102544-1-Julia.Lawall@inria.fr> References: <20230623211457.102544-1-Julia.Lawall@inria.fr> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769529734241189638?= X-GMAIL-MSGID: =?utf-8?q?1769529734241189638?= 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/iommu/tegra-gart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index a482ff838b53..def222da83f1 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -348,8 +348,8 @@ struct gart_device *tegra_gart_probe(struct device *dev, struct tegra_mc *mc) if (err) goto remove_sysfs; - gart->savedata = vmalloc(resource_size(res) / GART_PAGE_SIZE * - sizeof(u32)); + gart->savedata = vmalloc(array_size(resource_size(res) / GART_PAGE_SIZE, + sizeof(u32))); if (!gart->savedata) { err = -ENOMEM; goto unregister_iommu;