From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: dma-buf: fix UAF in dma_buf_fd() tracepoint
Date: Mon, 25 May 2026 17:28:46 +1000 [thread overview]
Message-ID: <review-patch1-20260523181446.69525-1-devnexen@gmail.com> (raw)
In-Reply-To: <20260523181446.69525-1-devnexen@gmail.com>
Patch Review
**Correctness: Good.**
The race condition is real and the fix is correct. Looking at the `DMA_BUF_TRACE` macro (line 47-54 of `dma-buf.c`):
```c
#define DMA_BUF_TRACE(FUNC, ...) \
do { \
if (IS_ENABLED(CONFIG_LOCKDEP) || FUNC##_enabled()) { \
guard(spinlock)(&dmabuf->name_lock); \
FUNC(__VA_ARGS__); \
} \
} while (0)
```
This takes `dmabuf->name_lock`, so `dmabuf` must be alive when the tracepoint fires. With `FD_ADD()`, the file is already installed and visible to other threads, so a racing `close()` can trigger `__fput()` → release → free before the tracepoint runs.
The fix correctly places the tracepoint in the window between `get_unused_fd_flags()` (fd reserved, not yet populated) and `fd_install()` (fd becomes live):
```c
fd = get_unused_fd_flags(flags);
if (fd < 0)
return fd;
DMA_BUF_TRACE(trace_dma_buf_fd, dmabuf, fd);
fd_install(fd, dmabuf->file);
```
**Error handling: Correct.** The `fd < 0` check properly handles `get_unused_fd_flags()` failure and returns the error. No file reference leak since `dmabuf->file` hasn't been consumed yet at that point.
**Consistency:** This matches the pattern used by `dma_buf_put()` at line 852, where the tracepoint fires before `fput()` to avoid the same class of UAF.
**Commit message: Excellent.** Clear description of the race, the fix mechanism, references to the prior analogous fix, proper Fixes/Cc-stable/Reported-by tags, and correctly identifies the original commit that introduced the tracepoints as the Fixes target rather than the `FD_ADD()` conversion (since the bug predates `FD_ADD()` — it just became more visible with it).
**Stable tag:** `Cc: stable@vger.kernel.org # 7.0.x` — appropriate since the `FD_ADD()` conversion happened recently and this is the tree where the regression manifests.
**No issues found.** This is a clean, correct fix ready for merge.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-25 7:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 18:14 [PATCH] dma-buf: fix UAF in dma_buf_fd() tracepoint David Carlier
2026-05-25 7:28 ` Claude Code Review Bot [this message]
2026-05-25 7:28 ` 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-20260523181446.69525-1-devnexen@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