Re: [PATCH] accel/ethosu: validate strides, format, and overflow in feat_matrix_length()

From: Rob Herring

Date: Fri Dec 04 2026 - 15:48:36 EST


On Sat, Nov 28, 2026 at 10:06:30PM +0800, Bilal Hashim wrote:
> In ethosu_gem_cmdstream_copy_and_validate(), `cmd_state_init()` fills
> `struct cmd_state` with `0xff` so that missing setup commands can be
> detected (leaving `s64 stride_x`, `stride_y`, and `stride_c` equal to
> `-1`).
>
> However, `feat_matrix_length()` never checks whether `fm->stride_y`,
> `fm->stride_x`, or `fm->stride_c` are negative (uninitialized), does not
> reject invalid format values `(fm->precision >> 6) & 0x3` greater than 1,
> and performs unchecked arithmetic on `addr` and `addr + 1`. If a command
> stream omits a stride setup command, multiplying by `-1` shrinks `addr`
> below `fm->base[tile]`, underestimating `info->region_size[fm->region]`
> and weakening the BO bounds check in `ethosu_ioctl_submit_job()`.
>
> Reject negative strides and unknown formats, and use `check_mul_overflow`
> and `check_add_overflow` when computing `addr` and `end = addr + 1`.

This is not complete.

See v5 of my validation fixes series.

Rob