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: misc: fastrpc: fix use-after-free of fastrpc_user in workqueue context
Date: Thu, 30 Apr 2026 10:52:17 +1000	[thread overview]
Message-ID: <review-overall-20260427074021.3774769-1-anandu.e@oss.qualcomm.com> (raw)
In-Reply-To: <20260427074021.3774769-1-anandu.e@oss.qualcomm.com>

Overall Series Review

Subject: misc: fastrpc: fix use-after-free of fastrpc_user in workqueue context
Author: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
Patches: 1
Reviewed: 2026-04-30T10:52:17.356682

---

This single-patch series adds kref-based reference counting to `fastrpc_user` to fix a real use-after-free race: when a user closes the file descriptor while a DSP invocation is still in flight, `fastrpc_device_release()` frees the `fastrpc_user` structure, and then the workqueue-scheduled `fastrpc_context_free()` dereferences the freed user through `ctx->fl`. The approach — have each invoke context take a user reference at allocation and release it at context free — is correct in principle and follows the existing kref pattern already used for `fastrpc_channel_ctx` and `fastrpc_invoke_ctx`.

However, the patch has two bugs: a **kref initialization ordering issue** and, more seriously, a **use-after-free on the pending context list** in the new `fastrpc_user_free()`. The latter is a direct consequence of moving the pending-list cleanup into the kref release callback without accounting for the fact that contexts freed via the workqueue path are `kfree()`'d without being removed from `fl->pending`. The result is that `fastrpc_user_free()` iterates a list containing already-freed entries — trading one UAF for another.

The fix is close but needs another revision to address these issues before it can be merged.

---

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-04-30  0:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27  7:40 [PATCH v2] misc: fastrpc: fix use-after-free of fastrpc_user in workqueue context Anandu Krishnan E
2026-04-30  0:52 ` Claude Code Review Bot [this message]
2026-04-30  0:52 ` 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-overall-20260427074021.3774769-1-anandu.e@oss.qualcomm.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