summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorVikash Garodia <quic_vgarodia@quicinc.com>2023-08-10 05:25:04 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-11-28 19:50:21 +0300
commit5d39d0c1f43f2efc0d97030f98e40fe012cf4507 (patch)
tree9793e68ea67a913acf500aacaf9f15318dcdd14e /drivers/media
parent497b12d47cc63d7e51e2ad0a920727631f3afa98 (diff)
downloadlinux-5d39d0c1f43f2efc0d97030f98e40fe012cf4507.tar.xz
media: venus: hfi_parser: Add check to keep the number of codecs within range
commit 0768a9dd809ef52440b5df7dce5a1c1c7e97abbd upstream. 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: stable@vger.kernel.org Fixes: 1a73374a04e5 ("media: venus: hfi_parser: add common capability parser") Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com> Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/qcom/venus/hfi_parser.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/media/platform/qcom/venus/hfi_parser.c b/drivers/media/platform/qcom/venus/hfi_parser.c
index 7f515a4b9bd1..e44cd8bf7837 100644
--- a/drivers/media/platform/qcom/venus/hfi_parser.c
+++ b/drivers/media/platform/qcom/venus/hfi_parser.c
@@ -19,6 +19,9 @@ static void init_codecs(struct venus_core *core)
struct venus_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);