From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Joel Fernandes" <joelagnelf@nvidia.com>,
"Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Alistair Popple" <apopple@nvidia.com>,
"nouveau@lists.freedesktop.org" <nouveau@lists.freedesktop.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH v3 2/4] gpu: nova-core: gsp: fix length of received messages
Date: Tue, 16 Dec 2025 22:02:52 +0900 [thread overview]
Message-ID: <DEZNTLSNCTMI.2ZGICVMVPHFJY@nvidia.com> (raw)
In-Reply-To: <63086256-CAD9-43AE-87CA-9569E6F392B1@nvidia.com>
On Tue Dec 16, 2025 at 6:21 PM JST, Joel Fernandes wrote:
> Hi Alex,
>
>> On Dec 15, 2025, at 9:57 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
>>
>> The size of messages' payload is miscalculated, leading to extra data
>> passed to the message handler. While this is not a problem with our
>> current set of commands, others with a variable-length payload may
>> misbehave. Fix this by introducing a method returning the payload size
>> and using it.
>>
>> Fixes: 75f6b1de8133 ("gpu: nova-core: gsp: Add GSP command queue bindings and handling")
>> Reviewed-by: Lyude Paul <lyude@redhat.com>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> ---
>> drivers/gpu/nova-core/gsp/cmdq.rs | 10 ++++++----
>> drivers/gpu/nova-core/gsp/fw.rs | 13 +++++++++----
>> 2 files changed, 15 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
>> index 6f946d14868a..7985a0b3f769 100644
>> --- a/drivers/gpu/nova-core/gsp/cmdq.rs
>> +++ b/drivers/gpu/nova-core/gsp/cmdq.rs
>> @@ -588,21 +588,23 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {
>> header.length(),
>> );
>>
>> + 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() < header.length() {
>> + if slice_1.len() + slice_2.len() < payload_length {
>> return Err(EIO);
>> }
>>
>> // Cut the message slices down to the actual length of the message.
>> - let (slice_1, slice_2) = if slice_1.len() > header.length() {
>> + let (slice_1, slice_2) = if slice_1.len() > payload_length {
>> // PANIC: we checked above that `slice_1` is at least as long as `msg_header.length()`.
>> - (slice_1.split_at(header.length()).0, &slice_2[0..0])
>> + (slice_1.split_at(payload_length).0, &slice_2[0..0])
>> } else {
>> (
>> slice_1,
>> // PANIC: we checked above that `slice_1.len() + slice_2.len()` is at least as
>> // large as `msg_header.length()`.
>> - slice_2.split_at(header.length() - slice_1.len()).0,
>> + slice_2.split_at(payload_length - slice_1.len()).0,
>
> The panic comments also need updating?
Oh, they do - nice catch, thanks!
next prev parent reply other threads:[~2025-12-16 13:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-16 2:57 [PATCH v3 0/4] gpu: nova-core: fixups for GSP message queue and bindings Alexandre Courbot
2025-12-16 2:57 ` [PATCH v3 1/4] gpu: nova-core: bindings: add missing explicit padding Alexandre Courbot
2025-12-16 2:57 ` [PATCH v3 2/4] gpu: nova-core: gsp: fix length of received messages Alexandre Courbot
2025-12-16 6:14 ` Alistair Popple
2025-12-16 7:57 ` Alexandre Courbot
2025-12-16 9:21 ` Joel Fernandes
2025-12-16 13:02 ` Alexandre Courbot [this message]
2025-12-16 2:57 ` [PATCH v3 3/4] gpu: nova-core: bindings: derive `MaybeZeroable` Alexandre Courbot
2025-12-16 2:57 ` [PATCH v3 4/4] gpu: nova-core: gsp: replace firmware version with "bindings" alias Alexandre Courbot
2025-12-16 9:21 ` [PATCH v3 0/4] gpu: nova-core: fixups for GSP message queue and bindings Joel Fernandes
2025-12-16 14:31 ` 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=DEZNTLSNCTMI.2ZGICVMVPHFJY@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
/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