Skip to content

gpu: nova-core: use checked arithmetic for firmware parsing robustness

Joel Fernandes dri-devel linux-riscv lkml nouveau rust-for-linux 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 15 repliesIn review
  2. v15 patches 7 repliesSuperseded

Changes in v2 from the cover letter

- Added Reviewed-by tags from Zhi
- Fixed comment formatting nits raised by Dirk/Zhi

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5gpu: nova-core: use checked arithmetic in FWSEC firmware parsingdrivers/gpu/nova-core/firmware/fwsec.rs+35 -2512 replies
2/5gpu: nova-core: use checked arithmetic in Booter signature parsingdrivers/gpu/nova-core/firmware/booter.rs+14 -50 replies
3/5gpu: nova-core: use checked arithmetic in frombytes_at helperdrivers/gpu/nova-core/firmware/booter.rs+2 -10 replies
4/5gpu: nova-core: use checked arithmetic in BinFirmware::datadrivers/gpu/nova-core/firmware.rs+2 -10 replies
5/5gpu: nova-core: use checked arithmetic in RISC-V firmware parsingdrivers/gpu/nova-core/firmware/riscv.rs+4 -20 replies

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchZhi WangGary Guo
SeriesR-b
1/5R-b
2/5R-b
3/5R-b
4/5R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/5] gpu: nova-core: use checked arithmetic for firmware parsing robustness

Changes from v1 to v2:
- Added Reviewed-by tags from Zhi
- Fixed comment formatting nits raised by Dirk/Zhi

This series adds checked arithmetic throughout nova-core's firmware parsing code to guard rust code against integer overflow from corrupt firmware.

Without checked arithmetic, firmware could cause integer overflow when computing offsets. The danger is not just wrapping to a huge value (which may fail validation in other paths), but potentially wrapping to a small plausible offset that accesses entirely wrong data, causing silent corruption or security issues.

This series has been rebased on drm-rust-next. If possible, I would like us to consider merging for the upcoming merge window to avoid future conflicts. Tested probing with GPU name printed in dmesg on my GA102 (Ampere).

The git tree with all patches can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git (tag: nova-checked-arith-v2-20260126)

Link to v1: https://lore.kernel.org/all/[email protected]/

Joel Fernandes (5):
gpu: nova-core: use checked arithmetic in FWSEC firmware parsing
gpu: nova-core: use checked arithmetic in Booter signature parsing
gpu: nova-core: use checked arithmetic in frombytes_at helper
gpu: nova-core: use checked arithmetic in BinFirmware::data
gpu: nova-core: use checked arithmetic in RISC-V firmware parsing

 drivers/gpu/nova-core/firmware.rs        |  3 +-
 drivers/gpu/nova-core/firmware/booter.rs | 22 ++++++---
 drivers/gpu/nova-core/firmware/fwsec.rs  | 60 ++++++++++++++----------
 drivers/gpu/nova-core/firmware/riscv.rs  |  6 ++-
 4 files changed, 57 insertions(+), 34 deletions(-)

base-commit: cea7b66a80412e2a5b74627b89ae25f1d0110a4b --
2.34.1