Re: [PATCH 1/2] media: rcar-isp: Account for the header in the ConfigDMA bounds check

From: Niklas Söderlund

Date: Wed Dec 02 2026 - 11:26:55 EST


Hi Hyeonjun,

Thanks for your work.

On 2026-12-03 00:17:17 +0900, Hyeonjun Hong wrote:
> risp_io_params_buffer_prepare() fills the ConfigDMA buffer with
> address/value pairs starting 8 bytes into the buffer, the first 8 bytes
> being reserved for the header. The bounds check in
> risp_conf_dma_prepare() compares the size of the pairs alone against
> RISP_IO_PARAMS_BUF_SIZE, so it accepts one pair more than fits and the
> last accepted pair is written to bytes 16384..16391 of the 16384 byte
> buffer.
>
> The number of pairs is controlled by the parameters buffer queued by
> userspace. v4l2_isp_params_validate_buffer() accepts repeated blocks of
> the same type and a header-only block still results in register writes.
> For example 171 header-only RPPX1_PARAMS_BLOCK_TYPE_CCOR_POST blocks
> with V4L2_ISP_PARAMS_FL_BLOCK_DISABLE set (1368 bytes of block data)
> produce more than the 2047 pairs that fit.
>
> Include the header in the check.
>
> Fixes: 2151350f60d1 ("media: rcar-isp: Add support for ISPCORE")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Hyeonjun Hong <hyeonjunhong330@xxxxxxxxx>
> ---
> drivers/media/platform/renesas/rcar-isp/core-io.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-isp/core-io.c b/drivers/media/platform/renesas/rcar-isp/core-io.c
> index b60b91f43d42..5c6018491160 100644
> --- a/drivers/media/platform/renesas/rcar-isp/core-io.c
> +++ b/drivers/media/platform/renesas/rcar-isp/core-io.c
> @@ -507,8 +507,8 @@ static int risp_conf_dma_prepare(void *priv, u32 offset, u32 value)
> {
> struct risp_conf_dma_write_desc *desc = priv;
>
> - /* Bounds check, 8 bytes = address (4)+ value (4). */
> - if ((desc->count + 1) * 8 > RISP_IO_PARAMS_BUF_SIZE)
> + /* Bounds check, 8 bytes header + 8 bytes = address (4) + value (4). */
> + if (8 + (desc->count + 1) * 8 > RISP_IO_PARAMS_BUF_SIZE)

Nice catch, but could you move the magic values to defines, maybe
something like,

#define RISP_IO_PARAMS_HEADER_SIZE 8
#define RISP_IO_PARAMS_MAX_PAIRS ((RISP_IO_PARAMS_BUF_SIZE - RISP_IO_PARAMS_HEADER_SIZE) / 8)

And use them here? I really should have added RISP_IO_PARAMS_MAX_PAIRS
myself when writing this...

> return -ENOMEM;
>
> (*desc->buf++) = desc->base | offset;
> --
> 2.34.1
>

--
Kind Regards,
Niklas Söderlund