All of lore.kernel.org
 help / color / mirror / Atom feed
* [Nouveau] [PATCH][next] nouveau/svm: Use struct_size() helper in nouveau_pfns_map()
@ 2022-02-07 23:39 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2022-02-07 23:39 UTC (permalink / raw)
  To: Ben Skeggs, Karol Herbst, Lyude Paul, David Airlie, Daniel Vetter
  Cc: nouveau, linux-hardening, linux-kernel, dri-devel, Gustavo A. R. Silva

Make use of the struct_size() helper instead of an open-coded version,
in order to avoid any potential type mistakes or integer overflows that,
in the worse scenario, could lead to heap overflows.

Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/gpu/drm/nouveau/nouveau_svm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 266809e511e2..46a5a1016e37 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -925,8 +925,8 @@ nouveau_pfns_map(struct nouveau_svmm *svmm, struct mm_struct *mm,
 
 	mutex_lock(&svmm->mutex);
 
-	ret = nvif_object_ioctl(&svmm->vmm->vmm.object, args, sizeof(*args) +
-				npages * sizeof(args->p.phys[0]), NULL);
+	ret = nvif_object_ioctl(&svmm->vmm->vmm.object, args,
+				struct_size(args, p.phys, npages), NULL);
 
 	mutex_unlock(&svmm->mutex);
 }
-- 
2.27.0


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

end of thread, other threads:[~2022-02-08 22:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 23:39 [Nouveau] [PATCH][next] nouveau/svm: Use struct_size() helper in nouveau_pfns_map() Gustavo A. R. Silva
2022-02-07 23:39 ` Gustavo A. R. Silva
2022-02-07 23:39 ` Gustavo A. R. Silva
2022-02-08 20:09 ` [Nouveau] " Lyude Paul
2022-02-08 20:09   ` Lyude Paul
2022-02-08 20:09   ` Lyude Paul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.