Repository navigation
Conversation
avd_hevc_check_tiles() now keeps the tile layout inside the picture, but stream_slices() still indexes ctb_addr_rs_to_ts[], which has one entry per CTB of the picture, with each slice's slice_segment_addr. That value comes from userspace, and the V4L2 core cannot check it against the picture size. An address past the last CTB reads past the table, and the value read there then indexes tile_ids[]. Refuse a slice whose address is not a CTB of the picture (H.265 7.4.7.1), next to the tile check, before the tables are built. stream_slices() also takes the tile row from the count of tile segments, which follows the entry points userspace gives, and reads row_bd[row + 1]. Refuse a frame with more tile segments than the PPS has tiles. Add a KUnit case for the slice address check. Tested: checkpatch --strict is clean. Not yet built as a kernel module, run under KUnit, or run on hardware. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
avd_vp9_check_tiling() now bounds the tile counts, but set_tiles() still computes the tile data size as the payload minus the header sizes that userspace gives, which wraps when the headers claim more than the frame. It then reads 4-byte tile size markers at offsets past the frame. A tile size larger than the rest of the frame only stopped the loop, and the frame was still submitted with fewer tiles than the job counts. Refuse headers past the payload, a size marker past the remaining data and a tile size past the frame, and fail the frame with -EINVAL instead of submitting a partial job. The run frees its control copies and the error retires the request like any other run error. Tested: checkpatch --strict is clean. Not yet built as a kernel module, run under KUnit, or run on hardware. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
set_tiles() indexes the frame's mi_row_starts[], mi_col_starts[], height_in_sbs_minus_1[] and width_in_sbs_minus_1[] with tile_row and tile_col from each tile group entry. The V4L2 core does not validate the entries, so any u32 from userspace reads far past the frame control. Refuse an entry whose row or column is outside the frame's tile grid in avd_av1_check_tiles(), which already checks each entry's offset and size. Tested with tools/asahi/avd-av1-tail-tests.py (macOS needed extra include and warning flags): 1804 production controls pass. Not built as a kernel module or run on hardware. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
The H.264 scratch buffers (motion vectors and colour data), the capture buffer, and the slice table that avd_h264_start() allocates are all sized from the OUTPUT format. The header pushed to the engine takes the picture size from the SPS, which is not checked against that format. A stream whose SPS is larger than the format makes the engine work on a picture bigger than its buffers. HEVC already refuses this case in avd_hevc_validate_sps(). Do the same in avd_h264_validate_sps(). It runs when the SPS control is set, when streaming starts and when a frame runs, so start() refuses an oversized SPS before it allocates the slice table. The V4L2 core rounds the format up to the 16-pixel height and 64-pixel width steps, so a stream whose format was set from its own size always passes. Checked by reading: v4l2_apply_frmsize_constraints() rounds up, so the check cannot refuse a correctly configured stream. That the engine writes past its buffers for such an SPS was not confirmed on hardware; this is a defensive check in the safe direction. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the #2755 split. Draft until it has a run on a Mac (the last Evidence line says which). These are the AVD checks that 259b966, 5e26308 and
966778e do not already make.
Summary
Evidence
than the buffers sized from the format (found by reading; not shown on hardware).
avd_hevc_slices_testaccepts address 15 on a 4x4-CTB picture and refuses 16and U32_MAX. Build and KUnit (
avd,avd-pm) on arm64LLVM=1: passed, Apple build and KUnit.or A18 Pro), to show that no real stream is wrongly refused.
Merge Danger
Door: two-way
Blast Radius: decoding
A wrong bound would refuse a valid stream with -EINVAL. Each check compares against the picture
or format the stream itself declares, and the core rounds the format up.
Assisted-by: LLM (Claude:Opus 5.5)