]> Git Repo - linux.git/commitdiff
media: venus: hfi_parser: Add check to keep the number of codecs within range
authorVikash Garodia <[email protected]>
Thu, 10 Aug 2023 02:25:04 +0000 (07:55 +0530)
committerHans Verkuil <[email protected]>
Mon, 23 Oct 2023 10:24:52 +0000 (12:24 +0200)
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: 1a73374a04e5 ("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]>
drivers/media/platform/qcom/venus/hfi_parser.c

index 9d6ba22698cc4bc309860ae1fe99c6b5a7cff17a..c43839539d4ddabff75ba0113110d4a8027a0dc8 100644 (file)
@@ -19,6 +19,9 @@ static void init_codecs(struct venus_core *core)
        struct hfi_plat_caps *caps = core->caps, *cap;
        unsigned long bit;
 
+       if (hweight_long(core->dec_codecs) + hweight_long(core->enc_codecs) > MAX_CODEC_NUM)
+               return;
+
        for_each_set_bit(bit, &core->dec_codecs, MAX_CODEC_NUM) {
                cap = &caps[core->codecs_count++];
                cap->codec = BIT(bit);
This page took 0.069086 seconds and 4 git commands to generate.