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/panthor: Avoid potential UAF due to memory reclaim
Date: Sun, 12 Apr 2026 09:28:38 +1000	[thread overview]
Message-ID: <review-patch1-20260410195050.687201-1-akash.goel@arm.com> (raw)
In-Reply-To: <20260410195050.687201-1-akash.goel@arm.com>

Patch Review

**Correctness: Good.** The fix correctly ensures that new VA mappings on an already-evicted vm_bo are still invalidated by the shrinker. The original code:

```c
-		/* Skip already evicted GPU mappings. */
-		if (vm_bo->evicted)
-			continue;
```

...was too aggressive — it skipped not just the `drm_gpuvm_bo_evict()` call, but the entire VA walk below it. After the fix, only the `drm_gpuvm_bo_evict()` call is conditionally skipped:

```c
+		if (!vm_bo->evicted)
+			drm_gpuvm_bo_evict(vm_bo, true);
 		drm_gpuvm_bo_for_each_va(va, vm_bo) {
```

**Minor comment issue.** The new comment states:

```c
+		/* ...we don't call drm_gpuvm_bo_evict() again because this would
+		 * mess up with the internal gpuvm lists...
```

This is technically inaccurate. Looking at the underlying `__drm_gpuvm_bo_list_add()` in `drm_gpuvm.c:871`:

```c
static void
__drm_gpuvm_bo_list_add(struct drm_gpuvm *gpuvm, spinlock_t *lock,
			struct list_head *entry, struct list_head *list)
{
	cond_spin_lock(lock, !!lock);
	if (list_empty(entry))
		list_add_tail(entry, list);
	cond_spin_unlock(lock, !!lock);
}
```

The `list_empty()` guard already prevents double-insertion — calling `drm_gpuvm_bo_evict(vm_bo, true)` a second time would be a harmless no-op (evicted is already `true`, and the list add is guarded). The real reason to skip the call is that it's *redundant*, not that it would corrupt lists. Consider rewording to something like: "we skip the redundant drm_gpuvm_bo_evict() call since the vm_bo is already on the evict list."

This is purely a comment accuracy issue — the code behavior is correct either way.

**Locking:** The `mutex_trylock(&vm->op_lock)` path and the `drm_gpuvm_bo_for_each_va` loop are unchanged and remain correct relative to the pre-existing code.

**Fixes tag and attribution look correct.**

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-04-11 23:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10 19:50 [PATCH] drm/panthor: Avoid potential UAF due to memory reclaim Akash Goel
2026-04-11 23:28 ` Claude review: " Claude Code Review Bot
2026-04-11 23:28 ` Claude Code Review Bot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-04-13  8:02 [PATCH v2] " Akash Goel
2026-04-13  8:43 ` Claude review: " Claude Code Review Bot
2026-04-13  8:43 ` Claude Code Review Bot

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-20260410195050.687201-1-akash.goel@arm.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