[PATCH v2 0/3] media: rkvdec: hevc: bound EXT SPS RPS control counts
Michael Bommarito
michael.bommarito at gmail.com
Wed May 27 12:47:34 PDT 2026
A userspace V4L2 client that can open the Rockchip RKVDEC m2m decoder
node can submit HEVC EXT SPS RPS controls whose spec-derived count
fields exceed the driver's fixed hardware descriptor tables and
temporary helper arrays. KASAN under a KUnit harness wrapping the real
rkvdec_hevc_assemble_hw_rps() helper confirms slab-out-of-bounds writes
on num_short_term_ref_pic_sets > 64, num_long_term_ref_pics_sps > 32,
num_negative/positive_pics > 16, and an OOB read via u8 ref_rps_idx
underflow when delta_idx_minus1 + 1 > idx.
v2 splits the single validation function from v1 into three layers at
the appropriate level, per Detlev's review:
1/3 Tighten .cfg.dims on EXT_SPS_ST_RPS (65 -> 64) and
EXT_SPS_LT_RPS (65 -> 32) to match the HEVC spec limits and
let the V4L2 control framework reject oversized payloads.
2/3 Add SPS ST/LT count validation plus
num_negative_pics / num_positive_pics validation in
v4l2-ctrls-core.c so every consumer driver is protected.
3/3 Guard the delta_idx_minus1 underflow in
st_ref_pic_set_prediction() in the rkvdec construction code.
Cc: stable at vger.kernel.org
Changes in v2:
- Split the monolithic rkvdec-hevc-common.c validation function into
dims, v4l2-core, and construction-code layers as Detlev suggested.
- Drop the rkvdec-local #defines and pr_err_ratelimited; the V4L2
framework now handles the bulk of the rejection, including the SPS
count fields that drive the rkvdec loops.
Michael Bommarito (3):
media: rkvdec: hevc: tighten EXT SPS RPS control dimensions
media: v4l2-ctrls: validate HEVC EXT SPS RPS counts
media: rkvdec: hevc: guard INTER_REF_PIC_SET_PRED index underflow
.../platform/rockchip/rkvdec/rkvdec-hevc-common.c | 3 +++
drivers/media/platform/rockchip/rkvdec/rkvdec.c | 4 ++--
drivers/media/v4l2-core/v4l2-ctrls-core.c | 15 +++++++++++++++
3 files changed, 20 insertions(+), 2 deletions(-)
base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
--
2.53.0
More information about the Linux-rockchip
mailing list