mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: Zhi Wang <zhiw@nvidia.com>
Cc: linux-kernel@vger.kernel.org,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>, "Edwin Peer" <epeer@nvidia.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"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>,
	nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v1 2/5] gpu: nova-core: use checked arithmetic in Booter signature parsing
Date: Mon, 26 Jan 2026 06:00:01 -0500	[thread overview]
Message-ID: <064d5afd-f193-46f2-9c46-b20adcfe36df@nvidia.com> (raw)
In-Reply-To: <20260126100837.74c8597d.zhiw@nvidia.com>



On 1/26/2026 3:08 AM, Zhi Wang wrote:
> On Sat, 24 Jan 2026 18:18:27 -0500
> Joel Fernandes <joelagnelf@nvidia.com> wrote:
> 
>> Use checked_add() when computing signature offsets from firmware-
>> provided values in signatures_iter().
>>
>> Without checked arithmetic, overflow could wrap to a small plausible
>> offset that points to entirely wrong data.
>>
>> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
>> ---
>>   drivers/gpu/nova-core/firmware/booter.rs | 19 ++++++++++++++-----
>>   1 file changed, 14 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/nova-core/firmware/booter.rs
>> b/drivers/gpu/nova-core/firmware/booter.rs index
>> 86556cee8e67..f5ad619dc055 100644 ---
>> a/drivers/gpu/nova-core/firmware/booter.rs +++
>> b/drivers/gpu/nova-core/firmware/booter.rs @@ -119,14 +119,23 @@ fn
>> signatures_iter(&'a self) -> Result<impl Iterator<Item =
>> BooterSignature<'a>> Some(sig_size) => { let patch_sig =
>>                       frombytes_at::<u32>(self.fw,
>> self.hdr.patch_sig_offset.into_safe_cast())?;
>> -                let signatures_start =
>> usize::from_safe_cast(self.hdr.sig_prod_offset + patch_sig); +
>> +                // Compute signatures_start = hdr.sig_prod_offset +
>> patch_sig.
>> +                let signatures_start = self
>> +                    .hdr
>> +                    .sig_prod_offset
>> +                    .checked_add(patch_sig)
>> +                    .map(usize::from_safe_cast)
>> +                    .ok_or(EINVAL)?;
>> +
>> +                // Compute signatures_end = signatures_start +
>> hdr.sig_prod_size.
>> +                let signatures_end = signatures_start
>> +
>> .checked_add(usize::from_safe_cast(self.hdr.sig_prod_size))
>> +                    .ok_or(EINVAL)?;
>>   
> 
> The same concern of comment format in PATCH 1 raised by Dirk, With that
> addressed,
> 
> Reviewed-by: Zhi Wang <zhiw@nvidia.com>
Fixed and applied your tags, thank you!

--
Joel Fernandes


  reply	other threads:[~2026-01-26 11:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-24 23:18 [PATCH v1 0/5] gpu: nova-core: use checked arithmetic for firmware parsing robustness Joel Fernandes
2026-01-24 23:18 ` [PATCH v1 1/5] gpu: nova-core: use checked arithmetic in FWSEC firmware parsing Joel Fernandes
2026-01-25  9:09   ` Dirk Behme
2026-01-25 15:13     ` Joel Fernandes
2026-01-24 23:18 ` [PATCH v1 2/5] gpu: nova-core: use checked arithmetic in Booter signature parsing Joel Fernandes
2026-01-26  8:08   ` Zhi Wang
2026-01-26 11:00     ` Joel Fernandes [this message]
2026-01-24 23:18 ` [PATCH v1 3/5] gpu: nova-core: use checked arithmetic in frombytes_at helper Joel Fernandes
2026-01-26  8:00   ` Zhi Wang
2026-01-24 23:18 ` [PATCH v1 4/5] gpu: nova-core: use checked arithmetic in BinFirmware::data Joel Fernandes
2026-01-26  8:01   ` Zhi Wang
2026-01-24 23:18 ` [PATCH v1 5/5] gpu: nova-core: use checked arithmetic in RISC-V firmware parsing Joel Fernandes
2026-01-26  8:01   ` Zhi Wang

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=064d5afd-f193-46f2-9c46-b20adcfe36df@nvidia.com \
    --to=joelagnelf@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=epeer@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@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 \
    --cc=ttabi@nvidia.com \
    --cc=zhiw@nvidia.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®