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: Mon, 13 Apr 2026 18:43:07 +1000 [thread overview]
Message-ID: <review-patch1-20260413080253.1288157-1-akash.goel@arm.com> (raw)
In-Reply-To: <20260413080253.1288157-1-akash.goel@arm.com>
Patch Review
**The Bug:**
When the shrinker evicts a BO, all CPU and GPU mappings are invalidated and `vm_bo->evicted` is set to `true`. If a *new* GPU mapping is subsequently created for that BO, the `vm_bo` ends up in a "partially evicted" state — it's back on a reclaim list but `vm_bo->evicted` is still `true`. On the next shrinker invocation, the old code would skip this `vm_bo` entirely:
```c
/* Skip already evicted GPU mappings. */
if (vm_bo->evicted)
continue;
```
This means the newly created mapping is never torn down, so its backing pages can be reclaimed and reused while still mapped to the GPU — a classic use-after-free.
**The Fix:**
The patch replaces the early `continue` with a conditional guard on `drm_gpuvm_bo_evict()`, while always walking the VAs to tear down any non-evicted mappings:
```c
if (!vm_bo->evicted)
drm_gpuvm_bo_evict(vm_bo, true);
drm_gpuvm_bo_for_each_va(va, vm_bo) {
```
This is correct — it ensures every VA on the `vm_bo` is checked for invalidation regardless of the evicted flag.
**Minor observation on the comment:** The comment states that calling `drm_gpuvm_bo_evict()` again "would mess up with the internal gpuvm lists." Looking at the underlying `__drm_gpuvm_bo_list_add()` in `drivers/gpu/drm/drm_gpuvm.c`:
```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 actually protects against double-adds, so a duplicate `drm_gpuvm_bo_evict(vm_bo, true)` call wouldn't corrupt the list — it would just be a redundant no-op. The guard `if (!vm_bo->evicted)` is still good practice (avoids pointless locking and makes the intent clear), but the comment slightly overstates the danger. This is very minor and not worth holding up the patch.
**Verdict:** The fix is correct, minimal, has proper `Fixes:` tag targeting the right commit, and is already reviewed by the relevant maintainer. No issues blocking merge.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-04-13 8:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 8:02 [PATCH v2] drm/panthor: Avoid potential UAF due to memory reclaim Akash Goel
2026-04-13 8:43 ` Claude review: " Claude Code Review Bot
2026-04-13 8:43 ` Claude Code Review Bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-04-10 19:50 [PATCH] " Akash Goel
2026-04-11 23:28 ` Claude review: " Claude Code Review Bot
2026-04-11 23:28 ` 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-20260413080253.1288157-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