FAILED: patch "[PATCH] media: v4l2-ctrls: validate HEVC active reference counts" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x afbe4bc252d90a6f8fad869b06d5430f615f22f9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072916-driller-shed-862c@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From afbe4bc252d90a6f8fad869b06d5430f615f22f9 Mon Sep 17 00:00:00 2001
From: Pengpeng Hou <[email protected]>
Date: Tue, 24 Mar 2026 11:13:26 +0800
Subject: [PATCH] media: v4l2-ctrls: validate HEVC active reference counts
HEVC slice parameters are shared stateless V4L2 controls, but the common validation path does not verify the active L0/L1 reference counts before driver-specific code consumes them.
The original report came from Cedrus, but the active count bounds are not Cedrus-specific. Validate them in the common HEVC slice control path so stateless HEVC drivers get the same basic guarantees as soon as the control is queued.
Do not reject ref_idx_l0/ref_idx_l1 entries here. Existing userspace may use out-of-range sentinel values such as 0xff for missing references, and some hardware can use that information for concealment. Keep this common check limited to the active reference counts.
drivers/media/v4l2-core/v4l2-ctrls-core.c +13 -0
@@ -971,6 +971,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,struct v4l2_ctrl_hevc_ext_sps_st_rps *p_hevc_st_rps;struct v4l2_ctrl_hevc_sps *p_hevc_sps;struct v4l2_ctrl_hevc_pps *p_hevc_pps; +struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;struct v4l2_area *area;
@@ -1260,6 +1261,18 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,break ;case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS : + p_hevc_slice_params = p; + +if (p_hevc_slice_params->num_ref_idx_l0_active_minus1 >= +V4L2_HEVC_DPB_ENTRIES_NUM_MAX ) +return -EINVAL ; + +if (p_hevc_slice_params->slice_type !=V4L2_HEVC_SLICE_TYPE_B ) +break ; + +if (p_hevc_slice_params->num_ref_idx_l1_active_minus1 >= +V4L2_HEVC_DPB_ENTRIES_NUM_MAX ) +return -EINVAL ;break ;case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS :