From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot 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 Message-ID: In-Reply-To: <20260410013907.2404175-1-ashutoshdesai993@gmail.com> References: <20260410013907.2404175-1-ashutoshdesai993@gmail.com> <20260410013907.2404175-1-ashutoshdesai993@gmail.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **Positive aspects:** - The commit message is well-written, clearly explains the vulnerability me= chanism and the bypass of the existing guard, and references how other driv= ers 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_e= xtensions()` was introduced. This is required by the stable kernel process = for patches targeting stable. The tag should reference the commit that adde= d the vulnerable function. 2. **Magic number =E2=80=94 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 =20 // i915 (i915_user_extensions.c:21): unsigned int stackdepth =3D 512; ``` =20 The patch uses a bare `16`: ```c if (ext_count++ >=3D 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 go= od defense-in-depth, but the underlying duplicate guard in `v3d_get_multisy= nc_submit_deps()` is fundamentally broken for the zero-sync-count case. Lin= e 409 already sets `se->flags |=3D DRM_V3D_EXT_ID_MULTI_SYNC`, so the dupli= cate 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; } ``` =20 This would be a more robust fix at the source, and the other CPU extensi= on types (`DRM_V3D_EXT_ID_CPU_INDIRECT_CSD`, `DRM_V3D_EXT_ID_CPU_TIMESTAMP_= QUERY`, etc.) have **no** duplicate guard at all =E2=80=94 a self-referenti= al chain using any of those IDs would also loop, and on each iteration pote= ntially 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 f= ollow-up patch in a small series. 4. **Minor style point:** The post-increment in `ext_count++ >=3D 16` is co= rrect (allows exactly 16 iterations, rejects on the 17th), but a pre-increm= ent `++ext_count > 16` or `++ext_count > V3D_MAX_EXTENSIONS` would be sligh= tly 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 app= ropriate, but it needs at minimum a `Fixes:` tag and a named constant inste= ad of the magic number `16`. The weak duplicate guard should ideally be fix= ed as well, either in this patch or as a follow-up. --- Generated by Claude Code Patch Reviewer