[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1769354007.1899374.21094@nvidia.com>
Date: Sun, 25 Jan 2026 10:13:27 -0500
From: Joel Fernandes <joelagnelf@...dia.com>
To: Dirk Behme <dirk.behme@...il.com>
Cc: <linux-kernel@...r.kernel.org>, Danilo Krummrich <dakr@...nel.org>,
Alexandre Courbot <acourbot@...dia.com>, Alice Ryhl <aliceryhl@...gle.com>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
John Hubbard <jhubbard@...dia.com>, Alistair Popple <apopple@...dia.com>,
Timur Tabi <ttabi@...dia.com>, Edwin Peer <epeer@...dia.com>,
Zhi Wang <zhiw@...dia.com>, Bjorn Helgaas <bhelgaas@...gle.com>,
Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>, Trevor Gross <tmgross@...ch.edu>,
<nouveau@...ts.freedesktop.org>, <dri-devel@...ts.freedesktop.org>,
<rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH v1 1/5] gpu: nova-core: use checked arithmetic in FWSEC firmware parsing
On Jan 25, 2026, at 4:09 AM, Dirk Behme <dirk.behme@...il.com> wrote:
>
> Hi Joel,
>
> On 25.01.26 00:18, Joel Fernandes wrote:
>> Use checked_add() and checked_mul() when computing offsets from
>> firmware-provided values in new_fwsec().
>>
>> Without checked arithmetic, corrupt firmware could cause integer overflow. The
>> danger is not just wrapping to a huge value, but potentially wrapping to a
>> small plausible offset that passes validation yet accesses entirely wrong data,
>> causing silent corruption or security issues.
>>
>> Signed-off-by: Joel Fernandes <joelagnelf@...dia.com>
>> ---
>> drivers/gpu/nova-core/firmware/fwsec.rs | 60 ++++++++++++++-----------
>> 1 file changed, 35 insertions(+), 25 deletions(-)
>>
>> diff --git a/drivers/gpu/nova-core/firmware/fwsec.rs b/drivers/gpu/nova-core/firmware/fwsec.rs
>> index a8ec08a500ac..1a91bbbce3d5 100644
>> --- a/drivers/gpu/nova-core/firmware/fwsec.rs
>> +++ b/drivers/gpu/nova-core/firmware/fwsec.rs
>> @@ -46,10 +46,7 @@
> ...
>> @@ -356,8 +362,12 @@ pub(crate) fn new(
>> // Patch signature if needed.
>> let desc = bios.fwsec_image().header()?;
>> let ucode_signed = if desc.signature_count() != 0 {
>> - let sig_base_img =
>> - usize::from_safe_cast(desc.imem_load_size() + desc.pkc_data_offset());
>> + // Compute sig_base_img = desc.imem_load_size + desc.pkc_data_offset.
>
> Nit: Drop `desc.` to make it consistent with the other comments.
Ok, thanks. I request anyone applying the patch to fix that on apply, but I can
totally do that if respinning/resending.
--
Joel Fernandes
Powered by blists - more mailing lists