* [PATCH ethtool v2] ethtool: fix EEPROM byte write
@ 2022-08-19 10:10 Tomasz Moń
2022-08-21 23:20 ` patchwork-bot+netdevbpf
2022-08-21 23:28 ` Michal Kubecek
0 siblings, 2 replies; 3+ messages in thread
From: Tomasz Moń @ 2022-08-19 10:10 UTC (permalink / raw)
To: Michal Kubecek
Cc: netdev, Andrew Lunn, Krzysztof Drobiński, Tomasz Moń
ethtool since version 1.8 supports EEPROM byte write:
# ethtool -E DEVNAME [ magic N ] [ offset N ] [ value N ]
ethtool 2.6.33 added EEPROM block write:
# ethtool -E ethX [ magic N ] [ offset N ] [ length N ] [ value N ]
EEPROM block write introduced in 2.6.33 is backwards compatible, i.e.
when value is specified the length is forced to 1 (commandline length
value is ignored).
The byte write behaviour changed in ethtool 5.9 where the value write
only works when value parameter is specified together with length 1.
While byte writes to any offset other than 0, without length 1, simply
fail with "offset & length out of bounds" error message, writing value
to offset 0 basically erased whole EEPROM. That is, the provided byte
value was written at offset 0, but the rest of the EEPROM was set to 0.
Fix the issue by setting length to 1 when value is specified and length
is omitted. Exit with error if length is specified to value other than 1
and value is specified.
Fixes: 923c3f51c444 ("ioctl: check presence of eeprom length argument properly")
Signed-off-by: Tomasz Moń <tomasz.mon@camlingroup.com>
---
changes in v2:
- set the length to 1 only if not specified by user
- exit with error if length is not 1
v1: https://lore.kernel.org/netdev/20220819062933.1155112-1-tomasz.mon@camlingroup.com/
---
ethtool.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index 89613ca..7b400da 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -3529,12 +3529,16 @@ static int do_seeprom(struct cmd_context *ctx)
return 74;
}
- if (seeprom_value_seen)
+ if (seeprom_value_seen && !seeprom_length_seen)
seeprom_length = 1;
-
- if (!seeprom_length_seen)
+ else if (!seeprom_length_seen)
seeprom_length = drvinfo.eedump_len;
+ if (seeprom_value_seen && (seeprom_length != 1)) {
+ fprintf(stderr, "value requires length 1\n");
+ return 1;
+ }
+
if (drvinfo.eedump_len < seeprom_offset + seeprom_length) {
fprintf(stderr, "offset & length out of bounds\n");
return 1;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH ethtool v2] ethtool: fix EEPROM byte write
2022-08-19 10:10 [PATCH ethtool v2] ethtool: fix EEPROM byte write Tomasz Moń
@ 2022-08-21 23:20 ` patchwork-bot+netdevbpf
2022-08-21 23:28 ` Michal Kubecek
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-21 23:20 UTC (permalink / raw)
To: =?utf-8?q?Tomasz_Mo=C5=84_=3Ctomasz=2Emon=40camlingroup=2Ecom=3E?=
Cc: mkubecek, netdev, andrew, k.drobinski
Hello:
This patch was applied to ethtool/ethtool.git (master)
by Michal Kubecek <mkubecek@suse.cz>:
On Fri, 19 Aug 2022 12:10:49 +0200 you wrote:
> ethtool since version 1.8 supports EEPROM byte write:
> # ethtool -E DEVNAME [ magic N ] [ offset N ] [ value N ]
>
> ethtool 2.6.33 added EEPROM block write:
> # ethtool -E ethX [ magic N ] [ offset N ] [ length N ] [ value N ]
>
> EEPROM block write introduced in 2.6.33 is backwards compatible, i.e.
> when value is specified the length is forced to 1 (commandline length
> value is ignored).
>
> [...]
Here is the summary with links:
- [ethtool,v2] ethtool: fix EEPROM byte write
https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=95a8d982f159
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH ethtool v2] ethtool: fix EEPROM byte write
2022-08-19 10:10 [PATCH ethtool v2] ethtool: fix EEPROM byte write Tomasz Moń
2022-08-21 23:20 ` patchwork-bot+netdevbpf
@ 2022-08-21 23:28 ` Michal Kubecek
1 sibling, 0 replies; 3+ messages in thread
From: Michal Kubecek @ 2022-08-21 23:28 UTC (permalink / raw)
To: Tomasz Moń; +Cc: netdev, Andrew Lunn, Krzysztof Drobiński
[-- Attachment #1: Type: text/plain, Size: 2513 bytes --]
On Fri, Aug 19, 2022 at 12:10:49PM +0200, Tomasz Moń wrote:
> ethtool since version 1.8 supports EEPROM byte write:
> # ethtool -E DEVNAME [ magic N ] [ offset N ] [ value N ]
>
> ethtool 2.6.33 added EEPROM block write:
> # ethtool -E ethX [ magic N ] [ offset N ] [ length N ] [ value N ]
>
> EEPROM block write introduced in 2.6.33 is backwards compatible, i.e.
> when value is specified the length is forced to 1 (commandline length
> value is ignored).
>
> The byte write behaviour changed in ethtool 5.9 where the value write
> only works when value parameter is specified together with length 1.
> While byte writes to any offset other than 0, without length 1, simply
> fail with "offset & length out of bounds" error message, writing value
> to offset 0 basically erased whole EEPROM. That is, the provided byte
> value was written at offset 0, but the rest of the EEPROM was set to 0.
>
> Fix the issue by setting length to 1 when value is specified and length
> is omitted. Exit with error if length is specified to value other than 1
> and value is specified.
>
> Fixes: 923c3f51c444 ("ioctl: check presence of eeprom length argument properly")
> Signed-off-by: Tomasz Moń <tomasz.mon@camlingroup.com>
> ---
> changes in v2:
> - set the length to 1 only if not specified by user
> - exit with error if length is not 1
>
> v1: https://lore.kernel.org/netdev/20220819062933.1155112-1-tomasz.mon@camlingroup.com/
> ---
> ethtool.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/ethtool.c b/ethtool.c
> index 89613ca..7b400da 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -3529,12 +3529,16 @@ static int do_seeprom(struct cmd_context *ctx)
> return 74;
> }
>
> - if (seeprom_value_seen)
> + if (seeprom_value_seen && !seeprom_length_seen)
> seeprom_length = 1;
> -
> - if (!seeprom_length_seen)
> + else if (!seeprom_length_seen)
> seeprom_length = drvinfo.eedump_len;
It would probably look a bit nicer like this:
if (!seeprom_length_seen)
seeprom_length = seeprom_value_seen ? 1 : drvinfo.eedump_len;
but that's just matter of taste so let's take it as it is.
Michal
>
> + if (seeprom_value_seen && (seeprom_length != 1)) {
> + fprintf(stderr, "value requires length 1\n");
> + return 1;
> + }
> +
> if (drvinfo.eedump_len < seeprom_offset + seeprom_length) {
> fprintf(stderr, "offset & length out of bounds\n");
> return 1;
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-21 23:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-19 10:10 [PATCH ethtool v2] ethtool: fix EEPROM byte write Tomasz Moń
2022-08-21 23:20 ` patchwork-bot+netdevbpf
2022-08-21 23:28 ` Michal Kubecek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox