From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Jernej Skrabec <jernej.skrabec@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>
Cc: Maxime Ripard <mripard@kernel.org>,
Paul Kocialkowski <paulk@sys-base.io>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Chen-Yu Tsai <wens@kernel.org>,
Samuel Holland <samuel@sholland.org>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 07/11] staging: media: cedrus: validate VP8 frame size
Date: Thu, 26 Nov 2026 17:39:18 -0500 [thread overview]
Message-ID: <74b063cdc772987150f00e084e60503e32291f23.camel@collabora.com> (raw)
In-Reply-To: <20261109175016.42061-8-jernej.skrabec@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3122 bytes --]
Le lundi 09 novembre 2026 à 18:50 +0100, Jernej Skrabec a écrit :
> A VP8 key frame can change the frame size. If userspace doesn't
> reallocate the capture buffers, the hardware writes and reads past the
> buffers, which shows up as IOMMU page faults and decode timeouts.
>
> Like for the H.264 and HEVC SPS, reject frames beyond the hardware
> limits in try_ctrl, and fail the job in the setup callback if the frame
> doesn't fit the buffers. The VP8 frame size register holds the size in
> 8-bit macroblock counts, so VP8 frames are limited to 4080 pixels in
> width.
>
> Fixes: 3c39a16d30d8 ("media: cedrus: Add support for VP8 decoding")
> Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
> drivers/staging/media/sunxi/cedrus/cedrus.c | 10 ++++++++++
> drivers/staging/media/sunxi/cedrus/cedrus_vp8.c | 3 +++
> 2 files changed, 13 insertions(+)
>
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
> index 197213911bf7..6c6aa45f5f96 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
> @@ -28,6 +28,8 @@
> #include "cedrus_dec.h"
> #include "cedrus_hw.h"
>
> +#define CEDRUS_VP8_MAX_WIDTH 4080U
> +
> /*
> * Reject picture sizes beyond the hardware limits. Whether the picture fits
> * the buffers is checked when a job is set up, see cedrus_check_pic_size().
> @@ -54,6 +56,13 @@ static int cedrus_try_ctrl(struct v4l2_ctrl *ctrl)
> if (!cedrus_pic_size_supported(cedrus_h264_sps_width(sps),
> cedrus_h264_sps_height(sps)))
> return -EINVAL;
> + } else if (ctrl->id == V4L2_CID_STATELESS_VP8_FRAME) {
> + const struct v4l2_ctrl_vp8_frame *frame = ctrl->p_new.p_vp8_frame;
> +
> + /* The VP8 frame size register holds 8-bit macroblock counts. */
> + if (!cedrus_pic_size_supported(frame->width, frame->height) ||
> + frame->width > CEDRUS_VP8_MAX_WIDTH)
> + return -EINVAL;
> } else if (ctrl->id == V4L2_CID_STATELESS_HEVC_SPS) {
> const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps;
> struct cedrus_ctx *ctx = container_of(ctrl->handler, struct cedrus_ctx, hdl);
> @@ -248,6 +257,7 @@ static const struct cedrus_control cedrus_controls[] = {
> {
> .cfg = {
> .id = V4L2_CID_STATELESS_VP8_FRAME,
> + .ops = &cedrus_ctrl_ops,
> },
> .capabilities = CEDRUS_CAPABILITY_VP8_DEC,
> },
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c
> index 969677a3bbf9..fecca343bd92 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c
> @@ -662,6 +662,9 @@ static int cedrus_vp8_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)
> int header_size;
> u32 reg;
>
> + if (cedrus_check_pic_size(ctx, slice->width, slice->height))
> + return -EINVAL;
> +
> cedrus_engine_enable(ctx);
>
> cedrus_write(dev, VE_H264_CTRL, VE_H264_CTRL_VP8);
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-11-26 22:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 17:50 [PATCH v2 00/11] staging: media: cedrus: assorted fixes and VP8 4K support Jernej Skrabec
2026-11-09 17:50 ` [PATCH v2 01/11] staging: media: cedrus: free MV-col buffers in buf_cleanup Jernej Skrabec
2026-11-09 17:50 ` [PATCH v2 02/11] staging: media: cedrus: reject too large H.264/HEVC SPS Jernej Skrabec
2026-11-26 22:37 ` Nicolas Dufresne
2026-11-09 17:50 ` [PATCH v2 03/11] staging: media: cedrus: h264: mark long-term references in the frame info Jernej Skrabec
2026-11-09 17:50 ` [PATCH v2 04/11] staging: media: cedrus: mpeg2: use the field height for field pictures Jernej Skrabec
2026-11-26 22:38 ` Nicolas Dufresne
2026-11-09 17:50 ` [PATCH v2 05/11] staging: media: cedrus: mpeg2: derive the field order of " Jernej Skrabec
2026-11-09 17:50 ` [PATCH v2 06/11] staging: media: cedrus: mpeg2: fix the references " Jernej Skrabec
2026-11-09 17:50 ` [PATCH v2 07/11] staging: media: cedrus: validate VP8 frame size Jernej Skrabec
2026-11-26 22:39 ` Nicolas Dufresne [this message]
2026-11-09 17:50 ` [PATCH v2 08/11] staging: media: cedrus: vp8: use the vendor probability table size Jernej Skrabec
2026-11-09 17:50 ` [PATCH v2 09/11] staging: media: cedrus: h616: use the 256-bit DDR mode Jernej Skrabec
2026-11-09 17:50 ` [PATCH v2 10/11] staging: media: cedrus: h264: clear the DRAM buffer sizes on start Jernej Skrabec
2026-11-26 22:39 ` Nicolas Dufresne
2026-11-09 17:50 ` [PATCH v2 11/11] staging: media: cedrus: vp8: support frames wider than 2048 pixels Jernej Skrabec
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=74b063cdc772987150f00e084e60503e32291f23.camel@collabora.com \
--to=nicolas.dufresne@collabora.com \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil@kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-sunxi@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=paulk@sys-base.io \
--cc=samuel@sholland.org \
--cc=wens@kernel.org \
/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