All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rob Herring (Arm)" <robh@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 11/11] accel: ethosu: Validate OFM transpose
Date: Thu, 27 Aug 2026 20:56:01 +0000	[thread overview]
Message-ID: <20260827205601.82D471F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827-ethosu-fixes-v1-11-346f9ea8791c@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Inconsistent extraction of the 'storage' configuration bitfield between `feat_matrix_size` and `feat_matrix_length` allows an attacker to bypass bounds checking for `base[3]` on U65 devices, leading to arbitrary out-of-bounds memory accesses by the NPU.
--

commit bea32820db5d7b74645ac247f33a7633b6b22166
Author: Rob Herring (Arm) <robh@kernel.org>

accel: ethosu: Validate OFM transpose

This commit permutes the output endpoint before validating its tile and
stride accesses on U85 devices, while rejecting reserved transpose encodings.

> diff --git a/drivers/accel/ethosu/ethosu_gem.c b/drivers/accel/ethosu/ethosu_gem.c
> index a042e650f626a..ad36fb8b3b302 100644
> --- a/drivers/accel/ethosu/ethosu_gem.c
> +++ b/drivers/accel/ethosu/ethosu_gem.c
> @@ -283,6 +329,9 @@ static int feat_matrix_size(struct ethosu_device *edev,
>  	int ret;
>  
>  	*max_len = 0;
> +	ret = feat_matrix_permute(edev, fm, &x, &y, &c, ofm);
> +	if (ret)
> +		return ret;
>  
>  	if (ethosu_is_u65(edev) || storage == 0) {

[Severity: Critical]
This isn't a bug introduced by this patch, but does this inconsistent
extraction of the storage bitfield lead to missing bounds checks for the
4th tile on U65 devices?

In feat_matrix_size(), storage is correctly forced to 0 for U65 hardware:

drivers/accel/ethosu/ethosu_gem.c:feat_matrix_size() {
	u32 storage = ethosu_is_u65(edev) ? 0 : fm->precision >> 14;
    ...
}

This ensures the loop checks all 4 possible tile coordinates. However,
feat_matrix_length() extracts it directly from the precision bits without
checking if the hardware is U65:

drivers/accel/ethosu/ethosu_gem.c:feat_matrix_length() {
	u32 element_size, storage = fm->precision >> 14;
    ...
}

If a user provides a command stream with bits 14-15 set to 1 (indicating
storage = 1) and sets a large, out-of-bounds offset for base[3],
feat_matrix_size() forces storage = 0 and delegates address computation to
feat_matrix_length().

Because feat_matrix_length() uses the unmasked storage = 1 value, its tile
computation logic will only ever produce tile = 1 or tile = 2. As a result,
the 4th tile (base[3]) is never visited or verified against the GEM buffer
size.

The previous commit "accel: ethosu: Validate all feature map tiles"
attempted to fix U65 tile validation, but left the direct bitwise extraction
in feat_matrix_length() intact.

Since U65 hardware natively uses 2x2 tiling and ignores the storage bits,
could this allow the NPU DMA engine to access arbitrary physical memory
outside the provided GEM buffers when evaluating the true coordinates?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260827-ethosu-fixes-v1-0-346f9ea8791c@kernel.org?part=11

      reply	other threads:[~2026-08-27 20:56 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 20:32 [PATCH 00/11] accel: ethosu: Another batch of fixes Rob Herring (Arm)
2026-08-27 20:33 ` [PATCH 01/11] accel: ethosu: Fix ethosu_job_open() return value Rob Herring (Arm)
2026-08-27 20:46   ` sashiko-bot
2026-08-27 20:48   ` Frank Li
2026-08-27 20:33 ` [PATCH 02/11] accel: ethosu: Drop IRQF_SHARED flag Rob Herring (Arm)
2026-08-27 20:48   ` sashiko-bot
2026-08-27 20:49   ` Frank Li
2026-08-27 20:33 ` [PATCH 03/11] accel: ethosu: Ensure cmd stream ends with a stop op Rob Herring (Arm)
2026-08-27 20:52   ` Frank Li
2026-08-27 20:33 ` [PATCH 04/11] accel: ethosu: Ensure SRAM size is 0 on mapping failure Rob Herring (Arm)
2026-08-27 20:48   ` sashiko-bot
2026-08-27 20:55   ` Frank Li
2026-08-27 20:33 ` [PATCH 05/11] accel: ethosu: Ensure SRAM region size matches job Rob Herring (Arm)
2026-08-27 20:47   ` sashiko-bot
2026-08-27 20:57   ` Frank Li
2026-08-27 20:33 ` [PATCH 06/11] accel: ethosu: Fix probe error cleanup Rob Herring (Arm)
2026-08-27 20:45   ` sashiko-bot
2026-08-27 21:08   ` Frank Li
2026-08-27 20:33 ` [PATCH 07/11] accel: ethosu: Factor buffer bounds checks Rob Herring (Arm)
2026-08-27 20:48   ` sashiko-bot
2026-08-27 21:10   ` Frank Li
2026-08-27 20:33 ` [PATCH 08/11] accel: ethosu: Validate secondary streams Rob Herring (Arm)
2026-08-27 21:14   ` Frank Li
2026-08-27 20:33 ` [PATCH 09/11] accel: ethosu: Reject unsupported commands Rob Herring (Arm)
2026-08-27 20:48   ` sashiko-bot
2026-08-27 21:16   ` Frank Li
2026-08-27 20:33 ` [PATCH 10/11] accel: ethosu: Validate all feature map tiles Rob Herring (Arm)
2026-08-27 20:45   ` sashiko-bot
2026-08-27 20:33 ` [PATCH 11/11] accel: ethosu: Validate OFM transpose Rob Herring (Arm)
2026-08-27 20:56   ` sashiko-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=20260827205601.82D471F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.