Skip to contentSkip to conversation

gpu: nova-core: fix bounds check In PmuLookupTableEntry::new, data is sliced from 2..6, but the bounds check data.len() < 5 does not satisfy those bounds.

PATCH In review Quaternions 2 participants 5 messages Jul 11, 2025 – Dec 13, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu: nova-core: fix bounds check In PmuLookupTableEntry::new, data is sliced from 2..6, but the bounds check data.len() < 5 does not satisfy those bounds.

---
 drivers/gpu/nova-core/vbios.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/nova-core/vbios.rs +1 -1
index 663fc50e8b66..5b5d9f38cbb3 100644
@@ -901,7 +901,7 @@ struct PmuLookupTableEntry {
 
 impl PmuLookupTableEntry {
     fn new(data: &[u8]) -> Result<Self> {
-        if data.len() < 5 {
+        if data.len() < 6 {
             return Err(EINVAL);
         }
 
Signature · 1 line
2.50.1
maintainer
#1 lore raw

Hi Rhys,

Quoted 1 line · Quaternions

Thanks for your contribution.

When sending patches, please make sure to follow the kernel's patch submission guidelines [1].

In particular, please stick to short and meaningful commit subject, followed by a commit description, even if the patch is simple and obvious.

Also make sure to run ./scripts/checkpatch.pl and ./scripts/get_maintainer.pl to get your patches checked and find the correct list of people to send them to.

Finally, please also consider the Rust submit checklist [2].

Thanks,
Danilo

[1] https://docs.kernel.org/process/submitting-patches.html
[2] https://rust-for-linux.com/contributing#submit-checklist-addendum

author
#2 lore raw

Hi Danilo,
I didn't understand the maintainers list yesterday, so all the patches I sent are missing mailing lists and recipients. I sent a second copy as requested in
https://gitlab.freedesktop.org/drm/nova/-/merge_requests/4#note_3003142,
and my mailing list mistakes were pointed out in detail. I also sent a fixed up v2 to the rust-for-linux mailing list only. If I need to send out another copy let me know, thanks.

Quoted 24 lines · Danilo Krummrich

Hi Rhys,

Quoted 1 line · Quaternions

Thanks for your contribution.

When sending patches, please make sure to follow the kernel's patch submission guidelines [1].

In particular, please stick to short and meaningful commit subject, followed by a commit description, even if the patch is simple and obvious.

Also make sure to run ./scripts/checkpatch.pl and ./scripts/get_maintainer.pl to get your patches checked and find the correct list of people to send them to.

Finally, please also consider the Rust submit checklist [2].

Thanks,
Danilo

[1] https://docs.kernel.org/process/submitting-patches.html
[2] https://rust-for-linux.com/contributing#submit-checklist-addendum

maintainer
#3 lore raw
Quoted 8 lines · Rhys Lloyd

Hi Danilo,
I didn't understand the maintainers list yesterday, so all the patches I sent are missing mailing lists and recipients. I sent a second copy as requested in
https://gitlab.freedesktop.org/drm/nova/-/merge_requests/4#note_3003142,
and my mailing list mistakes were pointed out in detail. I also sent a fixed up v2 to the rust-for-linux mailing list only. If I need to send out another copy let me know, thanks.

Can you please send a v2 following the instructions I linked in my previous reply?

For your patch, scripts/get_maintainer.pl should give you

Danilo Krummrich <[email protected]> (maintainer:CORE DRIVER FOR NVIDIA GPUS [RUST]) Alexandre Courbot <[email protected]> (maintainer:CORE DRIVER FOR NVIDIA GPUS [RUST]) David Airlie <[email protected]> (maintainer:DRM DRIVERS)
Simona Vetter <[email protected]> (maintainer:DRM DRIVERS) [email protected] (open list:CORE DRIVER FOR NVIDIA GPUS [RUST]) [email protected] (open list:DRM DRIVERS) [email protected] (open list)

Additionally, it makes sense to also add [email protected].

- Danilo

#4 lore raw

PATCH 1/1 gpu: nova-core: define named constants for magic numbers

In reply to Quaternions
---
 drivers/gpu/nova-core/vbios.rs | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/nova-core/vbios.rs +10 -5
index 5b5d9f38cbb3..d456c494374d 100644
@@ -364,8 +364,9 @@ struct BitHeader {
 }
 
 impl BitHeader {
+    const MIN_LEN: usize = 12;
     fn new(data: &[u8]) -> Result<Self> {
-        if data.len() < 12 {
+        if data.len() < Self::MIN_LEN {
             return Err(EINVAL);
         }
 
@@ -467,8 +468,9 @@ struct PciRomHeader {
 }
 
 impl PciRomHeader {
+    const MIN_LEN: usize = 26;
     fn new(pdev: &pci::Device, data: &[u8]) -> Result<Self> {
-        if data.len() < 26 {
+        if data.len() < Self::MIN_LEN {
             // Need at least 26 bytes to read pciDataStrucPtr and sizeOfBlock.
             return Err(EINVAL);
         }
@@ -772,10 +774,11 @@ fn into_image(self) -> Result<BiosImage> {
         BiosImage::try_from(self)
     }
 
+    const MIN_LEN: usize = 26;
     /// Creates a new BiosImageBase from raw byte data.
     fn new(pdev: &pci::Device, data: &[u8]) -> Result<Self> {
         // Ensure we have enough data for the ROM header.
-        if data.len() < 26 {
+        if data.len() < Self::MIN_LEN {
             dev_err!(pdev.as_ref(), "Not enough data for ROM header\n");
             return Err(EINVAL);
         }
@@ -900,8 +903,9 @@ struct PmuLookupTableEntry {
 }
 
 impl PmuLookupTableEntry {
+    const MIN_LEN: usize = 6;
     fn new(data: &[u8]) -> Result<Self> {
-        if data.len() < 6 {
+        if data.len() < Self::MIN_LEN {
             return Err(EINVAL);
         }
 
@@ -928,8 +932,9 @@ struct PmuLookupTable {
 }
 
 impl PmuLookupTable {
+    const MIN_LEN: usize = 4;
     fn new(pdev: &pci::Device, data: &[u8]) -> Result<Self> {
-        if data.len() < 4 {
+        if data.len() < Self::MIN_LEN {
             return Err(EINVAL);
         }
 
Signature · 1 line
2.50.1