drm/xe: Use copy_from_user() instead of __copy_from_user()
copy_from_user() has more checks and is more safer than __copy_from_user() Suggested-by: Kees Cook <kees@kernel.org> Signed-off-by: Harish Chegondi <harish.chegondi@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Link: https://lore.kernel.org/r/acabf20aa8621c7bc8de09b1bffb8d14b5376484.1746126614.git.harish.chegondi@intel.com
This commit is contained in:
committed by
Ashutosh Dixit
parent
12370bfcc4
commit
aef87a5fdb
@@ -2569,7 +2569,7 @@ static int gem_create_user_ext_set_property(struct xe_device *xe,
|
||||
int err;
|
||||
u32 idx;
|
||||
|
||||
err = __copy_from_user(&ext, address, sizeof(ext));
|
||||
err = copy_from_user(&ext, address, sizeof(ext));
|
||||
if (XE_IOCTL_DBG(xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
@@ -2606,7 +2606,7 @@ static int gem_create_user_extensions(struct xe_device *xe, struct xe_bo *bo,
|
||||
if (XE_IOCTL_DBG(xe, ext_number >= MAX_USER_EXTENSIONS))
|
||||
return -E2BIG;
|
||||
|
||||
err = __copy_from_user(&ext, address, sizeof(ext));
|
||||
err = copy_from_user(&ext, address, sizeof(ext));
|
||||
if (XE_IOCTL_DBG(xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ static int xe_eu_stall_user_ext_set_property(struct xe_device *xe, u64 extension
|
||||
int err;
|
||||
u32 idx;
|
||||
|
||||
err = __copy_from_user(&ext, address, sizeof(ext));
|
||||
err = copy_from_user(&ext, address, sizeof(ext));
|
||||
if (XE_IOCTL_DBG(xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
@@ -313,7 +313,7 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,
|
||||
if (XE_IOCTL_DBG(xe, ext_number >= MAX_USER_EXTENSIONS))
|
||||
return -E2BIG;
|
||||
|
||||
err = __copy_from_user(&ext, address, sizeof(ext));
|
||||
err = copy_from_user(&ext, address, sizeof(ext));
|
||||
if (XE_IOCTL_DBG(xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
|
||||
@@ -176,8 +176,8 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
|
||||
}
|
||||
|
||||
if (xe_exec_queue_is_parallel(q)) {
|
||||
err = __copy_from_user(addresses, addresses_user, sizeof(u64) *
|
||||
q->width);
|
||||
err = copy_from_user(addresses, addresses_user, sizeof(u64) *
|
||||
q->width);
|
||||
if (err) {
|
||||
err = -EFAULT;
|
||||
goto err_syncs;
|
||||
|
||||
@@ -479,7 +479,7 @@ static int exec_queue_user_ext_set_property(struct xe_device *xe,
|
||||
int err;
|
||||
u32 idx;
|
||||
|
||||
err = __copy_from_user(&ext, address, sizeof(ext));
|
||||
err = copy_from_user(&ext, address, sizeof(ext));
|
||||
if (XE_IOCTL_DBG(xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
@@ -518,7 +518,7 @@ static int exec_queue_user_extensions(struct xe_device *xe, struct xe_exec_queue
|
||||
if (XE_IOCTL_DBG(xe, ext_number >= MAX_USER_EXTENSIONS))
|
||||
return -E2BIG;
|
||||
|
||||
err = __copy_from_user(&ext, address, sizeof(ext));
|
||||
err = copy_from_user(&ext, address, sizeof(ext));
|
||||
if (XE_IOCTL_DBG(xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
@@ -618,9 +618,8 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
|
||||
if (XE_IOCTL_DBG(xe, !len || len > XE_HW_ENGINE_MAX_INSTANCE))
|
||||
return -EINVAL;
|
||||
|
||||
err = __copy_from_user(eci, user_eci,
|
||||
sizeof(struct drm_xe_engine_class_instance) *
|
||||
len);
|
||||
err = copy_from_user(eci, user_eci,
|
||||
sizeof(struct drm_xe_engine_class_instance) * len);
|
||||
if (XE_IOCTL_DBG(xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
|
||||
@@ -1301,7 +1301,7 @@ static int xe_oa_user_ext_set_property(struct xe_oa *oa, enum xe_oa_user_extn_fr
|
||||
int err;
|
||||
u32 idx;
|
||||
|
||||
err = __copy_from_user(&ext, address, sizeof(ext));
|
||||
err = copy_from_user(&ext, address, sizeof(ext));
|
||||
if (XE_IOCTL_DBG(oa->xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
@@ -1338,7 +1338,7 @@ static int xe_oa_user_extensions(struct xe_oa *oa, enum xe_oa_user_extn_from fro
|
||||
if (XE_IOCTL_DBG(oa->xe, ext_number >= MAX_USER_EXTENSIONS))
|
||||
return -E2BIG;
|
||||
|
||||
err = __copy_from_user(&ext, address, sizeof(ext));
|
||||
err = copy_from_user(&ext, address, sizeof(ext));
|
||||
if (XE_IOCTL_DBG(oa->xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
@@ -2281,7 +2281,7 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
err = __copy_from_user(¶m, u64_to_user_ptr(data), sizeof(param));
|
||||
err = copy_from_user(¶m, u64_to_user_ptr(data), sizeof(param));
|
||||
if (XE_IOCTL_DBG(oa->xe, err))
|
||||
return -EFAULT;
|
||||
|
||||
|
||||
@@ -3101,9 +3101,9 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,
|
||||
if (!*bind_ops)
|
||||
return args->num_binds > 1 ? -ENOBUFS : -ENOMEM;
|
||||
|
||||
err = __copy_from_user(*bind_ops, bind_user,
|
||||
sizeof(struct drm_xe_vm_bind_op) *
|
||||
args->num_binds);
|
||||
err = copy_from_user(*bind_ops, bind_user,
|
||||
sizeof(struct drm_xe_vm_bind_op) *
|
||||
args->num_binds);
|
||||
if (XE_IOCTL_DBG(xe, err)) {
|
||||
err = -EFAULT;
|
||||
goto free_bind_ops;
|
||||
|
||||
Reference in New Issue
Block a user