Skip to content

Conversation

kumarsac
Copy link
Contributor

@kumarsac kumarsac commented Oct 8, 2025

User might pass picParam->log2_tile_columns as 0 for >4K width
In this scenario Vp9WriteUncompressHeader may crash in while loop
or huze loop due to possible col_data negative value.

To avoid this added a boundary check and making picParam->log2_tile_columns
same as min_log2_tile_cols.

@kumarsac kumarsac requested a review from XinfengZhang as a code owner October 8, 2025 09:32
col_data = picParam->log2_tile_columns - min_log2_tile_cols;
if (picParam->log2_tile_columns < min_log2_tile_cols)
{
col_data = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a bug fix, but rather a protective check for problematic parameters passed down from the APP. However, if the condition "picParam->log2_tile_columns < min_log2_tile_cols" is met, should the driver return directly? After all, if we continue execution, there might be other risks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is boundary check to avoid the crash or long while loop with possible col_data negative value in difference calculation.
We are hitting crash in Android CTS test. where width is 8192.
As per the calculation of min_log2_tile_cols in here it gives 1. But the picParam->log2_tile_columns is passed as 0. which acceptable as per the structure definition.

if value of log2_tile_columns in picParam is 0, Then there should not be any risk in encoding with that configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Agreed on adding boundary check here.
  2. To avoid risks in subsequent processing, I also suggest correcting picParam->log2_tile_columns to min_log2_tile_cols. Since picParam is an internal parameter, it should be safe to modify.
  3. Please add a warning message here to report this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RachelChengRJ
Completely agree with your point 2. I have modified the code to correct the picParam->log2_tile_columns.
Added a note in the code for future reference and Added the DDI_CODEC_ASSERTMESSAGE to get in the logs if this happens, or please suggest if any other log can be used ?

User might pass picParam->log2_tile_columns as 0 for >4K width
In this scenario Vp9WriteUncompressHeader may crash in while loop
or huze loop due to possible col_data negative value.

To avoid this added a boundary check and making picParam->log2_tile_columns
same as min_log2_tile_cols.

Signed-off-by: sachin kumar <[email protected]>
@kumarsac kumarsac changed the title [Encode] VP9 Encode Fix file colums calculation [Encode] VP9 Encode Add boundary check for log2_tile_columns Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants