mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Michael Bommarito <michael.bommarito@gmail.com>,
	Detlev Casanova	 <detlev.casanova@collabora.com>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	 Mauro Carvalho Chehab	 <mchehab@kernel.org>
Cc: Hans Verkuil <hverkuil@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	 linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,  stable@vger.kernel.org
Subject: Re: [PATCH v2 2/3] media: v4l2-ctrls: validate HEVC EXT SPS RPS counts
Date: Wed, 15 Jul 2026 18:42:52 -0400	[thread overview]
Message-ID: <bc9e8f84b27e72d2d8ac9d18d2add1a55affdada.camel@collabora.com> (raw)
In-Reply-To: <20260527194737.1999409-3-michael.bommarito@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3005 bytes --]

Le mercredi 27 mai 2026 à 15:47 -0400, Michael Bommarito a écrit :
> The HEVC SPS control carries the short-term and long-term RPS counts
> that decoder drivers use to walk the matching EXT SPS dynamic arrays.
> Reject SPS values that exceed the HEVC limits of 64 short-term sets and
> 32 long-term references so drivers cannot later index beyond those
> controls.
> 
> Also reject EXT SPS ST RPS entries whose negative or positive picture
> counts exceed the 16-entry arrays, or whose combined delta-POC count
> exceeds the HEVC DPB maximum.
> 
> Fixes: c9a59dc2acc7 ("media: rkvdec: Add HEVC support for the VDPU381 variant")
> Cc: stable@vger.kernel.org
> Suggested-by: Detlev Casanova <detlev.casanova@collabora.com>
> Assisted-by: Claude:claude-opus-4-7
> Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> ---
>  drivers/media/v4l2-core/v4l2-ctrls-core.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> index 6b375720e395c..a1d773e5de20c 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> @@ -16,6 +16,9 @@
>  
>  static const union v4l2_ctrl_ptr ptr_null;
>  
> +#define V4L2_HEVC_MAX_SHORT_TERM_REF_PIC_SETS	64
> +#define V4L2_HEVC_MAX_LONG_TERM_REF_PICS_SPS	32
> +
>  static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl,
>  		       u32 changes)
>  {
> @@ -1213,6 +1216,10 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
>  	case V4L2_CTRL_TYPE_HEVC_SPS:
>  		p_hevc_sps = p;
>  
> +		if (p_hevc_sps->num_short_term_ref_pic_sets >
> +		    V4L2_HEVC_MAX_SHORT_TERM_REF_PIC_SETS)
> +			return -EINVAL;
> +
>  		if (!(p_hevc_sps->flags & V4L2_HEVC_SPS_FLAG_PCM_ENABLED)) {
>  			p_hevc_sps->pcm_sample_bit_depth_luma_minus1 = 0;
>  			p_hevc_sps->pcm_sample_bit_depth_chroma_minus1 = 0;
> @@ -1223,6 +1230,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
>  		if (!(p_hevc_sps->flags &
>  		      V4L2_HEVC_SPS_FLAG_LONG_TERM_REF_PICS_PRESENT))
>  			p_hevc_sps->num_long_term_ref_pics_sps = 0;
> +		else if (p_hevc_sps->num_long_term_ref_pics_sps >
> +			 V4L2_HEVC_MAX_LONG_TERM_REF_PICS_SPS)
> +			return -EINVAL;
>  		break;
>  
>  	case V4L2_CTRL_TYPE_HEVC_PPS:
> @@ -1267,6 +1277,11 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
>  
>  		if (p_hevc_st_rps->flags & ~V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED)
>  			return -EINVAL;
> +		if (p_hevc_st_rps->num_negative_pics > 16 ||
> +		    p_hevc_st_rps->num_positive_pics > 16 ||
> +		    p_hevc_st_rps->num_negative_pics +
> +		    p_hevc_st_rps->num_positive_pics > 16)
> +			return -EINVAL;
>  		break;
>  
>  	case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS:

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-07-15 22:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 18:19 [PATCH] media: rkvdec: hevc: cap EXT SPS RPS control counts before descriptor assembly Michael Bommarito
2026-05-19 13:04 ` Detlev Casanova
2026-05-21  0:57   ` Michael Bommarito
2026-05-22 13:06     ` Detlev Casanova
2026-05-27 19:47 ` [PATCH v2 0/3] media: rkvdec: hevc: bound EXT SPS RPS control counts Michael Bommarito
2026-05-27 19:47   ` [PATCH v2 1/3] media: rkvdec: hevc: tighten EXT SPS RPS control dimensions Michael Bommarito
2026-07-15 22:25     ` Nicolas Dufresne
2026-05-27 19:47   ` [PATCH v2 2/3] media: v4l2-ctrls: validate HEVC EXT SPS RPS counts Michael Bommarito
2026-07-15 22:42     ` Nicolas Dufresne [this message]
2026-05-27 19:47   ` [PATCH v2 3/3] media: rkvdec: hevc: guard INTER_REF_PIC_SET_PRED index underflow Michael Bommarito
2026-07-15 22:45     ` Nicolas Dufresne

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=bc9e8f84b27e72d2d8ac9d18d2add1a55affdada.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=detlev.casanova@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=heiko@sntech.de \
    --cc=hverkuil@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=michael.bommarito@gmail.com \
    --cc=stable@vger.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