On Tue Mar 24 16:08:56 2026 +0800, Pengpeng Hou wrote:
> Cedrus consumes H.264 ref_pic_list0/ref_pic_list1 entries from the
> stateless slice control and later uses their indices to look up
> decode->dpb[] in _cedrus_write_ref_list().
> 
> Rejecting such controls in cedrus_try_ctrl() would break existing
> userspace, since stateless H.264 reference lists may legitimately carry
> out-of-range indices for missing references. Instead, guard the actual
> DPB lookup in Cedrus and skip entries whose indices do not fit the fixed
> V4L2_H264_NUM_DPB_ENTRIES array.
> 
> This keeps the fix local to the driver use site and avoids out-of-bounds
> reads from malformed or unsupported reference list entries.
> 
> Fixes: e000e1fa4bdbd ("media: uapi: h264: Update reference lists")
> Cc: [email protected]
> Signed-off-by: Pengpeng Hou <[email protected]>
> Reviewed-by: Nicolas Dufresne <[email protected]>
> Acked-by: Jernej Skrabec <[email protected]>
> Tested-by: Chen-Yu Tsai <[email protected]>
> Signed-off-by: Nicolas Dufresne <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 3 +++
 1 file changed, 3 insertions(+)

---

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c 
b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
index 3e2843ef6cce..fc54d993b11f 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
@@ -210,6 +210,9 @@ static void _cedrus_write_ref_list(struct cedrus_ctx *ctx,
                u8 dpb_idx;
 
                dpb_idx = ref_list[i].index;
+               if (dpb_idx >= V4L2_H264_NUM_DPB_ENTRIES)
+                       continue;
+
                dpb = &decode->dpb[dpb_idx];
 
                if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE))
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to