dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pedro Yudi Honda" <niyudi.honda@usp.br>
Cc: ojeda@kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 2/5] drm/nova: use `zerocopy` in booter.rs
Date: Wed, 01 Jul 2026 17:50:04 +0000	[thread overview]
Message-ID: <20260701175005.38DCB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701174056.12604-3-niyudi.honda@gmail.com>

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

Pre-existing issues:
- [High] Kernel panic due to `chunks_exact(0)` when parsing malformed firmware signatures.
--

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

drm/nova: use `zerocopy` in booter.rs
    
In firmware/booter.rs, replace the following `transmute` traits with
their `zerocopy` equivalents:
    
- `transmute::FromBytes` -> `zerocopy::FromBytes`
    
Update call sites accordingly.

> diff --git a/drivers/gpu/nova-core/firmware/booter.rs b/drivers/gpu/nova-core/firmware/booter.rs
> index acb7f4d8a5327..fe9389b84b90a 100644
> --- a/drivers/gpu/nova-core/firmware/booter.rs
> +++ b/drivers/gpu/nova-core/firmware/booter.rs
[ ... ]
> @@ -144,6 +140,7 @@ fn signatures_iter(&'a self) -> Result<impl Iterator<Item = BooterSignature<'a>>

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a pre-existing issue
in signatures_iter().

If a malformed firmware file provides a num_sig greater than sig_prod_size
(but not 0), sig_size will evaluate to 0 because integer division truncates
towards zero.

Calling chunks_exact() with a chunk size of 0 triggers a kernel panic:

drivers/gpu/nova-core/firmware/booter.rs:signatures_iter() {
    ...
                self.fw
                    // Get signatures range.
                    .get(signatures_start..signatures_end)
                    .ok_or(EINVAL)?
                    .chunks_exact(sig_size.into_safe_cast())
    ...
}

Could this allow a local user who controls the firmware image or triggers
its loading to crash the kernel?

>  
>  /// Signature parameters, as defined in the firmware.
>  #[repr(C)]
> +#[derive(FromBytes)]
>  struct HsSignatureParams {
>      /// Fuse version to use.
>      fuse_ver: u32,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260701174056.12604-1-niyudi.honda@gmail.com?part=2

  reply	other threads:[~2026-07-01 17:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 17:40 [PATCH v2 0/5] drm/nova: replace `transmute` with `zerocopy` Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 1/5] drm/nova: use `zerocopy` in firmware.rs Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 2/5] drm/nova: use `zerocopy` in booter.rs Pedro Yudi Honda
2026-07-01 17:50   ` sashiko-bot [this message]
2026-07-01 17:40 ` [PATCH v2 3/5] drm/nova: use `zerocopy` in fwsec.rs Pedro Yudi Honda
2026-07-01 17:48   ` sashiko-bot
2026-07-01 17:40 ` [PATCH v2 4/5] drm/nova: use `zerocopy` in bootloader.rs Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 5/5] drm/nova: use `zerocopy` in riscv.rs Pedro Yudi Honda
  -- strict thread matches above, loose matches on Subject: below --
2026-07-02 12:03 [RESEND PATCH v2 0/5] drm/nova: replace `transmute` with `zerocopy` Pedro Yudi Honda
2026-07-02 12:03 ` [PATCH v2 2/5] drm/nova: use `zerocopy` in booter.rs Pedro Yudi Honda
2026-07-06 11:39   ` Alistair Popple

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=20260701175005.38DCB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox