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: accel/ivpu: Add buffer overflow check in MS get_info_ioctl
Date: Thu, 04 Jun 2026 16:35:51 +1000	[thread overview]
Message-ID: <review-patch1-20260529120841.135852-1-andrzej.kacprowski@linux.intel.com> (raw)
In-Reply-To: <20260529120841.135852-1-andrzej.kacprowski@linux.intel.com>

Patch Review

**Purpose and correctness:**

The call chain is:
1. `ivpu_jsm_metric_streamer_info()` is called with `ivpu_bo_size(bo)` as the buffer size limit (line 290), and fills `info_size` (a `u64`) with the actual data size returned by firmware.
2. `info_size` is then used directly at line 299 in `copy_to_user(..., info_size)`.

If firmware returns an `info_size` larger than `ivpu_bo_size(bo)`, the `copy_to_user` would read past the end of the BO's mapped memory. The new check correctly catches this case before the data is used.

The placement is correct — right after the JSM call succeeds (line 291-292) and before either the `args->buffer_size` comparison or the `copy_to_user`. This ensures the firmware-returned size is validated against the kernel buffer before any further use.

**Format string nit:**

```c
ivpu_warn_ratelimited(vdev, "MS info overflow: %#llx > %#zx\n",
                      info_size, ivpu_bo_size(bo));
```

`info_size` is `u64` — in the kernel, the canonical format specifier for `u64` is `%llu` (or `%#llx` for hex, which is used here). That's fine. `ivpu_bo_size()` returns `size_t`, and `%zx` is appropriate for that. So the format specifiers are correct.

However, one could argue that a decimal format would be more readable for sizes in a warning message (comparing `0x10001` vs `0x10000` is harder to eyeball than `65537 > 65536`). This is purely a style preference and not a bug.

**Error code:**

`-EOVERFLOW` is a reasonable choice for this condition — it clearly conveys that the returned data would overflow the allocated buffer. Some drivers use `-ENOSPC` for related conditions, but `EOVERFLOW` better captures the "firmware returned more than it should have" semantics, distinguishing it from the existing `-ENOSPC` check on the user buffer (line 294).

**No concerns with the fix itself.** The patch is correct, minimal, and addresses a real vulnerability where firmware could cause an out-of-bounds kernel memory read that gets copied to userspace.

Reviewed-by assessment: **Acceptable as-is.**

---
Generated by Claude Code Patch Reviewer

      parent reply	other threads:[~2026-06-04  6:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 12:08 [PATCH] accel/ivpu: Add buffer overflow check in MS get_info_ioctl Andrzej Kacprowski
2026-05-29 12:23 ` Wachowski, Karol
2026-06-02  5:49   ` Wachowski, Karol
2026-06-04  6:35 ` Claude review: " Claude Code Review Bot
2026-06-04  6:35 ` Claude Code Review Bot [this message]

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-20260529120841.135852-1-andrzej.kacprowski@linux.intel.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