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/ethosu: fix IFM region index out-of-bounds in command stream parser
Date: Mon, 25 May 2026 17:21:01 +1000	[thread overview]
Message-ID: <review-patch1-20260523195159.55801-1-meatuni001@gmail.com> (raw)
In-Reply-To: <20260523195159.55801-1-meatuni001@gmail.com>

Patch Review

**The bug:**  
At `ethosu_gem.c:467` (pre-patch), the IFM region was masked with `0x7f`:
```c
case NPU_SET_IFM_REGION:
    st.ifm.region = param & 0x7f;
```

This permits values up to 127, but `region_size[]` and `output_region[]` in `struct ethosu_validated_cmdstream_info` (`ethosu_gem.h:12-13`) are both `NPU_BASEP_REGION_MAX` (8) elements:
```c
u64 region_size[NPU_BASEP_REGION_MAX];   // 8 entries
bool output_region[NPU_BASEP_REGION_MAX]; // 8 entries
```

The region index is later used as a direct array subscript in `calc_sizes()` at `ethosu_gem.c:229`:
```c
info->region_size[fm->region] = max(info->region_size[fm->region], addr + 1);
```

A userspace-controlled `param > 7` causes a heap buffer overflow.

**The fix is correct:**  
All other region assignments use `& 0x7`:
- `ethosu_gem.c:507`: `st.ofm.region = param & 0x7`
- `ethosu_gem.c:541`: `st.ifm2.region = param & 0x7`
- `ethosu_gem.c:569`: `st.weight[0].region = param & 0x7`
- `ethosu_gem.c:572`: `st.scale[0].region = param & 0x7`
- `ethosu_gem.c:615`: `st.dma.src.region = param & 0x7`
- `ethosu_gem.c:622`: `st.dma.dst.region = param & 0x7`

The mask `0x7` limits the value to 0–7, exactly matching the array size of 8.

**Tags:** The `Fixes:` tag and `Cc: stable` are appropriate for a security-relevant bug fix.

**Commit message quality:** Excellent — clearly explains the inconsistency, the data flow from mask to array subscript, and the impact (heap corruption). This is a well-written single-line fix with a thorough justification.

**No issues found.** Reviewed-by worthy.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-05-25  7:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-23 19:51 [PATCH] accel/ethosu: fix IFM region index out-of-bounds in command stream parser Muhammad Bilal
2026-05-25  7:21 ` Claude Code Review Bot [this message]
2026-05-25  7:21 ` 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-20260523195159.55801-1-meatuni001@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