* [PATCH v0] net: ethtool: Only set supplied eee ethtool settings
@ 2025-04-16 22:12 Rutger van Kruiningen
2025-04-16 22:36 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Rutger van Kruiningen @ 2025-04-16 22:12 UTC (permalink / raw)
To: Andrew Lunn
Cc: netdev, linux-kernel, Rutger van Kruiningen, Jakub Kicinski,
David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman
Originally all ethtool eee setting updates were attempted even if the
settings were not supplied, causing a null pointer crash.
Add check for each eee setting and only update if it exists.
Signed-off-by: Rutger van Kruiningen <rutger.vankruiningen@alliedtelesis.co.nz>
---
net/ethtool/eee.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/net/ethtool/eee.c b/net/ethtool/eee.c
index bf398973eb8a..1b4831ff9a75 100644
--- a/net/ethtool/eee.c
+++ b/net/ethtool/eee.c
@@ -137,17 +137,26 @@ ethnl_set_eee(struct ethnl_req_info *req_info, struct genl_info *info)
if (ret < 0)
return ret;
- ret = ethnl_update_bitset(eee.advertised,
- __ETHTOOL_LINK_MODE_MASK_NBITS,
- tb[ETHTOOL_A_EEE_MODES_OURS],
- link_mode_names, info->extack, &mod);
- if (ret < 0)
- return ret;
- ethnl_update_bool(&eee.eee_enabled, tb[ETHTOOL_A_EEE_ENABLED], &mod);
- ethnl_update_bool(&eee.tx_lpi_enabled, tb[ETHTOOL_A_EEE_TX_LPI_ENABLED],
- &mod);
- ethnl_update_u32(&eee.tx_lpi_timer, tb[ETHTOOL_A_EEE_TX_LPI_TIMER],
- &mod);
+ if (tb[ETHTOOL_A_EEE_MODES_OURS]) {
+ ret = ethnl_update_bitset(eee.advertised,
+ __ETHTOOL_LINK_MODE_MASK_NBITS,
+ tb[ETHTOOL_A_EEE_MODES_OURS],
+ link_mode_names, info->extack, &mod);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (tb[ETHTOOL_A_EEE_ENABLED])
+ ethnl_update_bool(&eee.eee_enabled, tb[ETHTOOL_A_EEE_ENABLED], &mod);
+
+ if (tb[ETHTOOL_A_EEE_TX_LPI_ENABLED])
+ ethnl_update_bool(&eee.tx_lpi_enabled, tb[ETHTOOL_A_EEE_TX_LPI_ENABLED],
+ &mod);
+
+ if (tb[ETHTOOL_A_EEE_TX_LPI_TIMER])
+ ethnl_update_u32(&eee.tx_lpi_timer, tb[ETHTOOL_A_EEE_TX_LPI_TIMER],
+ &mod);
+
if (!mod)
return 0;
--
2.49.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v0] net: ethtool: Only set supplied eee ethtool settings
2025-04-16 22:12 [PATCH v0] net: ethtool: Only set supplied eee ethtool settings Rutger van Kruiningen
@ 2025-04-16 22:36 ` Andrew Lunn
2025-04-17 0:36 ` Rutger van Kruiningen
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2025-04-16 22:36 UTC (permalink / raw)
To: Rutger van Kruiningen
Cc: netdev, linux-kernel, Jakub Kicinski, David S. Miller,
Eric Dumazet, Paolo Abeni, Simon Horman
On Thu, Apr 17, 2025 at 10:12:30AM +1200, Rutger van Kruiningen wrote:
> Originally all ethtool eee setting updates were attempted even if the
> settings were not supplied, causing a null pointer crash.
>
> Add check for each eee setting and only update if it exists.
I see what you mean, but i'm somewhat surprised we have not seen this
crash. Do you have a simple reproducer? I just did
ethtool --debug 255 --set-eee eth0 eee on
and it did not crash, despite:
sending genetlink packet (44 bytes):
msg length 44 ethool ETHTOOL_MSG_EEE_SET
ETHTOOL_MSG_EEE_SET
ETHTOOL_A_EEE_HEADER
ETHTOOL_A_HEADER_DEV_NAME = "eth0"
ETHTOOL_A_EEE_ENABLED = on
So it only provided ETHTOOL_A_EEE_ENABLED and none of the others.
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v0] net: ethtool: Only set supplied eee ethtool settings
2025-04-16 22:36 ` Andrew Lunn
@ 2025-04-17 0:36 ` Rutger van Kruiningen
0 siblings, 0 replies; 3+ messages in thread
From: Rutger van Kruiningen @ 2025-04-17 0:36 UTC (permalink / raw)
To: andrew; +Cc: horms, davem, edumazet, netdev, linux-kernel, pabeni, kuba
On Thu, 2025-04-17 at 00:36 +0200, Andrew Lunn wrote:
> On Thu, Apr 17, 2025 at 10:12:30AM +1200, Rutger van Kruiningen
> wrote:
> > Originally all ethtool eee setting updates were attempted even if
> > the
> > settings were not supplied, causing a null pointer crash.
> >
> > Add check for each eee setting and only update if it exists.
>
> I see what you mean, but i'm somewhat surprised we have not seen this
> crash. Do you have a simple reproducer? I just did
>
> ethtool --debug 255 --set-eee eth0 eee on
>
> and it did not crash, despite:
>
> sending genetlink packet (44 bytes):
> msg length 44 ethool ETHTOOL_MSG_EEE_SET
> ETHTOOL_MSG_EEE_SET
> ETHTOOL_A_EEE_HEADER
> ETHTOOL_A_HEADER_DEV_NAME = "eth0"
> ETHTOOL_A_EEE_ENABLED = on
>
> So it only provided ETHTOOL_A_EEE_ENABLED and none of the others.
>
> Andrew
Sorry it seems that there actually isn't a problem here. I thought the
bug I had was related to this but it must have been for something else
and was fixed at the same time of adding this code.
You can disreguard this patch.
Thanks, Rutger.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-17 0:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-16 22:12 [PATCH v0] net: ethtool: Only set supplied eee ethtool settings Rutger van Kruiningen
2025-04-16 22:36 ` Andrew Lunn
2025-04-17 0:36 ` Rutger van Kruiningen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®