drm/v3d: Reject empty multisync extension to prevent infinite loop
Subsystems (4)
PATCH v3 1/1 drm/v3d: Reject empty multisync extension to prevent infinite loop
v3d_get_extensions() walks a userspace-provided singly-linked list of ioctl extensions without any bound on the chain length. A local user can craft a self-referential extension (ext->next == &ext) with zero in_sync_count and out_sync_count, which bypasses the existing duplicate- extension guard:
if (se->in_sync_count || se->out_sync_count)
return -EINVAL;The guard never fires because v3d_get_multisync_post_deps() returns immediately when count is zero, leaving both fields at zero on every iteration. The result is an infinite loop in kernel context, blocking the calling thread and pegging a CPU core indefinitely.
Fix this by rejecting a multisync extension where both in_sync_count and out_sync_count are zero in v3d_get_multisync_submit_deps(). An empty multisync carries no synchronization information and serves no useful purpose, so returning -EINVAL for such an extension is the correct defense against this attack vector.
---
V2 -> V3: drop depth counter; instead reject empty multisync
(in_sync_count == 0 && out_sync_count == 0) in
v3d_get_multisync_submit_deps()V1 -> V2: change cap from 16 to V3D_MAX_EXTENSIONS (7), add #define
v2: https://lore.kernel.org/dri-devel/[email protected]/
v1: https://lore.kernel.org/dri-devel/[email protected]/
drivers/gpu/drm/v3d/v3d_submit.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/v3d/v3d_submit.c +2 -0
@@ -393,6 +393,11 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,if (multisync.pad) -EINVAL ; +if (!multisync.in_sync_count && !multisync.out_sync_count) { +drm_dbg(&v3d->drm, "Empty multisync extension
");
+return -EINVAL;
+}
+
ret = v3d_get_multisync_post_deps(file_priv, se, multisync.out_sync_count, multisync.out_syncs);
if (ret)
Signature · 1 line
2.34.1
Maíra Canal
maintainerHi Ashutosh,
Quoted 40 lines · Ashutosh Desai
v3d_get_extensions()walks a userspace-provided singly-linked list of ioctl extensions without any bound on the chain length. A local user can craft a self-referential extension (ext->next== &ext) with zeroin_sync_countandout_sync_count, which bypasses the existing duplicate- extension guard:if (se->in_sync_count || se->out_sync_count) return -EINVAL;The guard never fires because
v3d_get_multisync_post_deps()returns immediately when count is zero, leaving both fields at zero on every iteration. The result is an infinite loop in kernel context, blocking the calling thread and pegging a CPU core indefinitely.Fix this by rejecting a multisync extension where both
in_sync_countandout_sync_countare zero inv3d_get_multisync_submit_deps(). An empty multisync carries no synchronization information and serves no useful purpose, so returning-EINVALfor such an extension is the correct defense against this attack vector.Fixes 9032d5f633ed ("drm/v3d: Detach job submissions IOCTLs to a new specific file")Signed-off-by Ashutosh Desai <[email protected]>---
V2 -> V3: drop depth counter; instead reject empty multisync(in_sync_count == 0 && out_sync_count == 0) in v3d_get_multisync_submit_deps()V1 -> V2: change cap from 16 to
V3D_MAX_EXTENSIONS(7), add #definev2: https://lore.kernel.org/dri-devel/[email protected]/
v1: https://lore.kernel.org/dri-devel/[email protected]/drivers/gpu/drm/v3d/v3d_submit.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/v3d/v3d_submit.c +0
-0
drivers/gpu/drm/v3d/v3d_submit.c v3d_get_multisync_submit_deps(struct drm_file *file_priv, · line 400
Quoted 8 lines
drivers/gpu/drm/v3d/v3d_submit.c +4
-0@@ -393,6 +393,11 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,if (multisync.pad) -EINVAL ; +if (!multisync.in_sync_count && !multisync.out_sync_count) { +drm_dbg (&v3d->drm,"Empty multisync extension " ); +return -EINVAL ; +}
LGTM, but the indentation looks off to me (v1 and v2 were correct). Could you check if there is any issue with your e-mail client?
Best regards,
- Maíra
Quoted 4 lines
drivers/gpu/drm/v3d/v3d_submit.c +1
-0+ ret =v3d_get_multisync_post_deps (file_priv, se, multisync.out_sync_count, multisync.out_syncs);if (ret)
Hi Maíra,
Quoted 2 lines · Maíra Canal
LGTM, but the indentation looks off to me (v1 and v2 were correct). Could you check if there is any issue with your e-mail client?
Sent v4 with the indentation fixed. Sorry for the noise!
Best regards,
Ashutosh