drm/v3d: reject an invalid indirect CSD buffer handle
Subsystems (4)
PATCH 1/1 drm/v3d: reject an invalid indirect CSD buffer handle
v3d_get_cpu_indirect_csd_params() does not check the result of drm_gem_object_lookup(). A bogus indirect CSD handle from userspace makes it store NULL in info->indirect; when the CPU job runs, v3d_rewrite_csd_job_wg_counts_from_indirect() dereferences it through v3d_get_bo_vaddr() and oopses the kernel. Any unprivileged client can trigger this.
Reject the NULL handle with -ENOENT, as every other GEM lookup in this driver does. v3d_cpu_job_free() drops the reference under a NULL check, so the error path leaks nothing.
--- drivers/gpu/drm/v3d/v3d_submit.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/v3d/v3d_submit.c +2 -0
@@ -605,6 +605,8 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv, sizeof(indirect_csd.wg_uniform_offsets)); info->indirect =drm_gem_object_lookup (file_priv, indirect_csd.indirect); +if (!info->indirect) +return -ENOENT ;return 0 ; }
Signature · 1 line
2.43.0
Maíra Canal
maintainerHi JaeHoon,
Duplicated patch, please check [1].
[1] https://lore.kernel.org/dri-devel/[email protected]/T/#m42c7a8cf94b8cb787cca01dfbdaf5fdce40c7332
Best regards,
- Maíra
Quoted 31 lines · JaeHoon Lee
v3d_get_cpu_indirect_csd_params()does not check the result ofdrm_gem_object_lookup(). A bogus indirect CSD handle from userspace makes it store NULL ininfo->indirect; when the CPU job runs,v3d_rewrite_csd_job_wg_counts_from_indirect()dereferences it throughv3d_get_bo_vaddr()and oopses the kernel. Any unprivileged client can trigger this.Reject the NULL handle with
-ENOENT, as every other GEM lookup in this driver does.v3d_cpu_job_free()drops the reference under a NULL check, so the error path leaks nothing.Fixes 18b8413b25b7 ("drm/v3d: Create a CPU job extension for a indirect CSD job")Signed-off-by JaeHoon Lee <[email protected]>--- drivers/gpu/drm/v3d/v3d_submit.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/v3d/v3d_submit.c +2
-0@@ -605,6 +605,8 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv, sizeof(indirect_csd.wg_uniform_offsets)); info->indirect =drm_gem_object_lookup (file_priv, indirect_csd.indirect); +if (!info->indirect) +return -ENOENT ;return 0 ; }