From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke
Date: Thu, 04 Jun 2026 13:14:39 +1000 [thread overview]
Message-ID: <review-patch1-SYBPR01MB78817DBE3397783540CE3372AF122@SYBPR01MB7881.ausprd01.prod.outlook.com> (raw)
In-Reply-To: <SYBPR01MB78817DBE3397783540CE3372AF122@SYBPR01MB7881.ausprd01.prod.outlook.com>
Patch Review
**What it does:** Adds `spin_lock(&fl->lock)` / `spin_unlock(&fl->lock)` around the `list_for_each_entry_safe` loop in the `-ERESTARTSYS` path of `fastrpc_internal_invoke()`.
**Positive:**
- The bug is real. Every other accessor of `fl->mmaps` holds `fl->lock` — `fastrpc_req_mmap()` at line 1988, `fastrpc_req_munmap()` at line 1888, `fastrpc_req_munmap_impl()` at line 1868. The unprotected `list_del()` in the interrupt path could race with any of these.
- The commit message is clear and correctly identifies the Fixes: tag for the commit that introduced the bug.
- The `Cc: stable` tag is appropriate.
**Concern — destination list `cctx->invoke_interrupted_mmaps` is also unprotected:**
The patch protects the *source* list (`fl->mmaps`) with `fl->lock`, but the *destination* list (`fl->cctx->invoke_interrupted_mmaps`) belongs to the shared `fastrpc_channel_ctx`, not to this `fl`. Multiple `fastrpc_user` instances can share the same `cctx`. If two users are interrupted concurrently, each holds their own `fl->lock`, and both do:
```c
list_add_tail(&buf->node, &fl->cctx->invoke_interrupted_mmaps);
```
This is a concurrent modification of the same list without a common lock — `fl->lock` is per-user, so it provides no mutual exclusion between different users on the same channel. The `cctx` has its own `spinlock_t lock` (line 273) that could be used here, but this patch does not acquire it.
The only other accessor of `invoke_interrupted_mmaps` is in `fastrpc_rpmsg_remove()` (line 2495), which runs during channel teardown and iterates the list without any lock:
```c
list_for_each_entry_safe(buf, b, &cctx->invoke_interrupted_mmaps, node)
list_del(&buf->node);
```
That teardown path also has a potential race with ongoing invokes, though it's likely mitigated by the device going away.
**Recommendation:** This patch should either also acquire `cctx->lock` around the `list_add_tail` to protect the destination list, or the commit message should note that `invoke_interrupted_mmaps` is a known pre-existing issue being addressed separately. As-is, the patch fixes one race but leaves a second race on the same code path. A nested locking approach (hold `fl->lock` for the `list_del`, then acquire `cctx->lock` for the `list_add_tail`) would work, or both operations could be done under `cctx->lock` if the lock ordering allows it.
**Minor nit (not blocking):** The `fastrpc_rpmsg_remove()` cleanup at line 2495-2496 does `list_del(&buf->node)` but never frees `buf`, which looks like a memory leak. This is pre-existing and not introduced by this patch, but worth noting.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-06-04 3:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 5:29 [PATCH] misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke Junrui Luo
2026-06-04 3:14 ` Claude Code Review Bot [this message]
2026-06-04 3:14 ` Claude review: " 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-SYBPR01MB78817DBE3397783540CE3372AF122@SYBPR01MB7881.ausprd01.prod.outlook.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