public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/v3d: Limit ioctl extension chain depth to prevent infinite loop
Date: Sun, 12 Apr 2026 10:35:52 +1000	[thread overview]
Message-ID: <review-patch1-20260410013907.2404175-1-ashutoshdesai993@gmail.com> (raw)
In-Reply-To: <20260410013907.2404175-1-ashutoshdesai993@gmail.com>

Patch Review

**Positive aspects:**
- The commit message is well-written, clearly explains the vulnerability mechanism and the bypass of the existing guard, and references how other drivers handle this.
- The chosen error code `-E2BIG` is consistent with i915's approach (`i915_user_extensions.c:29`).
- The fix is simple and correct in behavior.

**Issues:**

1. **Missing `Fixes:` tag** (required for stable backport). The patch has `Cc: stable@vger.kernel.org` but no `Fixes:` tag identifying when `v3d_get_extensions()` was introduced. This is required by the stable kernel process for patches targeting stable. The tag should reference the commit that added the vulnerable function.

2. **Magic number — should use a named constant.** Both xe and i915 define named constants for their limits:

   ```c
   // xe (xe_bo.c:3291, xe_exec_queue.c:1128, xe_oa.c:1366):
   #define MAX_USER_EXTENSIONS  16
   
   // i915 (i915_user_extensions.c:21):
   unsigned int stackdepth = 512;
   ```
   
   The patch uses a bare `16`:
   ```c
   if (ext_count++ >= 16) {
   ```
   This should be a `#define`, e.g. `#define V3D_MAX_EXTENSIONS 16`, placed near the top of the function or in the file's defines section.

3. **Consider also fixing the weak duplicate guard.** The depth limit is good defense-in-depth, but the underlying duplicate guard in `v3d_get_multisync_submit_deps()` is fundamentally broken for the zero-sync-count case. Line 409 already sets `se->flags |= DRM_V3D_EXT_ID_MULTI_SYNC`, so the duplicate check could simply test the flags:

   ```c
   if (se->flags & DRM_V3D_EXT_ID_MULTI_SYNC) {
       drm_dbg(&v3d->drm, "Two multisync extensions...");
       return -EINVAL;
   }
   ```
   
   This would be a more robust fix at the source, and the other CPU extension types (`DRM_V3D_EXT_ID_CPU_INDIRECT_CSD`, `DRM_V3D_EXT_ID_CPU_TIMESTAMP_QUERY`, etc.) have **no** duplicate guard at all — a self-referential chain using any of those IDs would also loop, and on each iteration potentially allocate memory or do real work. The depth limit catches all cases, but fixing the guards would be a more complete solution. This could be a follow-up patch in a small series.

4. **Minor style point:** The post-increment in `ext_count++ >= 16` is correct (allows exactly 16 iterations, rejects on the 17th), but a pre-increment `++ext_count > 16` or `++ext_count > V3D_MAX_EXTENSIONS` would be slightly more readable, making it obvious that the first extension is counted as 1, not 0. This is a very minor nit.

**Verdict:** The fix addresses a real vulnerability and the approach is appropriate, but it needs at minimum a `Fixes:` tag and a named constant instead of the magic number `16`. The weak duplicate guard should ideally be fixed as well, either in this patch or as a follow-up.

---
Generated by Claude Code Patch Reviewer

      parent reply	other threads:[~2026-04-12  0:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10  1:39 [PATCH] drm/v3d: Limit ioctl extension chain depth to prevent infinite loop Ashutosh Desai
2026-04-10 18:16 ` Maíra Canal
2026-04-13  5:52   ` [PATCH v2] " Ashutosh Desai
2026-04-12  0:35 ` Claude review: " Claude Code Review Bot
2026-04-12  0:35 ` Claude Code Review Bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch1-20260410013907.2404175-1-ashutoshdesai993@gmail.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox