mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/syncobj: Prevent overflow and large kmalloc in array_find()
@ 2025-11-27 13:05 Madhur Kumar
  2025-11-27 13:22 ` [syzbot] [dri?] WARNING in drm_syncobj_array_find syzbot
  0 siblings, 1 reply; 2+ messages in thread
From: Madhur Kumar @ 2025-11-27 13:05 UTC (permalink / raw)
  To: syzbot+95416f957d84e858b377, syzkaller-bugs, linux-kernel; +Cc: Madhur Kumar

#syz test

Signed-off-by: Madhur Kumar <madhurkumar004@gmail.com>
---
 drivers/gpu/drm/drm_syncobj.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index e1b0fa4000cd..f322b38ec251 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -1293,6 +1293,13 @@ static int drm_syncobj_array_find(struct drm_file *file_private,
 	uint32_t i, *handles;
 	struct drm_syncobj **syncobjs;
 	int ret;
+	size_t size;
+
+	if (check_mul_overflow(count_handles, sizeof(*handles), &size))
+		return -EOVERFLOW;
+
+	if (size > KMALLOC_MAX_SIZE)
+		return -ERANGE;
 
 	handles = kmalloc_array(count_handles, sizeof(*handles), GFP_KERNEL);
 	if (handles == NULL)
-- 
2.52.0


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

end of thread, other threads:[~2025-11-27 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-27 13:05 [PATCH] drm/syncobj: Prevent overflow and large kmalloc in array_find() Madhur Kumar
2025-11-27 13:22 ` [syzbot] [dri?] WARNING in drm_syncobj_array_find syzbot

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

all inboxes | Powered by JetHome®