public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/v3d: Reject empty multisync extension to prevent infinite loop
@ 2026-04-14  5:44 Ashutosh Desai
  2026-04-14 18:07 ` Maíra Canal
  0 siblings, 1 reply; 3+ messages in thread
From: Ashutosh Desai @ 2026-04-14  5:44 UTC (permalink / raw)
  To: dri-devel; +Cc: mcanal, itoral, stable

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.

Fixes: 9032d5f633ed ("drm/v3d: Detach job submissions IOCTLs to a new specific file")
Cc: stable@vger.kernel.org
Signed-off-by: Ashutosh Desai <ashutoshdesai993@gmail.com>
---
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/20260413055230.3349114-1-ashutoshdesai993@gmail.com/
v1: https://lore.kernel.org/dri-devel/20260410013907.2404175-1-ashutoshdesai993@gmail.com/

 drivers/gpu/drm/v3d/v3d_submit.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c
index 18f2bf1fe89f..fc74351efad5 100644
--- a/drivers/gpu/drm/v3d/v3d_submit.c
+++ b/drivers/gpu/drm/v3d/v3d_submit.c
@@ -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)
-- 
2.34.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] drm/v3d: Reject empty multisync extension to prevent infinite loop
  2026-04-14  5:44 [PATCH v3] drm/v3d: Reject empty multisync extension to prevent infinite loop Ashutosh Desai
@ 2026-04-14 18:07 ` Maíra Canal
  2026-04-15  5:08   ` Ashutosh Desai
  0 siblings, 1 reply; 3+ messages in thread
From: Maíra Canal @ 2026-04-14 18:07 UTC (permalink / raw)
  To: Ashutosh Desai, dri-devel; +Cc: itoral, stable

Hi Ashutosh,

On 14/04/26 02:44, Ashutosh Desai wrote:
> 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.
> 
> Fixes: 9032d5f633ed ("drm/v3d: Detach job submissions IOCTLs to a new specific file")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ashutosh Desai <ashutoshdesai993@gmail.com>
> ---
> 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/20260413055230.3349114-1-ashutoshdesai993@gmail.com/
> v1: https://lore.kernel.org/dri-devel/20260410013907.2404175-1-ashutoshdesai993@gmail.com/
> 
>   drivers/gpu/drm/v3d/v3d_submit.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c
> index 18f2bf1fe89f..fc74351efad5 100644
> --- a/drivers/gpu/drm/v3d/v3d_submit.c
> +++ b/drivers/gpu/drm/v3d/v3d_submit.c
> @@ -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

> +
>   ret = v3d_get_multisync_post_deps(file_priv, se, multisync.out_sync_count,
>   multisync.out_syncs);
>   if (ret)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] drm/v3d: Reject empty multisync extension to prevent infinite loop
  2026-04-14 18:07 ` Maíra Canal
@ 2026-04-15  5:08   ` Ashutosh Desai
  0 siblings, 0 replies; 3+ messages in thread
From: Ashutosh Desai @ 2026-04-15  5:08 UTC (permalink / raw)
  To: mcanal; +Cc: dri-devel, itoral, stable

[-- Attachment #1: Type: text/plain, Size: 267 bytes --]

Hi Maíra,

On 14/04/26 11:07, Maíra Canal wrote:
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-15  5:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14  5:44 [PATCH v3] drm/v3d: Reject empty multisync extension to prevent infinite loop Ashutosh Desai
2026-04-14 18:07 ` Maíra Canal
2026-04-15  5:08   ` Ashutosh Desai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox