Skip to content

Commit 69ef943

Browse files
Matthew Wilcoxairlied
authored andcommitted
drm: Use array_size() when creating lease
Passing an object_count of sufficient size will make object_count * 4 wrap around to be very small, then a later function will happily iterate off the end of the object_ids array. Using array_size() will saturate at SIZE_MAX, the kmalloc() will fail and we'll return an -ENOMEM to the norty userspace. Fixes: 62884cd ("drm: Add four ioctls for managing drm mode object leases [v7]") Signed-off-by: Matthew Wilcox <willy@infradead.org> Acked-by: Kees Cook <keescook@chromium.org> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: <stable@vger.kernel.org> # v4.15+ Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 7abbb35 commit 69ef943

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/gpu/drm/drm_lease.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
528528

529529
object_count = cl->object_count;
530530

531-
object_ids = memdup_user(u64_to_user_ptr(cl->object_ids), object_count * sizeof(__u32));
531+
object_ids = memdup_user(u64_to_user_ptr(cl->object_ids),
532+
array_size(object_count, sizeof(__u32)));
532533
if (IS_ERR(object_ids))
533534
return PTR_ERR(object_ids);
534535

0 commit comments

Comments
 (0)