ice: allow reading the last byte of the NVM and Shadow RAM regions
Subsystems (3)
PATCH 1/1 ice: allow reading the last byte of the NVM and Shadow RAM regions
ice_devlink_nvm_read() rejects a read whose end lands exactly on the region size, so feeding back the size devlink itself reports fails:
devlink region show pci/0000:04:00.0/nvm-flash pci/0000:04:00.0/nvm-flash: size 10485760 snapshot [] max 1
devlink region read pci/0000:04:00.0/nvm-flash address 0 length 10485760
Error: ice: Cannot read beyond the region size.
shadow-ram behaves the same. The regions are created with those sizes, so a read ending on the size is the whole region and has to be allowed. ice_read_flat_nvm() uses > for its own Shadow RAM check, and so does ixgbe, which grew its region support from this code.
--- drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/devlink/devlink.c +1 -1
@@ -1953,7 +1953,7 @@ static int ice_devlink_nvm_read(struct devlink *devlink,return -EOPNOTSUPP ; } -if (offset + size >= nvm_size) { +if (offset + size > nvm_size) {NL_SET_ERR_MSG_MOD (extack,"Cannot read beyond the region size" );return -ERANGE ; }
Signature · 1 line
2.54.0
Quoted 25 lines · Petr Oros
ice_devlink_nvm_read()rejects a read whose end lands exactly on the region size, so feeding back the size devlink itself reports fails:devlink region show pci/0000:04:00.0/nvm-flash pci/0000:04:00.0/nvm-flash: size 10485760 snapshot [] max 1
devlink region read pci/0000:04:00.0/nvm-flash address 0 length 10485760
Error: ice: Cannot read beyond the region size.shadow-ram behaves the same. The regions are created with those sizes, so a read ending on the size is the whole region and has to be allowed.
ice_read_flat_nvm()uses > for its own Shadow RAM check, and so does ixgbe, which grew its region support from this code.Fixes 3af4b40b0f2f ("ice: implement direct read for NVM and Shadow RAM regions")Signed-off-by Petr Oros <[email protected]>--- drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ice/devlink/devlink.c +0
-0
drivers/net/ethernet/intel/ice/devlink/devlink.c static int ice_devlink_nvm_read(struct devlink *devlink, · line 1959
Quoted 8 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +1
-1@@ -1953,7 +1953,7 @@ static int ice_devlink_nvm_read(struct devlink *devlink,return -EOPNOTSUPP ; } -if (offset + size >= nvm_size) { +if (offset + size > nvm_size) {NL_SET_ERR_MSG_MOD (extack,"Cannot read beyond the region size" );return -ERANGE ; }
Thank you,
Jacob Keller
Acked-byQuoted 40 lines · Przemek Kitszel
Quoted 33 lines · Petr Oros
ice_devlink_nvm_read()rejects a read whose end lands exactly on the region size, so feeding back the size devlink itself reports fails:devlink region show pci/0000:04:00.0/nvm-flash pci/0000:04:00.0/nvm-flash: size 10485760 snapshot [] max 1
devlink region read pci/0000:04:00.0/nvm-flash address 0 length 10485760
Error: ice: Cannot read beyond the region size.shadow-ram behaves the same. The regions are created with those sizes, so a read ending on the size is the whole region and has to be allowed.
ice_read_flat_nvm()uses > for its own Shadow RAM check, and so does ixgbe, which grew its region support from this code.Fixes 3af4b40b0f2f ("ice: implement direct read for NVM and ShadowRAM regions")
Signed-off-by Petr Oros <[email protected]>---
drivers/net/ethernet/intel/ice/devlink/devlink.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) renamed from drivers/net/ethernet/intel/ice/devlink/devlink.c +0
-0
drivers/net/ethernet/intel/ice/devlink/devlink.c
index8c2b63eef82bd5..a52b6044288975100644drivers/net/ethernet/intel/ice/devlink/devlink.c +1
-0@@ -1953,7 +1953,7 @@ static int ice_devlink_nvm_read(struct devlink *devlink, return -EOPNOTSUPP; } - if (offset + size >= nvm_size) { + if (offset + size > nvm_size) {Quoted 4 lines
NL_SET_ERR_MSG_MOD(extack, "Cannot read beyond the region size");
return-ERANGE;
}Thank you,
Quoted 1 line
Reviewed-by Przemek Kitszel <[email protected]>
Oops! Thanks for fixing my off-by-one error.
Thanks,
Jake
Quoted 15 lines
-----Original Message-----
From: Petr Oros <[email protected]>
Sent: Wednesday, August 19, 2026 1:25 AM
To: [email protected]
Cc: Oros, Petr <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Loktionov, Aleksandr <[email protected]>; Paul Menzel <[email protected]>; Keller, Jacob E <[email protected]>; Kees Cook <[email protected]>; Robert Malz <[email protected]>; Ratheesh Kannoth <[email protected]>; Daniel Zahka <[email protected]>; [email protected]; [email protected]
Subject: [PATCH iwl-net] ice: allow reading the last byte of the NVM and Shadow RAM regions
ice_devlink_nvm_read()rejects a read whose end lands exactly on the region size, so feeding back the size devlink itself reports fails:devlink region show pci/0000:04:00.0/nvm-flash pci/0000:04:00.0/nvm-flash: size 10485760 snapshot [] max 1
devlink region read pci/0000:04:00.0/nvm-flash address 0 length 10485760
Error: ice: Cannot read beyond the region size.
Quoted 8 lines
shadow-ram behaves the same. The regions are created with those sizes, so a read ending on the size is the whole region and has to be allowed.
ice_read_flat_nvm()uses > for its own Shadow RAM check, and so does ixgbe, which grew its region support from this code.Fixes 3af4b40b0f2f ("ice: implement direct read for NVM and Shadow RAM regions")Signed-off-by Petr Oros <[email protected]>--- drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)