* [PATCH iwl-net] ice: allow reading the last byte of the NVM and Shadow RAM regions
@ 2026-08-19 8:24 Petr Oros
2026-08-19 10:54 ` Przemek Kitszel
0 siblings, 1 reply; 3+ messages in thread
From: Petr Oros @ 2026-08-19 8:24 UTC (permalink / raw)
To: netdev
Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Aleksandr Loktionov, Paul Menzel, Jacob Keller, Kees Cook,
Robert Malz, Ratheesh Kannoth, Daniel Zahka, intel-wired-lan,
linux-kernel
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 <poros@redhat.com>
---
drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c
index 8c2b63eef82bd5..a52b6044288975 100644
--- a/drivers/net/ethernet/intel/ice/devlink/devlink.c
+++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c
@@ -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;
}
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iwl-net] ice: allow reading the last byte of the NVM and Shadow RAM regions
2026-08-19 8:24 [PATCH iwl-net] ice: allow reading the last byte of the NVM and Shadow RAM regions Petr Oros
@ 2026-08-19 10:54 ` Przemek Kitszel
2026-08-19 18:00 ` Jacob Keller
0 siblings, 1 reply; 3+ messages in thread
From: Przemek Kitszel @ 2026-08-19 10:54 UTC (permalink / raw)
To: Petr Oros, netdev
Cc: Tony Nguyen, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Aleksandr Loktionov, Paul Menzel,
Jacob Keller, Kees Cook, Robert Malz, Ratheesh Kannoth,
Daniel Zahka, intel-wired-lan, linux-kernel
On 8/19/26 10:24, Petr Oros wrote:
> 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 <poros@redhat.com>
> ---
> drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c
> index 8c2b63eef82bd5..a52b6044288975 100644
> --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c
> +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c
> @@ -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,
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH iwl-net] ice: allow reading the last byte of the NVM and Shadow RAM regions
2026-08-19 10:54 ` Przemek Kitszel
@ 2026-08-19 18:00 ` Jacob Keller
0 siblings, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2026-08-19 18:00 UTC (permalink / raw)
To: Przemek Kitszel, Petr Oros, netdev
Cc: Tony Nguyen, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Aleksandr Loktionov, Paul Menzel,
Kees Cook, Robert Malz, Ratheesh Kannoth, Daniel Zahka,
intel-wired-lan, linux-kernel
On 8/19/2026 3:54 AM, Przemek Kitszel wrote:
> On 8/19/26 10:24, Petr Oros wrote:
>> 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 <poros@redhat.com>
>> ---
>> drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/
>> drivers/net/ethernet/intel/ice/devlink/devlink.c
>> index 8c2b63eef82bd5..a52b6044288975 100644
>> --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c
>> +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c
>> @@ -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,
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Oops! Thanks for fixing my off-by-one error.
Acked-by: Jacob Keller <jacob.e.keller@intel.com>
Thanks,
Jake
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-19 18:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 8:24 [PATCH iwl-net] ice: allow reading the last byte of the NVM and Shadow RAM regions Petr Oros
2026-08-19 10:54 ` Przemek Kitszel
2026-08-19 18:00 ` Jacob Keller
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.