From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BB882D7DDB; Thu, 30 Jul 2026 15:15:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785424559; cv=none; b=PuINt5lg8NOoyFPR1pUb1Azr3B9951I2ohXwqpntLDoICDb+fRX+Z+iZFbsgA+6WdYtk93cOFxnlTmWuSO7uDeVCkrMWbPjJAoCTf+Owb6WZB7IrUcRSrpKMrLByrQwwP7t9XzU7hnDBc/pr//W4gnZ6fkdsdRCIZxbdwvAZJoM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785424559; c=relaxed/simple; bh=2Nv+KZtTgOZFpVIJGZMvapHTAbYmiXuZ6Dber21AkOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=roRqBmXd798CDeNlUyCxv8prQVn3RFBk/z1OO97sHiNErwIJReGDU3HnUrSINo8aK1X+EIbqjgLF1Tu3sTM4pqzvyWGVAU0Gd1Hk33gK3yZ3djSHkAW8Q0/PlM9Z8o4YNW/j7VSsSzTgB40rLhhpWBoJzcEtJ6k6Tn893aQiLqU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ssU7XLxo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ssU7XLxo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 788951F000E9; Thu, 30 Jul 2026 15:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785424558; bh=PN+ap/7Eaz8sNanenYR1gPmw10oTJP7cCwD6xBqk1AM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ssU7XLxozE46CICFmlwWq2GsBtZNmKP6DCtvP/Aa5I+rqHUDj0eSBsFCVXjIL/2xg ECFDbZj8EQH/lrzTDHvJDgyCMWqWnnP1TGGAm77VuI1hzx1leBSoAuFBOlF98e9SGg 7igHbqPcKXG++8MXIZm9S4DYMU+Yx67AS1+TFSgM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pengpeng Hou , Nicolas Dufresne , Hans Verkuil Subject: [PATCH 6.18 436/675] media: v4l2-ctrls: validate HEVC active reference counts Date: Thu, 30 Jul 2026 16:12:46 +0200 Message-ID: <20260730141454.408089564@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141445.110192266@linuxfoundation.org> References: <20260730141445.110192266@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pengpeng Hou commit afbe4bc252d90a6f8fad869b06d5430f615f22f9 upstream. 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. Fixes: d395a78db9eab ("media: hevc: Add decode params control") Cc: stable@vger.kernel.org Signed-off-by: Pengpeng Hou Reviewed-by: Nicolas Dufresne Signed-off-by: Nicolas Dufresne Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-ctrls-core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -882,6 +882,7 @@ static int std_validate_compound(const s struct v4l2_ctrl_h264_decode_params *p_h264_dec_params; 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; @@ -1171,6 +1172,18 @@ static int std_validate_compound(const s 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_HDR10_CLL_INFO: