From: sashiko-bot@kernel.org
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
dri-devel@lists.freedesktop.org,
"Alexandre Courbot" <acourbot@nvidia.com>,
ojeda@kernel.org
Subject: Re: [PATCH 1/2] gpu: nova-core: use kernel lossless integer conversion module
Date: Fri, 28 Aug 2026 05:43:49 +0000 [thread overview]
Message-ID: <20260828054350.038DB1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260828-nova_num-v1-1-e21f17ba4127@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] A TOCTOU double-fetch vulnerability in GSP message parsing allows compromised or malicious GSP firmware to corrupt the CPU's message queue read pointer, causing desynchronization and potential denial of service.
--
commit eaaa0723c196a2c00643733ca548b4c1354725ff
Author: Alexandre Courbot <acourbot@nvidia.com>
gpu: nova-core: use kernel lossless integer conversion module
The kernel crate now features a replacement for our lossless integer
conversion routines. Switch to the kernel version and remove our own.
> diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
> index 6da728201281b..f85fde09aa6e3 100644
> --- a/drivers/gpu/nova-core/gsp/cmdq.rs
> +++ b/drivers/gpu/nova-core/gsp/cmdq.rs
[ ... ]
> @@ -162,7 +162,7 @@ fn read(
> #[repr(C, align(0x1000))]
> #[derive(Debug)]
> struct MsgqData {
> - data: [[u8; GSP_PAGE_SIZE]; num::u32_as_usize(MSGQ_NUM_PAGES)],
> + data: [[u8; GSP_PAGE_SIZE]; casts::u32_as_usize(MSGQ_NUM_PAGES)],
> }
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing cmdq.rs, I
noticed a pre-existing double-fetch issue that could allow a compromised GSP
firmware to desynchronize the message queue.
Could the GSP modify the message length in DMA memory after it has been
validated, causing the host to corrupt its CPU read pointer?
In CmdqInner::wait_for_msg(), the message length is fetched from DMA memory
and validated against the available buffer size to ensure it is safe:
CmdqInner::wait_for_msg() {
...
let payload_length = header.payload_length();
// Check that the driver read area is large enough for the message.
if slice_1.len() + slice_2.len() < payload_length {
return Err(EIO);
}
...
}
However, upon returning to CmdqInner::receive_msg(), the length is fetched
a second time directly from the shared memory when advancing the queue read
pointer:
CmdqInner::receive_msg() {
...
let message = self.wait_for_msg(timeout)?;
...
// Advance the read pointer past this message.
self.gsp_mem.advance_cpu_read_ptr(u32::try_from(
message.header.length().div_ceil(GSP_PAGE_SIZE),
)?);
...
}
Because message.header is a reference into DMA memory, this second fetch
uses an unvalidated value. If the GSP modifies the length field in DMA
memory between these two reads, the kernel will advance its read pointer by
an unvalidated amount. This could cause the kernel to misinterpret queue
memory, fail subsequent validations, and lose communication with the GSP.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260828-nova_num-v1-0-e21f17ba4127@nvidia.com?part=1
next prev parent reply other threads:[~2026-08-28 5:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 5:33 [PATCH 0/2] gpu: nova-core: complete conversion to kernel `num` module Alexandre Courbot
2026-08-28 5:33 ` [PATCH 1/2] gpu: nova-core: use kernel lossless integer conversion module Alexandre Courbot
2026-08-28 5:43 ` sashiko-bot [this message]
2026-08-28 12:09 ` Danilo Krummrich
2026-08-28 12:16 ` Miguel Ojeda
2026-08-29 3:34 ` Alexandre Courbot
2026-08-29 19:14 ` Danilo Krummrich
2026-08-31 1:08 ` Alexandre Courbot
2026-08-31 12:50 ` Danilo Krummrich
2026-08-31 14:20 ` Alexandre Courbot
2026-08-28 5:33 ` [PATCH 2/2] gpu: nova-core: use FromSafeCast wherever possible Alexandre Courbot
2026-08-28 5:42 ` Eliot Courtney
2026-08-28 5:49 ` sashiko-bot
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=20260828054350.038DB1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acourbot@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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