diff options
author | Matthew Wilcox | 2019-02-14 20:03:48 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2019-02-20 10:25:49 +0100 |
commit | 3312e0ae2faf4336e9549f13ec0671ec263f4b40 (patch) | |
tree | e211379df989297572a3ba7ec9774f74292bb018 /drivers/gpu/drm/drm_lease.c | |
parent | dm thin: fix bug where bio that overwrites thin block ignores FUA (diff) | |
download | kernel-qcow2-linux-3312e0ae2faf4336e9549f13ec0671ec263f4b40.tar.gz kernel-qcow2-linux-3312e0ae2faf4336e9549f13ec0671ec263f4b40.tar.xz kernel-qcow2-linux-3312e0ae2faf4336e9549f13ec0671ec263f4b40.zip |
drm: Use array_size() when creating lease
commit 69ef943dbc14b21987c79f8399ffea08f9a1b446 upstream.
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: 62884cd386b8 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/gpu/drm/drm_lease.c')
-rw-r--r-- | drivers/gpu/drm/drm_lease.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c index fe6bfaf8b53f..086f2adc541b 100644 --- a/drivers/gpu/drm/drm_lease.c +++ b/drivers/gpu/drm/drm_lease.c @@ -521,7 +521,8 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev, object_count = cl->object_count; - object_ids = memdup_user(u64_to_user_ptr(cl->object_ids), object_count * sizeof(__u32)); + object_ids = memdup_user(u64_to_user_ptr(cl->object_ids), + array_size(object_count, sizeof(__u32))); if (IS_ERR(object_ids)) return PTR_ERR(object_ids); |