* [Intel-gfx] [PATCH v2 16/24] drm/i915/gvt: use vmalloc_array and vcalloc
2023-06-27 14:43 [Intel-gfx] [PATCH v2 00/24] use vmalloc_array and vcalloc Julia Lawall
@ 2023-06-27 14:43 ` Julia Lawall
2023-06-27 16:40 ` [Intel-gfx] [PATCH v2 00/24] " patchwork-bot+netdevbpf
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2023-06-27 14:43 UTC (permalink / raw)
To: Zhenyu Wang
Cc: keescook, intel-gvt-dev, intel-gfx, kernel-janitors, linux-kernel,
christophe.jaillet, dri-devel, Daniel Vetter, Rodrigo Vivi, kuba,
David Airlie
Use vmalloc_array and vcalloc to protect against
multiplication overflows.
The changes were done using the following Coccinelle
semantic patch:
// <smpl>
@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)
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
---
v2: Use vmalloc_array and vcalloc instead of array_size.
This also leaves a multiplication of a constant by a sizeof
as is. Two patches are thus dropped from the series.
drivers/gpu/drm/i915/gvt/gtt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff -u -p a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -1969,14 +1969,16 @@ static struct intel_vgpu_mm *intel_vgpu_
return ERR_PTR(-ENOMEM);
}
- mm->ggtt_mm.host_ggtt_aperture = vzalloc((vgpu_aperture_sz(vgpu) >> PAGE_SHIFT) * sizeof(u64));
+ mm->ggtt_mm.host_ggtt_aperture = vcalloc(vgpu_aperture_sz(vgpu) >> PAGE_SHIFT,
+ sizeof(u64));
if (!mm->ggtt_mm.host_ggtt_aperture) {
vfree(mm->ggtt_mm.virtual_ggtt);
vgpu_free_mm(mm);
return ERR_PTR(-ENOMEM);
}
- mm->ggtt_mm.host_ggtt_hidden = vzalloc((vgpu_hidden_sz(vgpu) >> PAGE_SHIFT) * sizeof(u64));
+ mm->ggtt_mm.host_ggtt_hidden = vcalloc(vgpu_hidden_sz(vgpu) >> PAGE_SHIFT,
+ sizeof(u64));
if (!mm->ggtt_mm.host_ggtt_hidden) {
vfree(mm->ggtt_mm.host_ggtt_aperture);
vfree(mm->ggtt_mm.virtual_ggtt);
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Intel-gfx] [PATCH v2 00/24] use vmalloc_array and vcalloc
2023-06-27 14:43 [Intel-gfx] [PATCH v2 00/24] use vmalloc_array and vcalloc Julia Lawall
2023-06-27 14:43 ` [Intel-gfx] [PATCH v2 16/24] drm/i915/gvt: " Julia Lawall
@ 2023-06-27 16:40 ` patchwork-bot+netdevbpf
2023-07-06 1:35 ` Martin K. Petersen
2023-07-11 16:31 ` [Intel-gfx] (subset) " Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-27 16:40 UTC (permalink / raw)
To: Julia Lawall
Cc: linux-hyperv, dave.hansen, kernel-janitors, dri-devel,
virtualization, jstultz, hpa, linux-sgx, xuanzhuo,
benjamin.gaignard, linux-scsi, linux-rdma, kasan-dev, iommu, kuba,
labbott, linux-media, keescook, linux-arm-msm, intel-gfx,
linaro-mm-sig, vdumpa, shailend, christophe.jaillet, linux-tegra,
intel-gvt-dev, dvyukov, andreyknvl, netdev, linux-kernel, lmark,
mhi, robin.murphy, linux-btrfs
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 27 Jun 2023 16:43:15 +0200 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [v2,02/24] octeon_ep: use vmalloc_array and vcalloc
https://git.kernel.org/netdev/net-next/c/32d462a5c3e5
- [v2,04/24] gve: use vmalloc_array and vcalloc
https://git.kernel.org/netdev/net-next/c/a13de901e8d5
- [v2,09/24] pds_core: use vmalloc_array and vcalloc
https://git.kernel.org/netdev/net-next/c/906a76cc7645
- [v2,11/24] ionic: use vmalloc_array and vcalloc
https://git.kernel.org/netdev/net-next/c/f712c8297e0a
- [v2,18/24] net: enetc: use vmalloc_array and vcalloc
https://git.kernel.org/netdev/net-next/c/fa87c54693ae
- [v2,22/24] net: mana: use vmalloc_array and vcalloc
https://git.kernel.org/netdev/net-next/c/e9c74f8b8a31
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Intel-gfx] [PATCH v2 00/24] use vmalloc_array and vcalloc
2023-06-27 14:43 [Intel-gfx] [PATCH v2 00/24] use vmalloc_array and vcalloc Julia Lawall
2023-06-27 14:43 ` [Intel-gfx] [PATCH v2 16/24] drm/i915/gvt: " Julia Lawall
2023-06-27 16:40 ` [Intel-gfx] [PATCH v2 00/24] " patchwork-bot+netdevbpf
@ 2023-07-06 1:35 ` Martin K. Petersen
2023-07-11 16:31 ` [Intel-gfx] (subset) " Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2023-07-06 1:35 UTC (permalink / raw)
To: Julia Lawall
Cc: linux-hyperv, Dave Hansen, kernel-janitors, dri-devel,
virtualization, John Stultz, H. Peter Anvin, linux-sgx, Xuan Zhuo,
Benjamin Gaignard, linux-scsi, linux-rdma, kasan-dev, iommu, kuba,
Laura Abbott, linux-media, keescook, linux-arm-msm, intel-gfx,
linaro-mm-sig, Krishna Reddy, Shailend Chand, christophe.jaillet,
linux-tegra, intel-gvt-dev, Dmitry Vyukov, Andrey Konovalov,
netdev, linux-kernel, Liam Mark, mhi, Robin Murphy, linux-btrfs
Julia,
> 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.
Applied #7 and #24 to 6.5/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Intel-gfx] (subset) [PATCH v2 00/24] use vmalloc_array and vcalloc
2023-06-27 14:43 [Intel-gfx] [PATCH v2 00/24] use vmalloc_array and vcalloc Julia Lawall
` (2 preceding siblings ...)
2023-07-06 1:35 ` Martin K. Petersen
@ 2023-07-11 16:31 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2023-07-11 16:31 UTC (permalink / raw)
To: linux-hyperv, Julia Lawall
Cc: Dave Hansen, kernel-janitors, dri-devel, virtualization,
John Stultz, H. Peter Anvin, linux-sgx, Xuan Zhuo,
Benjamin Gaignard, linux-scsi, linux-rdma, kasan-dev, iommu, kuba,
Laura Abbott, linux-media, keescook, linux-arm-msm, intel-gfx,
linaro-mm-sig, Krishna Reddy, Shailend Chand, christophe.jaillet,
linux-tegra, intel-gvt-dev, Dmitry Vyukov, Andrey Konovalov,
Martin K . Petersen, netdev, linux-kernel, Liam Mark, mhi,
Robin Murphy, linux-btrfs
On Tue, 27 Jun 2023 16:43:15 +0200, Julia Lawall wrote:
> 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.
>
> [...]
Applied to 6.5/scsi-fixes, thanks!
[07/24] scsi: fnic: use vmalloc_array and vcalloc
https://git.kernel.org/mkp/scsi/c/b34c7dcaf311
[24/24] scsi: qla2xxx: use vmalloc_array and vcalloc
https://git.kernel.org/mkp/scsi/c/04d91b783acf
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread