Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 0768a9d

Browse files
Vikash-GarodiaHans Verkuil
authored andcommitted
media: venus: hfi_parser: Add check to keep the number of codecs within range
Supported codec bitmask is populated from the payload from venus firmware. There is a possible case when all the bits in the codec bitmask is set. In such case, core cap for decoder is filled and MAX_CODEC_NUM is utilized. Now while filling the caps for encoder, it can lead to access the caps array beyong 32 index. Hence leading to OOB write. The fix counts the supported encoder and decoder. If the count is more than max, then it skips accessing the caps. Cc: [email protected] Fixes: 1a73374 ("media: venus: hfi_parser: add common capability parser") Signed-off-by: Vikash Garodia <[email protected]> Signed-off-by: Stanimir Varbanov <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 8d0b893 commit 0768a9d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/media/platform/qcom/venus/hfi_parser.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ static void init_codecs(struct venus_core *core)
1919
struct hfi_plat_caps *caps = core->caps, *cap;
2020
unsigned long bit;
2121

22+
if (hweight_long(core->dec_codecs) + hweight_long(core->enc_codecs) > MAX_CODEC_NUM)
23+
return;
24+
2225
for_each_set_bit(bit, &core->dec_codecs, MAX_CODEC_NUM) {
2326
cap = &caps[core->codecs_count++];
2427
cap->codec = BIT(bit);

0 commit comments

Comments
 (0)