From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: Vedang Nagar <quic_vnagar@quicinc.com>,
Stanimir Varbanov <stanimir.k.varbanov@gmail.com>,
Vikash Garodia <quic_vgarodia@quicinc.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] media: venus: fix OOB read issue due to double read
Date: Sun, 5 Jan 2025 23:58:40 +0000 [thread overview]
Message-ID: <f18c1277-0d72-4f7c-b325-5f19cfb0ab98@linaro.org> (raw)
In-Reply-To: <20250104-venus-security-fixes-v1-1-9d0dd4594cb4@quicinc.com>
On 04/01/2025 05:41, Vedang Nagar wrote:
> During message queue read, the address is being read twice
> from the shared memory. The first read is validated against
> the size of the packet, however the second read is not
> being validated.
A brief scan of this code doesn't really show the base case you assert here.
Could you be a bit more explicit.
Therefore, it's possible for firmware to
> modify the value to a bigger invalid value which can lead
> to OOB read access issue while reading the packet.
> Added fix to reupdate the size of the packet which was
> read for the first time.
>
> Signed-off-by: Vedang Nagar <quic_vnagar@quicinc.com>
> ---
> drivers/media/platform/qcom/venus/hfi_venus.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> index f9437b6412b91c2483670a2b11f4fd43f3206404..64cc9e916f53e5a9c82b1ff25c4475d622ebc321 100644
> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> @@ -298,6 +298,7 @@ static int venus_read_queue(struct venus_hfi_device *hdev,
> memcpy(pkt, rd_ptr, len);
> memcpy(pkt + len, queue->qmem.kva, new_rd_idx << 2);
> }
> + memcpy(pkt, (u32 *)(queue->qmem.kva + (rd_idx << 2)), sizeof(u32));
I'm not entirely following your reasoning here.
Here's how the code looks after your change:
if (new_rd_idx < qsize) {
memcpy(pkt, rd_ptr, dwords << 2);
} else {
size_t len;
new_rd_idx -= qsize;
len = (dwords - new_rd_idx) << 2;
memcpy(pkt, rd_ptr, len);
memcpy(pkt + len, queue->qmem.kva, new_rd_idx << 2);
}
memcpy(pkt, (u32 *)(queue->qmem.kva + (rd_idx << 2)), sizeof(u32));
Which of the above memcpy() operations is subject to a pointer that
firmware can influence exactly ?
Is this a real problem you've seen if so please add a backtrace to this
commit log.
> } else {
> /* bad packet received, dropping */
> new_rd_idx = qhdr->write_idx;
>
If this is a fix it requires a Fixes: tag.
Please add.
Still finding the reasoning you are outlining here not obvious.
---
bod
next prev parent reply other threads:[~2025-01-05 23:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-04 5:41 [PATCH 0/2] venus driver fixes to avoid possible OOB read access Vedang Nagar
2025-01-04 5:41 ` [PATCH 1/2] media: venus: fix OOB read issue due to double read Vedang Nagar
2025-01-05 23:58 ` Bryan O'Donoghue [this message]
2025-01-17 8:39 ` Vedang Nagar
2025-01-17 10:25 ` Bryan O'Donoghue
2025-01-29 5:00 ` Vedang Nagar
2025-01-04 5:41 ` [PATCH 2/2] media: venus: fix OOB access issue while reading sequence changed events Vedang Nagar
2025-01-06 0:06 ` Bryan O'Donoghue
2025-01-17 8:39 ` Vedang Nagar
2025-01-17 10:32 ` Bryan O'Donoghue
2025-01-29 5:01 ` Vedang Nagar
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=f18c1277-0d72-4f7c-b325-5f19cfb0ab98@linaro.org \
--to=bryan.odonoghue@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=quic_vnagar@quicinc.com \
--cc=stanimir.k.varbanov@gmail.com \
/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®