* [FFmpeg-devel] [PATCH] lavc/vvc: Prevent OOB write to slice_top_left_ctu_x in PPS CBS (PR #21317)
@ 2025-12-29 22:31 frankplow via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: frankplow via ffmpeg-devel @ 2025-12-29 22:31 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: frankplow
PR #21317 opened by frankplow
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21317
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21317.patch
Prior to the fix, in the case of a tile containing multiple slices
(pps_num_exp_slices_in_tile != 0) the number of slices was temporarily
allowed to exceed pps_num_slices_in_pic_minus1+1 and therefore
VVC_MAX_SLICES. The number of slices was later verified, but while the
current slice index was higher than expected it was used to write to a
array of size VVC_MAX_SLICES, leading to an OOB write.
To rectify this, the patch adds some checks at an earlier stage, to
ensure that the slice index i + j at no point exceeds
pps_num_slices_in_pic_minus1.
Fixes #YWH-PGM40646-30
>From 65574e151d92613cda0f8861f71de891c0e060b9 Mon Sep 17 00:00:00 2001
From: Frank Plowman <post@frankplowman.com>
Date: Mon, 29 Dec 2025 22:14:53 +0000
Subject: [PATCH] lavc/vvc: Prevent OOB write to slice_top_left_ctu_x in PPS
CBS
Prior to the fix, in the case of a tile containing multiple slices
(pps_num_exp_slices_in_tile != 0) the number of slices was temporarily
allowed to exceed pps_num_slices_in_pic_minus1+1 and therefore
VVC_MAX_SLICES. The number of slices was later verified, but while the
current slice index was higher than expected it was used to write to a
array of size VVC_MAX_SLICES, leading to an OOB write.
To rectify this, the patch adds some checks at an earlier stage, to
ensure that the slice index i + j at no point exceeds
pps_num_slices_in_pic_minus1.
Fixes #YWH-PGM40646-30
---
libavcodec/cbs_h266_syntax_template.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c
index d9a65a9c19..4f6ae76e27 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -2011,6 +2011,12 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw,
slice_top_left_ctu_y[i] = ctu_y;
} else {
uint16_t slice_height_in_ctus;
+ int num_uniform_slices;
+
+ if (i + current->pps_num_exp_slices_in_tile[i] >
+ current->pps_num_slices_in_pic_minus1 + 1)
+ return AVERROR_INVALIDDATA;
+
for (j = 0; j < current->pps_num_exp_slices_in_tile[i];
j++) {
ues(pps_exp_slice_height_in_ctus_minus1[i][j], 0,
@@ -2031,6 +2037,13 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw,
uniform_slice_height = 1 +
(j == 0 ? current->row_height_val[tile_y] - 1:
current->pps_exp_slice_height_in_ctus_minus1[i][j-1]);
+
+ num_uniform_slices = (remaining_height_in_ctbs_y + uniform_slice_height - 1)
+ / uniform_slice_height;
+ if (i + current->pps_num_exp_slices_in_tile[i] + num_uniform_slices >
+ current->pps_num_slices_in_pic_minus1 + 1)
+ return AVERROR_INVALIDDATA;
+
while (remaining_height_in_ctbs_y > uniform_slice_height) {
current->slice_height_in_ctus[i + j] =
uniform_slice_height;
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-29 22:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-29 22:31 [FFmpeg-devel] [PATCH] lavc/vvc: Prevent OOB write to slice_top_left_ctu_x in PPS CBS (PR #21317) frankplow via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git