From patchwork Fri Jun 23 21:14:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6050304vqr; Fri, 23 Jun 2023 14:28:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5M/YRy3+dfcf1ztVAAGeBQzf/xtIzlSd7CsFZ9bXZB1U+9yXcVkAXREUkLX732JiaetS+N X-Received: by 2002:a05:6a00:1a87:b0:66a:386c:e6a6 with SMTP id e7-20020a056a001a8700b0066a386ce6a6mr12029243pfv.6.1687555723824; Fri, 23 Jun 2023 14:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555723; cv=none; d=google.com; s=arc-20160816; b=uyh2ifYNI0ivH1HAdp8BzHVivrMB9VUz0fd8BwT5gEKF2FvV9w6r2MHFZ3TiUeyusP Zj0xVLpMOxmg+yh3MQvCJJMchXwO930twdYZJZisK0g1ag9rwJEhvZ6zOVGbs8zDPr/j cmx0m0A0o7IUmErVXbNcTsZx0+7fjgHW1lRgEsVyetbZt9DbI/ZIxSxyvMmEl/RvyFri iUCvYceXNZgqrlGUT0WjAxrwM2I2p3LUW0J9cbpIKh8Z00KwklY4pOzNGsnqpKNPpgl6 AlocUjI7e3gXeJPsnCXrdpdqpXoz2mBsq6nEl/QrAZKCVvTkCWThbgRJmWD+gtNOGPeE Oc8g== 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=v1C6X9Yx4yVXOAdKb8gSIcJ1cJexwLFD0Mhp8hyTXpM=; fh=F5dRuVQGU4ee3jzykFtDTPC2cSFBiBkLO6/40suH+oo=; b=vkEjzHws5+wrn6QzWn5GPegXgpaxgt+CjwB1uVxwoJuJcetLkESGkHQURKTHH8QC77 +TDoDGWdjP5qlOabE4r556vddELTmr1UXn0rqXCI+tXp/8aZueFd+nKr6kczSfGTVjKg SOMyPrgfqpULOR7IWNVTSy1tzmCvIZvOeLgHhxebwCdYWOjaoEBz3I8e4CEbIbK0rU5J 1QlGlW7pj6qqMWVou/Up7e020bjCvRz0Lx4C1HAe0S6aVAEsXOKDwNFzG6kphJCaaeDT 7SGQH93KFrdguVXhSuXW9AQzOAy4BqRO5CnCZJBwaBcobCVIbU7w8vO+sAyK3XyMKcgY UuHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=ibGdS6fG; 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 fi14-20020a056a00398e00b006688d6acadesi45239pfb.156.2023.06.23.14.28.31; Fri, 23 Jun 2023 14:28:43 -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=ibGdS6fG; 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 S232442AbjFWVPZ (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232276AbjFWVPQ (ORCPT ); Fri, 23 Jun 2023 17:15:16 -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 4215C10F2; Fri, 23 Jun 2023 14:15:15 -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=v1C6X9Yx4yVXOAdKb8gSIcJ1cJexwLFD0Mhp8hyTXpM=; b=ibGdS6fGsGhc/uttTGaoiJpbUVLv1dQE53RQlyqWPi8I8jYsjA4QPhsG 69vuLyA1lvbPNf9DFQ9xV+59969GQRIT64vAPf+BtV5VoJBI5MAp5KGAg 4j/AIfruYXqvPQ99dB1Q5fqTn+WPSuJXNvhdtCBICTm1jBC06qptZY2WA c=; 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="59686164" 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:10 +0200 From: Julia Lawall To: Sumit Semwal Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , John Stultz , =?utf-8?q?Christian_K=C3=B6nig?= , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/26] dma-buf: system_heap: use array_size Date: Fri, 23 Jun 2023 23:14:37 +0200 Message-Id: <20230623211457.102544-7-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?1769530430841966736?= X-GMAIL-MSGID: =?utf-8?q?1769530430841966736?= 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 Acked-by: John Stultz --- drivers/dma-buf/heaps/system_heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index ee7059399e9c..fb7867599874 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -221,7 +221,7 @@ static void *system_heap_do_vmap(struct system_heap_buffer *buffer) { struct sg_table *table = &buffer->sg_table; int npages = PAGE_ALIGN(buffer->len) / PAGE_SIZE; - struct page **pages = vmalloc(sizeof(struct page *) * npages); + struct page **pages = vmalloc(array_size(npages, sizeof(struct page *))); struct page **tmp = pages; struct sg_page_iter piter; void *vaddr;