From patchwork Tue Jun 27 14:43:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 11346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8294626vqr; Tue, 27 Jun 2023 08:45:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BopF+SPGB8jPCcD9NYDu/wZOosMtrJEVMnXRIGe3KqadSCL9LdPK5b3V7kThbjRvJP3L7 X-Received: by 2002:a17:903:11c7:b0:1b6:6c32:59a8 with SMTP id q7-20020a17090311c700b001b66c3259a8mr6687099plh.36.1687880718075; Tue, 27 Jun 2023 08:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687880718; cv=none; d=google.com; s=arc-20160816; b=XTIjpyTfzBr5e89XLqE//Ek6acPrK5iccdzNmkQR6/cHcBVFP8NWoQW8LqJUnq9Xdw 9MoI7U0Ooj7UdNr6xQfPOdlQ5Qt/FbLp8nnROXb18AZA1GMo9k5QpdnXYlV6BWNFJpqY Dja7EHsEuJzRX2DrtIpooChQBjQBWAw4K2b1SSIUjr1K0mN0IUn9/QAmnZW8lOj/xHT/ QGWbz8R4Bxy75c5eHiXfAbRpSBSnF9ObNgTVVQd2klKA5BldwtGDLDGVSzcJhkx51Fii mtJHmcN4aKcTQR70TcYmMS76s6hJXgdK8W4lVSsPeyr40sssJJH6QqB8cNgZf2ox0o9y aiwA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=lz+eaKXjltZfgC96+KOEH+DiV357kqzsKaP1ME9j9JM=; fh=G7yZoAXDVSoKYk/MV98bbQy4hqfCBj12o7NoburH1aI=; b=uNeDR2Z7+BqytClMdmM84tkvcsRx5eMEXVQdR0oX/STjT8zmHkkBgj2r4t7JkGohvT P/lCUz6JEidvjdoi9OrpueESXGUiizfMTCgpNCfbRMAWHNfWYdiUThUz5UID79p8oePL q2GOSrYPzwCqbdgy5mTBHvjEN32Jz89Yv40x9tL5ROuc7HnpQRZQ+PCouQR8Bm+VHr3o jXfx2SRPUxE0PKIB5jI3liPAFWqQz7qC2XAFBz3LwT+s5iGeRcdYZSXzPn8YD4tykErB n1+/29MpUXDy4NhPuv1uTxcv93UZNYIyhbqhPX57URVLgBaTsTtMsCSbAnKGrA8JjV25 9EaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=YpuufV72; 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 h10-20020a170902f7ca00b001b80bcb306asi3532690plw.69.2023.06.27.08.45.02; Tue, 27 Jun 2023 08:45:18 -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=YpuufV72; 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 S231941AbjF0Ope (ORCPT + 99 others); Tue, 27 Jun 2023 10:45:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbjF0Ooz (ORCPT ); Tue, 27 Jun 2023 10:44:55 -0400 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CD33358A; Tue, 27 Jun 2023 07:44:32 -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:mime-version: content-transfer-encoding; bh=lz+eaKXjltZfgC96+KOEH+DiV357kqzsKaP1ME9j9JM=; b=YpuufV72ER5dSm9wrYSnJ+nyISX1oQx33v1s2pGZoMDoTbTZApc/Qnr+ jWRuBVmLvwZwmibFQ5jrR1vtZ5noOKi7DSKRNrP0U1BZ9FCltFGcibx6p ck1ThN0OMstSb7PrPLh1Mq91rYGjkQ4mlVR9Zej3KEIn+kL4eNkAXPzxE c=; Authentication-Results: mail2-relais-roc.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,162,1684792800"; d="scan'208";a="114936315" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2023 16:43:51 +0200 From: Julia Lawall To: linux-hyperv@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, keescook@chromium.org, christophe.jaillet@wanadoo.fr, kuba@kernel.org, kasan-dev@googlegroups.com, Andrey Konovalov , Dmitry Vyukov , iommu@lists.linux.dev, linux-tegra@vger.kernel.org, Robin Murphy , Krishna Reddy , virtualization@lists.linux-foundation.org, Xuan Zhuo , linux-scsi@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, John Stultz , Brian Starkey , Laura Abbott , Liam Mark , Benjamin Gaignard , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shailend Chand , linux-rdma@vger.kernel.org, mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-btrfs@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Dave Hansen , "H. Peter Anvin" , linux-sgx@vger.kernel.org Subject: [PATCH v2 00/24] use vmalloc_array and vcalloc Date: Tue, 27 Jun 2023 16:43:15 +0200 Message-Id: <20230627144339.144478-1-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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?1769871212009614609?= X-GMAIL-MSGID: =?utf-8?q?1769871212009614609?= The functions vmalloc_array and vcalloc were introduced in commit a8749a35c399 ("mm: vmalloc: introduce array allocation functions") but are not used much yet. This series introduces uses of these functions, to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch. @initialize:ocaml@ @@ let rename alloc = match alloc with "vmalloc" -> "vmalloc_array" | "vzalloc" -> "vcalloc" | _ -> failwith "unknown" @@ size_t e1,e2; constant C1, C2; expression E1, E2, COUNT, x1, x2, x3; typedef u8; typedef __u8; type t = {u8,__u8,char,unsigned char}; identifier alloc = {vmalloc,vzalloc}; fresh identifier realloc = script:ocaml(alloc) { rename alloc }; @@ ( alloc(x1*x2*x3) | alloc(C1 * C2) | alloc((sizeof(t)) * (COUNT), ...) | - alloc((e1) * (e2)) + realloc(e1, e2) | - alloc((e1) * (COUNT)) + realloc(COUNT, e1) | - alloc((E1) * (E2)) + realloc(E1, E2) ) v2: This series uses vmalloc_array and vcalloc instead of array_size. It also leaves a multiplication of a constant by a sizeof as is. Two patches are thus dropped from the series. --- arch/x86/kernel/cpu/sgx/main.c | 2 +- drivers/accel/habanalabs/common/device.c | 3 ++- drivers/accel/habanalabs/common/state_dump.c | 7 ++++--- drivers/bus/mhi/host/init.c | 2 +- drivers/comedi/comedi_buf.c | 4 ++-- drivers/dma-buf/heaps/system_heap.c | 2 +- drivers/gpu/drm/gud/gud_pipe.c | 2 +- drivers/gpu/drm/i915/gvt/gtt.c | 6 ++++-- drivers/infiniband/hw/bnxt_re/qplib_res.c | 4 ++-- drivers/infiniband/hw/erdma/erdma_verbs.c | 4 ++-- drivers/infiniband/sw/siw/siw_qp.c | 4 ++-- drivers/infiniband/sw/siw/siw_verbs.c | 6 +++--- drivers/iommu/tegra-gart.c | 4 ++-- drivers/net/ethernet/amd/pds_core/core.c | 4 ++-- drivers/net/ethernet/freescale/enetc/enetc.c | 4 ++-- drivers/net/ethernet/google/gve/gve_tx.c | 2 +- drivers/net/ethernet/marvell/octeon_ep/octep_rx.c | 2 +- drivers/net/ethernet/microsoft/mana/hw_channel.c | 2 +- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 4 ++-- drivers/scsi/fnic/fnic_trace.c | 2 +- drivers/scsi/qla2xxx/qla_init.c | 4 ++-- drivers/vdpa/vdpa_user/iova_domain.c | 4 ++-- drivers/virtio/virtio_mem.c | 6 +++--- fs/btrfs/zoned.c | 4 ++-- kernel/kcov.c | 2 +- lib/test_vmalloc.c | 9 +++++---- 26 files changed, 52 insertions(+), 47 deletions(-)