Skip to content

Commit aef87a5

Browse files
harishchegondiashutoshx
authored andcommitted
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 <[email protected]> Signed-off-by: Harish Chegondi <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Reviewed-by: Ashutosh Dixit <[email protected]> Signed-off-by: Ashutosh Dixit <[email protected]> Link: https://lore.kernel.org/r/acabf20aa8621c7bc8de09b1bffb8d14b5376484.1746126614.git.harish.chegondi@intel.com
1 parent 12370bf commit aef87a5

File tree

6 files changed

+16
-17
lines changed

6 files changed

+16
-17
lines changed

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,7 @@ static int gem_create_user_ext_set_property(struct xe_device *xe,
25692569
int err;
25702570
u32 idx;
25712571

2572-
err = __copy_from_user(&ext, address, sizeof(ext));
2572+
err = copy_from_user(&ext, address, sizeof(ext));
25732573
if (XE_IOCTL_DBG(xe, err))
25742574
return -EFAULT;
25752575

@@ -2606,7 +2606,7 @@ static int gem_create_user_extensions(struct xe_device *xe, struct xe_bo *bo,
26062606
if (XE_IOCTL_DBG(xe, ext_number >= MAX_USER_EXTENSIONS))
26072607
return -E2BIG;
26082608

2609-
err = __copy_from_user(&ext, address, sizeof(ext));
2609+
err = copy_from_user(&ext, address, sizeof(ext));
26102610
if (XE_IOCTL_DBG(xe, err))
26112611
return -EFAULT;
26122612

drivers/gpu/drm/xe/xe_eu_stall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static int xe_eu_stall_user_ext_set_property(struct xe_device *xe, u64 extension
283283
int err;
284284
u32 idx;
285285

286-
err = __copy_from_user(&ext, address, sizeof(ext));
286+
err = copy_from_user(&ext, address, sizeof(ext));
287287
if (XE_IOCTL_DBG(xe, err))
288288
return -EFAULT;
289289

@@ -313,7 +313,7 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,
313313
if (XE_IOCTL_DBG(xe, ext_number >= MAX_USER_EXTENSIONS))
314314
return -E2BIG;
315315

316-
err = __copy_from_user(&ext, address, sizeof(ext));
316+
err = copy_from_user(&ext, address, sizeof(ext));
317317
if (XE_IOCTL_DBG(xe, err))
318318
return -EFAULT;
319319

drivers/gpu/drm/xe/xe_exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
176176
}
177177

178178
if (xe_exec_queue_is_parallel(q)) {
179-
err = __copy_from_user(addresses, addresses_user, sizeof(u64) *
180-
q->width);
179+
err = copy_from_user(addresses, addresses_user, sizeof(u64) *
180+
q->width);
181181
if (err) {
182182
err = -EFAULT;
183183
goto err_syncs;

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static int exec_queue_user_ext_set_property(struct xe_device *xe,
479479
int err;
480480
u32 idx;
481481

482-
err = __copy_from_user(&ext, address, sizeof(ext));
482+
err = copy_from_user(&ext, address, sizeof(ext));
483483
if (XE_IOCTL_DBG(xe, err))
484484
return -EFAULT;
485485

@@ -518,7 +518,7 @@ static int exec_queue_user_extensions(struct xe_device *xe, struct xe_exec_queue
518518
if (XE_IOCTL_DBG(xe, ext_number >= MAX_USER_EXTENSIONS))
519519
return -E2BIG;
520520

521-
err = __copy_from_user(&ext, address, sizeof(ext));
521+
err = copy_from_user(&ext, address, sizeof(ext));
522522
if (XE_IOCTL_DBG(xe, err))
523523
return -EFAULT;
524524

@@ -618,9 +618,8 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
618618
if (XE_IOCTL_DBG(xe, !len || len > XE_HW_ENGINE_MAX_INSTANCE))
619619
return -EINVAL;
620620

621-
err = __copy_from_user(eci, user_eci,
622-
sizeof(struct drm_xe_engine_class_instance) *
623-
len);
621+
err = copy_from_user(eci, user_eci,
622+
sizeof(struct drm_xe_engine_class_instance) * len);
624623
if (XE_IOCTL_DBG(xe, err))
625624
return -EFAULT;
626625

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ static int xe_oa_user_ext_set_property(struct xe_oa *oa, enum xe_oa_user_extn_fr
13011301
int err;
13021302
u32 idx;
13031303

1304-
err = __copy_from_user(&ext, address, sizeof(ext));
1304+
err = copy_from_user(&ext, address, sizeof(ext));
13051305
if (XE_IOCTL_DBG(oa->xe, err))
13061306
return -EFAULT;
13071307

@@ -1338,7 +1338,7 @@ static int xe_oa_user_extensions(struct xe_oa *oa, enum xe_oa_user_extn_from fro
13381338
if (XE_IOCTL_DBG(oa->xe, ext_number >= MAX_USER_EXTENSIONS))
13391339
return -E2BIG;
13401340

1341-
err = __copy_from_user(&ext, address, sizeof(ext));
1341+
err = copy_from_user(&ext, address, sizeof(ext));
13421342
if (XE_IOCTL_DBG(oa->xe, err))
13431343
return -EFAULT;
13441344

@@ -2281,7 +2281,7 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi
22812281
return -EACCES;
22822282
}
22832283

2284-
err = __copy_from_user(&param, u64_to_user_ptr(data), sizeof(param));
2284+
err = copy_from_user(&param, u64_to_user_ptr(data), sizeof(param));
22852285
if (XE_IOCTL_DBG(oa->xe, err))
22862286
return -EFAULT;
22872287

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,9 +3101,9 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,
31013101
if (!*bind_ops)
31023102
return args->num_binds > 1 ? -ENOBUFS : -ENOMEM;
31033103

3104-
err = __copy_from_user(*bind_ops, bind_user,
3105-
sizeof(struct drm_xe_vm_bind_op) *
3106-
args->num_binds);
3104+
err = copy_from_user(*bind_ops, bind_user,
3105+
sizeof(struct drm_xe_vm_bind_op) *
3106+
args->num_binds);
31073107
if (XE_IOCTL_DBG(xe, err)) {
31083108
err = -EFAULT;
31093109
goto free_bind_ops;

0 commit comments

Comments
 (0)