From: Vikash Garodia <quic_vgarodia@quicinc.com>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
<stanimir.k.varbanov@gmail.com>, <agross@kernel.org>,
<andersson@kernel.org>, <konrad.dybcio@linaro.org>,
<mchehab@kernel.org>, <hans.verkuil@cisco.com>,
<tfiga@chromium.org>
Cc: <linux-media@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH v2 4/4] venus: hfi_parser: Add check to keep the number of codecs within range
Date: Mon, 14 Aug 2023 12:04:17 +0530 [thread overview]
Message-ID: <cd9da205-ccdb-dc71-16a4-83b22ca7fcae@quicinc.com> (raw)
In-Reply-To: <c5f912a9-cc08-1645-ad04-c7a58c1e47ce@linaro.org>
On 8/12/2023 12:21 AM, Bryan O'Donoghue wrote:
> On 11/08/2023 17:02, Vikash Garodia wrote:
>>
>>
>> On 8/11/2023 4:11 PM, Bryan O'Donoghue wrote:
>>> On 11/08/2023 09:49, Vikash Garodia wrote:
>>>>
>>>> On 8/11/2023 2:12 PM, Bryan O'Donoghue wrote:
>>>>> On 11/08/2023 07:04, Vikash Garodia wrote:
>>>>>>
>>>>>> On 8/10/2023 5:03 PM, Bryan O'Donoghue wrote:
>>>>>>> On 10/08/2023 03:25, Vikash Garodia wrote:
>>>>>>>> + if (hweight_long(core->dec_codecs) + hweight_long(core->enc_codecs) >
>>>>>>>> MAX_CODEC_NUM)
>>>>>>>> + return;
>>>>>>>> +
>>>>>>>
>>>>>>> Shouldn't this be >= ?
>>>>>> Not needed. Lets take a hypothetical case when core->dec_codecs has
>>>>>> initial 16
>>>>>> (0-15) bits set and core->enc_codecs has next 16 bits (16-31) set. The bit
>>>>>> count
>>>>>> would be 32. The codec loop after this check would run on caps array index
>>>>>> 0-31.
>>>>>> I do not see a possibility for OOB access in this case.
>>>>>>
>>>>>>>
>>>>>>> struct hfi_plat_caps caps[MAX_CODEC_NUM];
>>>>>>>
>>>>>>> ---
>>>>>>> bod
>>>>>>>
>>>>>
>>>>> Are you not doing a general defensive coding pass in this series ie
>>>>>
>>>>> "[PATCH v2 2/4] venus: hfi: fix the check to handle session buffer
>>>>> requirement"
>>>>
>>>> In "PATCH v2 2/4", there is a possibility if the check does not consider "=".
>>>> Here in this patch, I do not see a possibility.
>>>>
>>>>>
>>>>> ---
>>>>> bod
>>>
>>> But surely hweight_long(core->dec_codecs) + hweight_long(core->enc_codecs) ==
>>> MAX_CODEC_NUM is an invalid offset ?
>>
>> No, it isn't. Please run through the loop with the bitmasks added upto 32 and
>> see if there is a possibility of OOB.
>
> IDK Vikash, the logic here seems suspect.
>
> We have two loops that check for up to 32 indexes per loop. Why not have a
> capabilities index that can accommodate all 64 bits ?
Max codecs supported can be 32, which is also a very high number. At max the
hardware supports 5-6 codecs, including both decoder and encoder. 64 indices is
would not be needed.
> Why is it valid to have 16 encoder bits and 16 decoder bits but invalid to have
> 16 encoder bits with 17 decoder bits ? While at the same time valid to have 0
> encoder bits but 17 decoder bits ?
The addition of the encoder and decoder should be 32. Any combination which adds
to it, would go through. For ex, (17 dec + 15 enc) OR (32 dec + 0 enc) OR (0 dec
+ 32 enc) etc are valid combination theoretically, though there are only few
decoders and encoders actually supported by hardware.
Regards,
Vikash
next prev parent reply other threads:[~2023-08-14 6:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 2:25 [PATCH v2 0/4] Venus driver fixes to avoid possible OOB accesses Vikash Garodia
2023-08-10 2:25 ` [PATCH v2 1/4] venus: hfi: add checks to perform sanity on queue pointers Vikash Garodia
2023-08-10 11:24 ` Bryan O'Donoghue
2023-08-11 5:46 ` Vikash Garodia
2023-08-10 2:25 ` [PATCH v2 2/4] venus: hfi: fix the check to handle session buffer requirement Vikash Garodia
2023-08-10 11:26 ` Bryan O'Donoghue
2023-08-10 2:25 ` [PATCH v2 3/4] venus: hfi: add checks to handle capabilities from firmware Vikash Garodia
2023-08-10 11:31 ` Bryan O'Donoghue
2023-08-11 5:54 ` Vikash Garodia
2023-08-11 8:41 ` Bryan O'Donoghue
2023-08-11 8:51 ` Vikash Garodia
2023-08-11 10:39 ` Bryan O'Donoghue
2023-08-11 16:10 ` Vikash Garodia
2023-08-10 2:25 ` [PATCH v2 4/4] venus: hfi_parser: Add check to keep the number of codecs within range Vikash Garodia
2023-08-10 11:33 ` Bryan O'Donoghue
2023-08-11 6:04 ` Vikash Garodia
2023-08-11 8:42 ` Bryan O'Donoghue
2023-08-11 8:49 ` Vikash Garodia
2023-08-11 10:41 ` Bryan O'Donoghue
2023-08-11 16:02 ` Vikash Garodia
2023-08-11 18:51 ` Bryan O'Donoghue
2023-08-14 6:34 ` Vikash Garodia [this message]
2023-08-14 14:15 ` Bryan O'Donoghue
2023-08-29 8:00 ` Vikash Garodia
2023-08-29 11:59 ` Bryan O'Donoghue
2023-08-29 14:06 ` Vikash Garodia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cd9da205-ccdb-dc71-16a4-83b22ca7fcae@quicinc.com \
--to=quic_vgarodia@quicinc.com \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=hans.verkuil@cisco.com \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stanimir.k.varbanov@gmail.com \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®