From: sashiko-bot@kernel.org
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: dri-devel@lists.freedesktop.org, gary@garyguo.net,
"Danilo Krummrich" <dakr@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
ojeda@kernel.org
Subject: Re: [PATCH 07/10] gpu: nova-core: gsp: cmdq: split the transport part of the receive path
Date: Sun, 27 Sep 2026 11:27:44 +0000 [thread overview]
Message-ID: <20260927112744.921E91F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927-cmdq-rpc-v1-7-822db5af910e@nvidia.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] gpu/nova-core: checksum validation fails on untrimmed queue buffer slices
- [High] gpu/nova-core: unvalidated element_count from GSP allows arbitrary read pointer manipulation
--
commit 4799dd94b859632b92a2a5821daacb47098f5faa
Author: Alexandre Courbot <acourbot@nvidia.com>
gpu: nova-core: gsp: cmdq: split the transport part of the receive path
This commit splits wait_for_msg into wait_for_element and wait_for_msg. The
transport layer is moved into wait_for_element, while the RPC layer that
trims the payload slices remains in wait_for_msg. This prepares the code
for moving the RPC layer into its own module.
> diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
> index a5595da23407b..d50a2a594f828 100644
> --- a/drivers/gpu/nova-core/gsp/cmdq.rs
> +++ b/drivers/gpu/nova-core/gsp/cmdq.rs
[ ... ]
> @@ -755,7 +584,7 @@ fn send_command<M>(&mut self, command: M) -> Result
> /// message queue.
> ///
> /// Error codes returned by the message constructor are propagated as-is.
> - fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {
> + fn wait_for_element(&self, timeout: Delta) -> Result<GspMessage<'_>> {
> // Wait for a message to arrive from the GSP.
> let (slice_1, slice_2) = read_poll_timeout(
> || Ok(self.gsp_mem.driver_read_area()),
> @@ -768,15 +597,41 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {
> // Extract the `GspMsgElement`.
> let (header, slice_1) = GspMsgElement::from_bytes_prefix(slice_1).ok_or(EIO)?;
>
> + // Validate checksum.
> + if Cmdq::calculate_checksum(SBufferIter::new_reader([
> + header.as_bytes(),
> + slice_1,
> + slice_2,
> + ])) != 0
> + {
> + dev_err!(&self.dev, "GSP receive: bad checksum\n");
> + return Err(EIO);
> + }
> +
> + Ok(GspMessage {
> + header,
> + contents: (slice_1, slice_2),
> + })
> + }
[Severity: High]
Does this code calculate the checksum over the entire available read area,
including trailing padding or queued messages?
In the original wait_for_msg(), slice_1 and slice_2 were trimmed to the
message payload_length before the checksum calculation. Since
wait_for_element() performs validation before trimming, won't valid messages
fail the checksum if there's extra data in the buffer?
[ ... ]
> @@ -863,9 +703,8 @@ fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M>
> };
>
> // 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),
> - )?);
> + self.gsp_mem
> + .advance_cpu_read_ptr(message.header.element_count());
>
> result
> }
[Severity: High]
Does this code allow an untrusted GSP to arbitrarily manipulate the host's
ring buffer read pointer?
The element_count() value comes directly from the GSP message header and
is never validated against the available read area or queue capacity, unlike
payload_length.
Can a malicious GSP send a small payload but a huge element_count to force
the kernel to process uninitialized memory or stale data?
(Note: In the final state of the patch series, this logic ends up in
receive_rpc_msg(), but the vulnerability is introduced here).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260927-cmdq-rpc-v1-0-822db5af910e@nvidia.com?part=7
next prev parent reply other threads:[~2026-09-27 11:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 11:14 [PATCH 00/10] gpu: nova-core: gsp: prepare the command queue for r000 dual-message types Alexandre Courbot
2026-09-27 11:14 ` [PATCH 01/10] gpu: nova-core: gsp: cmdq: use element_count to advance queue pointer Alexandre Courbot
2026-09-27 11:23 ` sashiko-bot
2026-09-27 11:14 ` [PATCH 02/10] gpu: nova-core: gsp: cmdq: validate checksum earlier on receive Alexandre Courbot
2026-09-27 11:23 ` sashiko-bot
2026-09-27 11:14 ` [PATCH 03/10] gpu: nova-core: gsp: introduce and use proper RpcMessageHeader type Alexandre Courbot
2026-09-27 11:25 ` sashiko-bot
2026-09-27 11:14 ` [PATCH 04/10] gpu: nova-core: gsp: cmdq: group the RPC-specific part of send_single_command Alexandre Courbot
2026-09-27 11:14 ` [PATCH 05/10] gpu: nova-core: gsp: cmdq: split the transport part of the send path Alexandre Courbot
2026-09-27 11:26 ` sashiko-bot
2026-09-27 11:14 ` [PATCH 06/10] gpu: nova-core: gsp: cmdq: move the RPC send code into a sub-module Alexandre Courbot
2026-09-27 11:14 ` [PATCH 07/10] gpu: nova-core: gsp: cmdq: split the transport part of the receive path Alexandre Courbot
2026-09-27 11:27 ` sashiko-bot [this message]
2026-09-27 11:14 ` [PATCH 08/10] gpu: nova-core: gsp: cmdq: move the RPC receive code into a sub-module Alexandre Courbot
2026-09-27 11:14 ` [PATCH 09/10] gpu: nova-core: gsp: move the RPC commands " Alexandre Courbot
2026-09-27 11:14 ` [PATCH 10/10] gpu: nova-core: gsp: add `rpc` to RPC message send/receive methods Alexandre Courbot
2026-09-27 11:22 ` sashiko-bot
2026-09-27 13:35 ` [PATCH 00/10] gpu: nova-core: gsp: prepare the command queue for r000 dual-message types Alexandre Courbot
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=20260927112744.921E91F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acourbot@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.