* [PATCH RESEND] drm/syncobj: Validate count_handles to prevent large allocations in array_find()
@ 2025-12-06 22:00 Madhur Kumar
0 siblings, 0 replies; only message in thread
From: Madhur Kumar @ 2025-12-06 22:00 UTC (permalink / raw)
To: maarten.lankhorst, mripard, tzimmermann, airlied, simona
Cc: dri-devel, linux-kernel, Madhur Kumar, syzbot+95416f957d84e858b377
The DRM_IOCTL_SYNCOBJ_WAIT ioctl reads `count_handles` from userspace and
uses it directly when allocating memory in array_find(). and
kmalloc_array() allows userspace to request very large allocations,
which syzkaller was able to trigger.
Such unbounded values can lead to excessive memory requests, allocation
failures, warnings, or resource exhaustion paths. Add explicit bounds
validation to prevent excessively large allocations coming from
userspace-provided values.
Reported-by: syzbot+95416f957d84e858b377@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=95416f957d84e858b377
Fixes: 3e6fb72d6cef6 ("drm/syncobj: Add a syncobj_array_find helper")
Tested-by: syzbot+95416f957d84e858b377@syzkaller.appspotmail.com
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] only message in thread
only message in thread, other threads:[~2025-12-06 22:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-06 22:00 [PATCH RESEND] drm/syncobj: Validate count_handles to prevent large allocations in array_find() Madhur Kumar
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®