mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
drm/gem: Use vmemdup_array_user in drm_gem_objects_lookup
Use a helper to shrink the code and separate the user and kernel slabs for better security. While at it lets remove the useless debug message. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Reviewed-by: André Almeida <andrealmeid@igalia.com> Signed-off-by: Tvrtko Ursulin <tursulin@ursulin.net> Link: https://lore.kernel.org/r/20251112092732.23584-1-tvrtko.ursulin@igalia.com
This commit is contained in:
committed by
Tvrtko Ursulin
parent
04c7adb587
commit
cb77b79abf
@@ -783,7 +783,6 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,
|
|||||||
int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles,
|
int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles,
|
||||||
int count, struct drm_gem_object ***objs_out)
|
int count, struct drm_gem_object ***objs_out)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = filp->minor->dev;
|
|
||||||
struct drm_gem_object **objs;
|
struct drm_gem_object **objs;
|
||||||
u32 *handles;
|
u32 *handles;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -798,15 +797,9 @@ int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles,
|
|||||||
|
|
||||||
*objs_out = objs;
|
*objs_out = objs;
|
||||||
|
|
||||||
handles = kvmalloc_array(count, sizeof(u32), GFP_KERNEL);
|
handles = vmemdup_array_user(bo_handles, count, sizeof(u32));
|
||||||
if (!handles) {
|
if (IS_ERR(handles)) {
|
||||||
ret = -ENOMEM;
|
ret = PTR_ERR(handles);
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (copy_from_user(handles, bo_handles, count * sizeof(u32))) {
|
|
||||||
ret = -EFAULT;
|
|
||||||
drm_dbg_core(dev, "Failed to copy in GEM handles\n");
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user