All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pedro Yudi Honda" <niyudi.honda@usp.br>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	dri-devel@lists.freedesktop.org, ojeda@kernel.org,
	"Alexandre Courbot" <acourbot@nvidia.com>
Subject: Re: [PATCH 3/7] drm/nova: use `zerocopy` in booter.rs
Date: Thu, 25 Jun 2026 21:06:57 +0000	[thread overview]
Message-ID: <20260625210658.4D26A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260625205146.5047-4-niyudi.honda@usp.br>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Firmware structures are parsed using native integer types, causing endianness mismatches on big-endian architectures.
--

commit f0a0d5143a0bf185e80fec9d804b5bc8f1e3c0b1
Author: Pedro Yudi Honda <niyudi.honda@usp.br>

drm/nova: use zerocopy in booter.rs

This commit replaces the transmute::FromBytes traits with their
zerocopy::FromBytes equivalents in the firmware/booter.rs file. It updates the
call sites and struct derivations to match the new library usage.

> diff --git a/drivers/gpu/nova-core/firmware/booter.rs b/drivers/gpu/nova-core/firmware/booter.rs
> index d9313ac361af3..0cda2c50fbbe9 100644
> --- a/drivers/gpu/nova-core/firmware/booter.rs
> +++ b/drivers/gpu/nova-core/firmware/booter.rs

[ ... ]

> @@ -44,7 +43,7 @@ fn frombytes_at<S: FromBytes + Sized>(slice: &[u8], offset: usize) -> Result<S>
>      let end = offset.checked_add(size_of::<S>()).ok_or(EINVAL)?;
>      slice
>          .get(offset..end)
> -        .and_then(S::from_bytes_copy)
> +        .and_then(|b| S::read_from_bytes(b).ok())
>          .ok_or(EINVAL)
>  }
>  
> @@ -53,7 +52,7 @@ fn frombytes_at<S: FromBytes + Sized>(slice: &[u8], offset: usize) -> Result<S>
>  /// Such firmwares have an application-specific payload that needs to be patched with a given
>  /// signature.
>  #[repr(C)]
> -#[derive(Debug, Clone)]
> +#[derive(Debug, Clone, FromBytes)]
>  struct HsHeaderV2 {
>      /// Offset to the start of the signatures.
>      sig_prod_offset: u32,
>      /// Size of the signatures.
>      sig_prod_size: u32,

[Severity: High]
This is a pre-existing issue, but does using native integer types like u32
in firmware structures cause endianness mismatches on big-endian architectures?

When frombytes_at() reads the firmware headers directly from fixed-endian
firmware blobs into host-endian structures using S::read_from_bytes(b), the
driver will parse incorrect offset and size values on big-endian systems.

Should these structures be updated to use explicitly endian-aware types (like
kernel::types::Le32) for fields such as sig_prod_offset and sig_prod_size to
ensure correct parsing across all architectures and avoid potential
out-of-bounds memory accesses?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260625205146.5047-1-niyudi.honda@usp.br?part=3

  reply	other threads:[~2026-06-25 21:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-25 20:51 [RESEND PATCH 0/7] drm/nova: replace `transmute` with `zerocopy` Pedro Yudi Honda
2026-06-25 20:51 ` [PATCH 1/7] drm/nova: use `zerocopy` in firmware.rs Pedro Yudi Honda
2026-06-25 20:51 ` [PATCH 2/7] drm/nova: use `zerocopy` in vbios.rs Pedro Yudi Honda
2026-06-25 21:14   ` sashiko-bot
2026-06-25 20:51 ` [PATCH 3/7] drm/nova: use `zerocopy` in booter.rs Pedro Yudi Honda
2026-06-25 21:06   ` sashiko-bot [this message]
2026-06-25 20:51 ` [PATCH 4/7] drm/nova: use `zerocopy` in fwsec.rs Pedro Yudi Honda
2026-06-25 20:51 ` [PATCH 5/7] drm/nova: use `zerocopy` in bootloader.rs Pedro Yudi Honda
2026-06-25 20:51 ` [PATCH 6/7] drm/nova: use `zerocopy` in riscv.rs Pedro Yudi Honda
2026-06-25 20:51 ` [PATCH 7/7] drm/nova: remove unused trait in commands.rs Pedro Yudi Honda
2026-06-25 21:04   ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-06-25 19:05 [PATCH 0/7] drm/nova: replace `transmute` with `zerocopy` Pedro Yudi Honda
2026-06-25 19:05 ` [PATCH 3/7] drm/nova: use `zerocopy` in booter.rs Pedro Yudi Honda
2026-06-25 19:14   ` 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=20260625210658.4D26A1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=niyudi.honda@usp.br \
    --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.