public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/24] use vmalloc_array and vcalloc
@ 2023-06-27 14:43 Julia Lawall
  2023-06-27 14:43 ` [PATCH v2 01/24] lib/test_vmalloc.c: " Julia Lawall
                   ` (26 more replies)
  0 siblings, 27 replies; 38+ messages in thread
From: Julia Lawall @ 2023-06-27 14:43 UTC (permalink / raw)
  To: linux-hyperv
  Cc: kernel-janitors, keescook, christophe.jaillet, kuba, kasan-dev,
	Andrey Konovalov, Dmitry Vyukov, iommu, linux-tegra, Robin Murphy,
	Krishna Reddy, virtualization, Xuan Zhuo, linux-scsi,
	linaro-mm-sig, linux-media, John Stultz, Brian Starkey,
	Laura Abbott, Liam Mark, Benjamin Gaignard, dri-devel,
	linux-kernel, netdev, Shailend Chand, linux-rdma, mhi,
	linux-arm-msm, linux-btrfs, intel-gvt-dev, intel-gfx, Dave Hansen,
	H. Peter Anvin, linux-sgx

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(-)

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2023-07-21 18:56 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-27 14:43 [PATCH v2 00/24] use vmalloc_array and vcalloc Julia Lawall
2023-06-27 14:43 ` [PATCH v2 01/24] lib/test_vmalloc.c: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 02/24] octeon_ep: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 03/24] drm/gud: " Julia Lawall
2023-07-03 12:23   ` Thomas Zimmermann
2023-07-04 10:41   ` Noralf Trønnes
2023-06-27 14:43 ` [PATCH v2 04/24] gve: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 05/24] RDMA/erdma: " Julia Lawall
2023-07-21 18:56   ` Jason Gunthorpe
2023-06-27 14:43 ` [PATCH v2 06/24] dma-buf: system_heap: " Julia Lawall
2023-06-27 18:52   ` John Stultz
2023-06-27 14:43 ` [PATCH v2 07/24] scsi: fnic: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 08/24] virtio-mem: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 09/24] pds_core: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 10/24] bus: mhi: host: " Julia Lawall
2023-06-27 14:48   ` Jeffrey Hugo
2023-07-12 16:48   ` Manivannan Sadhasivam
2023-06-27 14:43 ` [PATCH v2 11/24] ionic: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 12/24] btrfs: zoned: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 13/24] iommu/tegra: gart: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 14/24] RDMA/siw: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 15/24] habanalabs: " Julia Lawall
2023-07-02  8:01   ` Oded Gabbay
2023-06-27 14:43 ` [PATCH v2 16/24] drm/i915/gvt: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 17/24] kcov: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 18/24] net: enetc: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 19/24] RDMA/bnxt_re: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 20/24] comedi: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 21/24] x86/sgx: " Julia Lawall
2023-06-27 14:54   ` Dave Hansen
2023-06-27 15:01     ` Julia Lawall
2023-06-27 15:06       ` Dave Hansen
2023-06-27 14:43 ` [PATCH v2 22/24] net: mana: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 23/24] vduse: " Julia Lawall
2023-06-27 14:43 ` [PATCH v2 24/24] scsi: qla2xxx: " Julia Lawall
2023-06-27 16:40 ` [PATCH v2 00/24] " patchwork-bot+netdevbpf
2023-07-06  1:35 ` Martin K. Petersen
2023-07-11 16:31 ` (subset) " Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox