Re: [PATCH v2 2/7] iio: accel: adxl313: Prevent FIFO buffer overflow in adxl313_fifo_transfer()

From: Jonathan Cameron

Date: Sat Nov 28 2026 - 18:13:31 EST


On Mon, 23 Nov 2026 07:50:28 +0000
Lee Jones <lee@xxxxxxxxxx> wrote:

> The ADXL313 32-entry FIFO plus one sample held in the output filter can
> yield up to 33 3-axis samples (ADXL313_FIFO_SIZE + 1). Because of
> missing parentheses in ADXL313_NUM_AXIS * ADXL313_FIFO_SIZE + 1,
> fifo_buf is sized at 97 16-bit elements instead of 99, overflowing the
> buffer by four bytes whenever all 33 entries are read.
>
> In addition, adxl313_get_samples() returns the 6-bit FIFO_STATUS entries
> field (0..63) without bounds checking, allowing a malfunctioning or
> spoofed bus device to overflow fifo_buf on the heap in
> adxl313_fifo_transfer().
>
> Parenthesise (ADXL313_FIFO_SIZE + 1) when sizing fifo_buf and reject
> entry counts exceeding ADXL313_FIFO_SIZE + 1 with -EIO in
> adxl313_get_samples().
>
> Fixes: ff8093fa6ba4 ("iio: accel: adxl313: add buffered FIFO watermark with interrupt handling")
> Closes: https://sashiko.dev/#/bug/linux-6baeb7fe-ad68-4961-b5f9-5f0c7628df1e
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
Applied to the fixes-togreg branch of iio.git. Depending on when I catch up
with backlog and random other reasons may or may not make it in before end
of the cycle.

Thanks,
Jonathan