mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: Vikash Garodia <quic_vgarodia@quicinc.com>,
	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 1/4] venus: hfi: add checks to perform sanity on queue pointers
Date: Thu, 10 Aug 2023 12:24:59 +0100	[thread overview]
Message-ID: <922c02e5-3081-45d4-4635-150393970bf8@linaro.org> (raw)
In-Reply-To: <1691634304-2158-2-git-send-email-quic_vgarodia@quicinc.com>

On 10/08/2023 03:25, Vikash Garodia wrote:
> Read and write pointers are used to track the packet index in the memory
> shared between video driver and firmware. There is a possibility of OOB
> access if the read or write pointer goes beyond the queue memory size.
> Add checks for the read and write pointer to avoid OOB access.
> 
> Cc: stable@vger.kernel.org
> Fixes: d96d3f30c0f2 ("[media] media: venus: hfi: add Venus HFI files")
> Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
> ---
>   drivers/media/platform/qcom/venus/hfi_venus.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> index f0b4638..4ddabb1 100644
> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> @@ -206,6 +206,11 @@ static int venus_write_queue(struct venus_hfi_device *hdev,
>   
>   	new_wr_idx = wr_idx + dwords;
>   	wr_ptr = (u32 *)(queue->qmem.kva + (wr_idx << 2));
> +
> +	if (wr_ptr < (u32 *)queue->qmem.kva ||
> +	    wr_ptr > (u32 *)(queue->qmem.kva + queue->qmem.size - sizeof(*wr_ptr)))
> +		return -EINVAL;
> +
>   	if (new_wr_idx < qsize) {
>   		memcpy(wr_ptr, packet, dwords << 2);
>   	} else {
> @@ -273,6 +278,11 @@ static int venus_read_queue(struct venus_hfi_device *hdev,
>   	}
>   
>   	rd_ptr = (u32 *)(queue->qmem.kva + (rd_idx << 2));
> +
> +	if (rd_ptr < (u32 *)queue->qmem.kva ||
> +	    rd_ptr > (u32 *)(queue->qmem.kva + queue->qmem.size - sizeof(*rd_ptr)))
> +		return -EINVAL;
> +
>   	dwords = *rd_ptr >> 2;
>   	if (!dwords)
>   		return -EINVAL;

What is the bit-shifting for ?

  reply	other threads:[~2023-08-10 11:25 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 [this message]
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
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=922c02e5-3081-45d4-4635-150393970bf8@linaro.org \
    --to=bryan.odonoghue@linaro.org \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.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=quic_vgarodia@quicinc.com \
    --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®