]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: venus: hfi_parser: add check to avoid out of bound access
authorVikash Garodia <quic_vgarodia@quicinc.com>
Thu, 20 Feb 2025 17:20:08 +0000 (22:50 +0530)
committerHans Verkuil <hverkuil@xs4all.nl>
Mon, 3 Mar 2025 17:21:54 +0000 (18:21 +0100)
There is a possibility that init_codecs is invoked multiple times during
manipulated payload from video firmware. In such case, if codecs_count
can get incremented to value more than MAX_CODEC_NUM, there can be OOB
access. Reset the count so that it always starts from beginning.

Cc: stable@vger.kernel.org
Fixes: 1a73374a04e5 ("media: venus: hfi_parser: add common capability parser")
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/qcom/venus/hfi_parser.c

index 3df241dc3a118bcdeb2c28a6ffdb907b644d5653..1425c69d9006694adbc3ee0a67264c0d69522854 100644 (file)
@@ -19,6 +19,8 @@ static void init_codecs(struct venus_core *core)
        struct hfi_plat_caps *caps = core->caps, *cap;
        unsigned long bit;
 
+       core->codecs_count = 0;
+
        if (hweight_long(core->dec_codecs) + hweight_long(core->enc_codecs) > MAX_CODEC_NUM)
                return;