ethtool: more bug fixes
Subsystems (4)
Jakub Kicinski
maintainercover ethtool: more bug fixes
Last week I sent two patch sets - one fixing bugs in RSS handling, and one fixing CMIS / module handling. This set contains the remaining fixes. There's a concentration of fixes around PHY and timestamp config handling but not enough to break those out as separate sets.
Jakub Kicinski (10):
ethtool: coalesce: cap profile updates at NET_DIM_PARAMS_NUM_PROFILES
ethtool: tsconfig: fix reply error handling
ethtool: linkstate: fix unbalanced ethnl_ops_complete() on PHY lookup
error
ethtool: pse-pd: fix missing ethnl_ops_complete()
ethtool: tsconfig: fix missing ethnl_ops_complete()
ethtool: tsinfo: fix uninitialized stats on the by-PHC path
ethtool: tsinfo: don't pass ERR_PTR to genlmsg_cancel on prepare
failure
ethtool: strset: fix header attribute index in ethnl_req_get_phydev()
ethtool: eeprom: add missing ethnl_ops_begin() / _complete() during
fallback
ethtool: eeprom: add more safeties to EEPROM Netlink fallback
net/ethtool/coalesce.c | 6 ++++++ net/ethtool/eeprom.c | 10 ++++++---- net/ethtool/linkstate.c | 6 ++---- net/ethtool/pse-pd.c | 10 +++++----- net/ethtool/strset.c | 2 +- net/ethtool/tsconfig.c | 15 +++++++++++---- net/ethtool/tsinfo.c | 19 +++++++++++++++---- 7 files changed, 46 insertions(+), 22 deletions(-)
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 1/10 ethtool: coalesce: cap profile updates at NET_DIM_PARAMS_NUM_PROFILES
ethnl_update_profile() walks the ETHTOOL_A_PROFILE_IRQ_MODERATION nest list with an index 'i' and writes new_profile[i++] without bounding i. The destination is kmemdup()'d at NET_DIM_PARAMS_NUM_PROFILES entries (5), but the Netlink nest count is entirely user-controlled. Netlink policies do not have support for constraining the number of nested entries (or number of multi-attr entries).
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ethtool/coalesce.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ethtool/coalesce.c +6 -0
@@ -472,6 +472,12 @@ static int ethnl_update_profile(struct net_device *dev,nla_for_each_nested_type (nest,ETHTOOL_A_PROFILE_IRQ_MODERATION , nests, rem) { +if (i >=NET_DIM_PARAMS_NUM_PROFILES ) { +NL_SET_BAD_ATTR (extack, nest); + ret = -E2BIG ; + goto err_out; + } + ret =nla_parse_nested (tb, len_irq_moder -1 , nest, coalesce_irq_moderation_policy, extack);
Signature · 1 line
2.54.0
Re: [PATCH net 01/10] ethtool: coalesce: cap profile updates at NET_DIM_PARAMS_NUM_PROFILES
Hi,
Quoted 9 lines · Jakub Kicinski
ethnl_update_profile()walks theETHTOOL_A_PROFILE_IRQ_MODERATIONnest list with an index 'i' and writes new_profile[i++] without bounding i. The destination is kmemdup()'d atNET_DIM_PARAMS_NUM_PROFILESentries (5), but the Netlink nest count is entirely user-controlled. Netlink policies do not have support for constraining the number of nested entries (or number of multi-attr entries).Fixes f750dfe825b9 ("ethtool: provide customized dim profile management")Signed-off-by Jakub Kicinski <[email protected]>
Maxime
Quoted 26 lines
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]--- net/ethtool/coalesce.c | 6 ++++++ 1 file changed, 6 insertions(+)net/ethtool/coalesce.c +6
-0@@ -472,6 +472,12 @@ static int ethnl_update_profile(struct net_device *dev,nla_for_each_nested_type (nest,ETHTOOL_A_PROFILE_IRQ_MODERATION , nests, rem) { +if (i >=NET_DIM_PARAMS_NUM_PROFILES ) { +NL_SET_BAD_ATTR (extack, nest); + ret = -E2BIG ; + goto err_out; + } + ret =nla_parse_nested (tb, len_irq_moder -1 , nest, coalesce_irq_moderation_policy, extack);
Jakub Kicinski
maintainerPATCH 2/10 ethtool: tsconfig: fix reply error handling
In reply to Jakub KicinskiA couple of trivial bugs in error handling in tsconfig_send_reply(). If we failed to allocate rskb we need to set the error. If we did allocate it but failed to send it - we need to remember to free it.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ethtool/tsconfig.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/ethtool/tsconfig.c +7 -2
@@ -224,16 +224,21 @@ static int tsconfig_send_reply(struct net_device *dev, struct genl_info *info) reply_len = ret +ethnl_reply_header_size (); rskb =ethnl_reply_init (reply_len, dev,ETHTOOL_MSG_TSCONFIG_SET_REPLY ,ETHTOOL_A_TSCONFIG_HEADER , info, &reply_payload); -if (!rskb) +if (!rskb) { + ret = -ENOMEM ; goto err_cleanup; + } ret =tsconfig_fill_reply (rskb, &req_info->base, &reply_data->base);if (ret <0 ) - goto err_cleanup; + goto err_free_msg;genlmsg_end (rskb, reply_payload); ret =genlmsg_reply (rskb, info); + rskb =NULL ; +err_free_msg: +nlmsg_free (rskb); err_cleanup:kfree (reply_data);kfree (req_info);
Signature · 1 line
2.54.0
Re: [PATCH net 02/10] ethtool: tsconfig: fix reply error handling
Quoted 33 lines · Jakub Kicinski
A couple of trivial bugs in error handling in
tsconfig_send_reply(). If we failed to allocate rskb we need to set the error. If we did allocate it but failed to send it - we need to remember to free it.Fixes 6e9e2eed4f39 ("net: ethtool: Add support for tsconfig command to get/set hwtstamp config")Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- net/ethtool/tsconfig.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)net/ethtool/tsconfig.c +4
-2@@ -224,16 +224,21 @@ static int tsconfig_send_reply(struct net_device *dev, struct genl_info *info) reply_len = ret +ethnl_reply_header_size (); rskb =ethnl_reply_init (reply_len, dev,ETHTOOL_MSG_TSCONFIG_SET_REPLY ,ETHTOOL_A_TSCONFIG_HEADER , info, &reply_payload); -if (!rskb) +if (!rskb) { + ret = -ENOMEM ; goto err_cleanup; + } ret =tsconfig_fill_reply (rskb, &req_info->base, &reply_data->base);if (ret <0 ) - goto err_cleanup; + goto err_free_msg;
net/ethtool/tsconfig.c static int tsconfig_send_reply(struct net_device *dev, struct genl_info *info) · line 244
Quoted 10 lines
net/ethtool/tsconfig.c +3
-0genlmsg_end (rskb, reply_payload); ret =genlmsg_reply (rskb, info); + rskb =NULL ; +err_free_msg: +nlmsg_free (rskb); err_cleanup:kfree (reply_data);kfree (req_info);
Re: [PATCH net 02/10] ethtool: tsconfig: fix reply error handling
In reply to Jakub KicinskiQuoted 7 lines · On Tue, 26 May 2026 08:35:25 -0700 Jakub Kicinski <[email protected]> wrote:
A couple of trivial bugs in error handling in
tsconfig_send_reply(). If we failed to allocate rskb we need to set the error. If we did allocate it but failed to send it - we need to remember to free it.Fixes 6e9e2eed4f39 ("net: ethtool: Add support for tsconfig command toget/set hwtstamp config") Signed-off-by: Jakub Kicinski <[email protected]>
Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Jakub Kicinski
maintainerPATCH 3/10 ethtool: linkstate: fix unbalanced ethnl_ops_complete() on PHY lookup error
In reply to Jakub Kicinskilinkstate_prepare_data() calls ethnl_req_get_phydev() before ethnl_ops_begin(), but routes its error path through "goto out" which calls ethnl_ops_complete().
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ethtool/linkstate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/ethtool/linkstate.c +2 -4
@@ -106,10 +106,8 @@ static int linkstate_prepare_data(const struct ethnl_req_info *req_base, phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_LINKSTATE_HEADER , info->extack); -if (IS_ERR (phydev)) { - ret =PTR_ERR (phydev); - goto out; - } +if (IS_ERR (phydev)) +return PTR_ERR (phydev); ret =ethnl_ops_begin (dev);if (ret <0 )
Signature · 1 line
2.54.0
Re: [PATCH net 03/10] ethtool: linkstate: fix unbalanced ethnl_ops_complete() on PHY lookup error
Hi Jakub,
Quoted 6 lines · Jakub Kicinski
linkstate_prepare_data()callsethnl_req_get_phydev()beforeethnl_ops_begin(), but routes its error path through "goto out" which callsethnl_ops_complete().Fixes fe55b1d401c6 ("ethtool: linkstate: migrate linkstate functions to support multi-PHY setups")Signed-off-by Jakub Kicinski <[email protected]>
Thanks for fixing this,
Maxime
Quoted 25 lines
---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- net/ethtool/linkstate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)net/ethtool/linkstate.c +2
-4@@ -106,10 +106,8 @@ static int linkstate_prepare_data(const struct ethnl_req_info *req_base, phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_LINKSTATE_HEADER , info->extack); -if (IS_ERR (phydev)) { - ret =PTR_ERR (phydev); - goto out; - } +if (IS_ERR (phydev)) +return PTR_ERR (phydev); ret =ethnl_ops_begin (dev);if (ret <0 )
Jakub Kicinski
maintainerPATCH 4/10 ethtool: pse-pd: fix missing ethnl_ops_complete()
In reply to Jakub Kicinskipse_prepare_data() is missing ethnl_ops_complete() if ethnl_req_get_phydev() returned an error. Move getting phydev up so that we don't have to worry about this (similar order to linkstate_prepare_data()).
Note that phydev may still be NULL (this is checked in pse_get_pse_attributes()), the goal isn't really to avoid the _begin() / _complete() calls, only to simplify the error handling.
While at it propagate the original error. Why this code overrides the error with -ENODEV but !phydev generates -EOPNOTSUPP is unclear to me...
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ethtool/pse-pd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/ethtool/pse-pd.c +5 -5
@@ -62,14 +62,14 @@ static int pse_prepare_data(const struct ethnl_req_info *req_base,struct phy_device *phydev;int ret; - ret =ethnl_ops_begin (dev); -if (ret <0 ) -return ret; - phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_PSE_HEADER , info->extack);if (IS_ERR (phydev)) -return -ENODEV ; +return PTR_ERR (phydev); + + ret =ethnl_ops_begin (dev); +if (ret <0 ) +return ret; ret =pse_get_pse_attributes (phydev, info->extack, data);
Signature · 1 line
2.54.0
Re: [PATCH net 04/10] ethtool: pse-pd: fix missing ethnl_ops_complete()
Hi,
Quoted 5 lines · Jakub Kicinski
pse_prepare_data()is missingethnl_ops_complete()ifethnl_req_get_phydev()returned an error. Move getting phydev up so that we don't have to worry about this (similar order tolinkstate_prepare_data()).
Quoted 8 lines
Note that phydev may still be NULL (this is checked in
pse_get_pse_attributes()), the goal isn't really to avoid the_begin()/_complete()calls, only to simplify the error handling.While at it propagate the original error. Why this code overrides the error with
-ENODEVbut !phydev generates-EOPNOTSUPPis unclear to me...
The logic is that ethnl_req_get_phydev() may return -ENODEV, meaning "you passed a phy index for a PHY that doesn't exist", which is different than "there's no PHY, setting PSE-PD params isn't supported then."
But there's no real sense overriding the phydev ERR_PTR with the same value :) Your fix should be fine :) Thanks for this !
Quoted 3 lines
Fixes 31748765bed3 ("net: ethtool: pse-pd: Target the command to the requested PHY")Signed-off-by Jakub Kicinski <[email protected]>
Maxime
Quoted 34 lines
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]--- net/ethtool/pse-pd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)net/ethtool/pse-pd.c +5
-5@@ -62,14 +62,14 @@ static int pse_prepare_data(const struct ethnl_req_info *req_base,struct phy_device *phydev;int ret; - ret =ethnl_ops_begin (dev); -if (ret <0 ) -return ret; - phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_PSE_HEADER , info->extack);if (IS_ERR (phydev)) -return -ENODEV ; +return PTR_ERR (phydev); + + ret =ethnl_ops_begin (dev); +if (ret <0 ) +return ret; ret =pse_get_pse_attributes (phydev, info->extack, data);
Jakub Kicinski
maintainerPATCH 5/10 ethtool: tsconfig: fix missing ethnl_ops_complete()
In reply to Jakub Kicinskitsconfig_prepare_data() calls ethnl_ops_begin(), we need to call ethnl_ops_complete() before returning the error.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ethtool/tsconfig.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ethtool/tsconfig.c +4 -2
@@ -69,8 +69,10 @@ static int tsconfig_prepare_data(const struct ethnl_req_info *req_base,if (ret) goto out; -if (ts_info.phc_index ==-1 ) -return -ENODEV ; +if (ts_info.phc_index ==-1 ) { + ret = -ENODEV ; + goto out; + } data->hwprov_desc.index = ts_info.phc_index; data->hwprov_desc.qualifier = ts_info.phc_qualifier;
Signature · 1 line
2.54.0
Re: [PATCH net 05/10] ethtool: tsconfig: fix missing ethnl_ops_complete()
Quoted 20 lines · Jakub Kicinski
tsconfig_prepare_data()callsethnl_ops_begin(), we need to callethnl_ops_complete()before returning the error.Fixes 6e9e2eed4f39 ("net: ethtool: Add support for tsconfig command to get/set hwtstamp config")Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- net/ethtool/tsconfig.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)net/ethtool/tsconfig.c +0
-0@@ -69,8 +69,10 @@ static int tsconfig_prepare_data(const struct ethnl_req_info *req_base,if (ret) goto out;
net/ethtool/tsconfig.c static int tsconfig_prepare_data(const struct ethnl_req_info *req_base, · line 78
Quoted 10 lines
net/ethtool/tsconfig.c +4
-2-if (ts_info.phc_index ==-1 ) -return -ENODEV ; +if (ts_info.phc_index ==-1 ) { + ret = -ENODEV ; + goto out; + } data->hwprov_desc.index = ts_info.phc_index; data->hwprov_desc.qualifier = ts_info.phc_qualifier;
Re: [PATCH net 05/10] ethtool: tsconfig: fix missing ethnl_ops_complete()
In reply to Jakub KicinskiQuoted 5 lines · On Tue, 26 May 2026 08:35:28 -0700 Jakub Kicinski <[email protected]> wrote:
tsconfig_prepare_data()callsethnl_ops_begin(), we need to callethnl_ops_complete()before returning the error.Fixes 6e9e2eed4f39 ("net: ethtool: Add support for tsconfig command toget/set hwtstamp config") Signed-off-by: Jakub Kicinski <[email protected]>
Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Jakub Kicinski
maintainerPATCH 6/10 ethtool: tsinfo: fix uninitialized stats on the by-PHC path
In reply to Jakub Kicinskitsinfo_prepare_data() has two code paths: a "by-PHC" path for user-specified hardware timestamping providers, and the old path. Commit 89e281ebff72 ("ethtool: init tsinfo stats if requested") added ethtool_stats_init() to mark stat slots as ETHTOOL_STAT_NOT_SET before the driver callback populates them, but placed the call inside the old-path block.
When commit b9e3f7dc9ed9 ("net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology") added the by-PHC early return, it landed above the stats initialization. On that path the stats array retains the zero-fill from ethnl_init_reply_data()'s zalloc. This leads to the reply including a stats nest with four zero-valued attributes that should have been absent.
Reject GET requests for stats with HWTSTAMP_PROVIDER or dump.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ethtool/tsinfo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
net/ethtool/tsinfo.c +13 -0
@@ -83,6 +83,11 @@ tsinfo_parse_request(struct ethnl_req_info *req_base,if (!tb[ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER ])return 0 ; +if (req_base->flags ÐTOOL_FLAG_STATS ) { +NL_SET_ERR_MSG (extack,"can't query statistics for a provider" ); +return -EOPNOTSUPP ; + } +return ts_parse_hwtst_provider (tb[ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER ], &req->hwprov_desc, extack, &mod); }
@@ -523,6 +528,12 @@ int ethnl_tsinfo_start(struct netlink_callback *cb)if (ret <0 ) goto free_reply_data; +if (req_info->base.flags ÐTOOL_FLAG_STATS ) { +NL_SET_ERR_MSG (cb->extack,"stats not supported in dump" ); + ret = -EOPNOTSUPP ; + goto err_dev_put; + } + ctx->req_info = req_info; ctx->reply_data = reply_data; ctx->pos_ifindex =0 ;
@@ -532,6 +543,8 @@ int ethnl_tsinfo_start(struct netlink_callback *cb)return 0 ; +err_dev_put: +ethnl_parse_header_dev_put (&req_info->base); free_reply_data:kfree (reply_data); free_req_info:
Signature · 1 line
2.54.0
Re: [PATCH net 06/10] ethtool: tsinfo: fix uninitialized stats on the by-PHC path
Quoted 14 lines · Jakub Kicinski
tsinfo_prepare_data()has two code paths: a "by-PHC" path for user-specified hardware timestamping providers, and the old path. Commit89e281ebff72("ethtool: init tsinfo stats if requested") addedethtool_stats_init()to mark stat slots asETHTOOL_STAT_NOT_SETbefore the driver callback populates them, but placed the call inside the old-path block.When commit
b9e3f7dc9ed9("net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology") added the by-PHC early return, it landed above the stats initialization. On that path the stats array retains the zero-fill from ethnl_init_reply_data()'s zalloc. This leads to the reply including a stats nest with four zero-valued attributes that should have been absent.
Quoted 4 lines
Reject GET requests for stats with
HWTSTAMP_PROVIDERor dump.Fixes b9e3f7dc9ed9 ("net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology")Signed-off-by Jakub Kicinski <[email protected]>
We may have per-provider stats one day, but for now I agree with this patch.
Maxime
Quoted 47 lines
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]--- net/ethtool/tsinfo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)net/ethtool/tsinfo.c +13
-0@@ -83,6 +83,11 @@ tsinfo_parse_request(struct ethnl_req_info *req_base,if (!tb[ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER ])return 0 ; +if (req_base->flags ÐTOOL_FLAG_STATS ) { +NL_SET_ERR_MSG (extack,"can't query statistics for a provider" ); +return -EOPNOTSUPP ; + } +return ts_parse_hwtst_provider (tb[ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER ], &req->hwprov_desc, extack, &mod); }@@ -523,6 +528,12 @@ int ethnl_tsinfo_start(struct netlink_callback *cb)if (ret <0 ) goto free_reply_data; +if (req_info->base.flags ÐTOOL_FLAG_STATS ) { +NL_SET_ERR_MSG (cb->extack,"stats not supported in dump" ); + ret = -EOPNOTSUPP ; + goto err_dev_put; + } + ctx->req_info = req_info; ctx->reply_data = reply_data; ctx->pos_ifindex =0 ;@@ -532,6 +543,8 @@ int ethnl_tsinfo_start(struct netlink_callback *cb)return 0 ; +err_dev_put: +ethnl_parse_header_dev_put (&req_info->base); free_reply_data:kfree (reply_data); free_req_info:
Jakub Kicinski
maintainerRe: [PATCH net 06/10] ethtool: tsinfo: fix uninitialized stats on the by-PHC path
Quoted 2 lines · On Tue, 26 May 2026 19:23:22 +0200 Maxime Chevallier wrote:
We may have per-provider stats one day, but for now I agree with this patch.
The fact we don't have stats in dumps (even without providers) is even sadder :( But the fix would be too large & risky for net. AFAICT this "never worked".
Jakub Kicinski
maintainerPATCH 7/10 ethtool: tsinfo: don't pass ERR_PTR to genlmsg_cancel on prepare failure
In reply to Jakub KicinskiThe goto err label leads to:
genlmsg_cancel(skb, ehdr); return ret;
If ethnl_tsinfo_prepare_dump() failed, it has not started a genlmsg. There's nothing to cancel, and passing an error pointer to genlmsg_cancel() would cause a crash.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ethtool/tsinfo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/ethtool/tsinfo.c +2 -4
@@ -407,10 +407,8 @@ static int ethnl_tsinfo_dump_one_netdev(struct sk_buff *skb,continue ; ehdr =ethnl_tsinfo_prepare_dump (skb, dev, reply_data, cb); -if (IS_ERR (ehdr)) { - ret =PTR_ERR (ehdr); - goto err; - } +if (IS_ERR (ehdr)) +return PTR_ERR (ehdr); reply_data->ts_info.phc_qualifier = ctx->pos_phcqualifier; ret = ops->get_ts_info (dev, &reply_data->ts_info);
Signature · 1 line
2.54.0
Re: [PATCH net 07/10] ethtool: tsinfo: don't pass ERR_PTR to genlmsg_cancel on prepare failure
Hi,
Quoted 11 lines · Jakub Kicinski
The goto err label leads to:
genlmsg_cancel(skb, ehdr); return ret;If
ethnl_tsinfo_prepare_dump()failed, it has not started a genlmsg. There's nothing to cancel, and passing an error pointer togenlmsg_cancel()would cause a crash.Fixes b9e3f7dc9ed9 ("net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology")Signed-off-by Jakub Kicinski <[email protected]>
Maxime
Quoted 25 lines
---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- net/ethtool/tsinfo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)net/ethtool/tsinfo.c +2
-4@@ -407,10 +407,8 @@ static int ethnl_tsinfo_dump_one_netdev(struct sk_buff *skb,continue ; ehdr =ethnl_tsinfo_prepare_dump (skb, dev, reply_data, cb); -if (IS_ERR (ehdr)) { - ret =PTR_ERR (ehdr); - goto err; - } +if (IS_ERR (ehdr)) +return PTR_ERR (ehdr); reply_data->ts_info.phc_qualifier = ctx->pos_phcqualifier; ret = ops->get_ts_info (dev, &reply_data->ts_info);
Re: [PATCH net 07/10] ethtool: tsinfo: don't pass ERR_PTR to genlmsg_cancel on prepare failure
In reply to Jakub KicinskiQuoted 11 lines · On Tue, 26 May 2026 08:35:30 -0700 Jakub Kicinski <[email protected]> wrote:
The goto err label leads to:
genlmsg_cancel(skb, ehdr); return ret;If
ethnl_tsinfo_prepare_dump()failed, it has not started a genlmsg. There's nothing to cancel, and passing an error pointer togenlmsg_cancel()would cause a crash.Fixes b9e3f7dc9ed9 ("net: ethtool: tsinfo: Enhance tsinfo to support severalhwtstamp by net topology") Signed-off-by: Jakub Kicinski <[email protected]>
Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Jakub Kicinski
maintainerPATCH 8/10 ethtool: strset: fix header attribute index in ethnl_req_get_phydev()
In reply to Jakub Kicinskistrset_prepare_data() passes ETHTOOL_A_HEADER_FLAGS (3) as the header attribute to ethnl_req_get_phydev(). This is incorrect, in the main attr space 3 is ETHTOOL_A_STRSET_COUNTS_ONLY, not the request header attr. The correct constant is ETHTOOL_A_STRSET_HEADER (1).
ethnl_req_get_phydev() only uses this value for the extack, so this is not a "functionally visible"(?) bug.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ethtool/strset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ethtool/strset.c +1 -1
@@ -311,7 +311,7 @@ static int strset_prepare_data(const struct ethnl_req_info *req_base,return 0 ; } - phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_HEADER_FLAGS , + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_STRSET_HEADER , info->extack);/* phydev can be NULL, check for errors only */
Signature · 1 line
2.54.0
Re: [PATCH net 08/10] ethtool: strset: fix header attribute index in ethnl_req_get_phydev()
Hi,
Quoted 10 lines · Jakub Kicinski
strset_prepare_data()passesETHTOOL_A_HEADER_FLAGS(3) as the header attribute toethnl_req_get_phydev(). This is incorrect, in the main attr space 3 isETHTOOL_A_STRSET_COUNTS_ONLY, not the request header attr. The correct constant isETHTOOL_A_STRSET_HEADER(1).
ethnl_req_get_phydev()only uses this value for the extack, so this is not a "functionally visible"(?) bug.Fixes e96c93aa4be9 ("net: ethtool: strset: Allow querying phy stats by index")Signed-off-by Jakub Kicinski <[email protected]>
Indeed, my bad :(
Thanks !
Maxime
Quoted 22 lines
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]--- net/ethtool/strset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ethtool/strset.c +1
-1@@ -311,7 +311,7 @@ static int strset_prepare_data(const struct ethnl_req_info *req_base,return 0 ; } - phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_HEADER_FLAGS , + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_STRSET_HEADER , info->extack);/* phydev can be NULL, check for errors only */
Jakub Kicinski
maintainerPATCH 9/10 ethtool: eeprom: add missing ethnl_ops_begin() / _complete() during fallback
In reply to Jakub KicinskiAll ethtool driver op calls should be sandwiched between ethnl_ops_begin() / ethnl_ops_complete(). In Netlink eeprom code, if the paged access failed we fall back to old API, but we first call _complete() and the fallback never does its own ethnl_ops_begin(). Move the fallback into the _begin() / _complete() section.
---
CC: [email protected]
CC: [email protected]
--- net/ethtool/eeprom.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/ethtool/eeprom.c +2 -3
@@ -141,12 +141,11 @@ static int eeprom_prepare_data(const struct ethnl_req_info *req_base,return 0 ; err_ops: +if (ret == -EOPNOTSUPP ) + ret =eeprom_fallback (request, reply);ethnl_ops_complete (dev); err_free:kfree (page_data.data); - -if (ret == -EOPNOTSUPP ) -return eeprom_fallback (request, reply);return ret; }
Signature · 1 line
2.54.0
Re: [PATCH net 09/10] ethtool: eeprom: add missing ethnl_ops_begin() / _complete() during fallback
Hi,
Quoted 9 lines · Jakub Kicinski
All ethtool driver op calls should be sandwiched between
ethnl_ops_begin()/ethnl_ops_complete(). In Netlink eeprom code, if the paged access failed we fall back to old API, but we first call_complete()and the fallback never does its ownethnl_ops_begin(). Move the fallback into the_begin()/_complete()section.Fixes 96d971e307cc ("ethtool: Add fallback to get_module_eeprom from netlink command")Signed-off-by Jakub Kicinski <[email protected]>
Thanks :)
Maxime
Quoted 26 lines
---
CC: [email protected]
CC: [email protected]--- net/ethtool/eeprom.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)net/ethtool/eeprom.c +2
-3@@ -141,12 +141,11 @@ static int eeprom_prepare_data(const struct ethnl_req_info *req_base,return 0 ; err_ops: +if (ret == -EOPNOTSUPP ) + ret =eeprom_fallback (request, reply);ethnl_ops_complete (dev); err_free:kfree (page_data.data); - -if (ret == -EOPNOTSUPP ) -return eeprom_fallback (request, reply);return ret; }
Jakub Kicinski
maintainerPATCH 10/10 ethtool: eeprom: add more safeties to EEPROM Netlink fallback
In reply to Jakub KicinskiThe Netlink fallback path for reading module EEPROM (fallback_set_params()) validates that offset < eeprom_len, but does not check that offset + length stays within eeprom_len. The ioctl equivalent (ethtool_get_any_eeprom() in ioctl.c) has always enforced both bounds:
if (eeprom.offset + eeprom.len > total_len)
return -EINVAL;
This could lead to surprises in both drivers and device FW. Add the missing offset + length validation to fallback_set_params(), mirroring the ioctl.
Similarly - ethtool core in general, and ethtool_get_any_eeprom() in particular tries to zero-init all buffers passed to the drivers to avoid any extra work of zeroing things out. eeprom_fallback() uses a plain kmalloc(), change it to zalloc.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ethtool/eeprom.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ethtool/eeprom.c +4 -1
@@ -44,6 +44,9 @@ static int fallback_set_params(struct eeprom_req_info *request,if (offset >= modinfo->eeprom_len)return -EINVAL ; +if (length > modinfo->eeprom_len - offset) +return -EINVAL ; + eeprom->cmd =ETHTOOL_GMODULEEEPROM ; eeprom->len = length; eeprom->offset = offset;
@@ -69,7 +72,7 @@ static int eeprom_fallback(struct eeprom_req_info *request,if (err <0 )return err; - data =kmalloc (eeprom.len,GFP_KERNEL ); + data =kzalloc (eeprom.len,GFP_KERNEL );if (!data)return -ENOMEM ; err =ethtool_get_module_eeprom_call (dev, &eeprom, data);
Signature · 1 line
2.54.0
Re: [PATCH net 10/10] ethtool: eeprom: add more safeties to EEPROM Netlink fallback
Hi,
Quoted 13 lines · Jakub Kicinski
The Netlink fallback path for reading module EEPROM (
fallback_set_params()) validates that offset <eeprom_len, but does not check that offset + length stays withineeprom_len. The ioctl equivalent (ethtool_get_any_eeprom()inioctl.c) has always enforced both bounds:if (eeprom.offset + eeprom.len >
total_len)return -EINVAL;This could lead to surprises in both drivers and device FW. Add the missing offset + length validation to
fallback_set_params(), mirroring the ioctl.
Quoted 7 lines
Similarly - ethtool core in general, and
ethtool_get_any_eeprom()in particular tries to zero-init all buffers passed to the drivers to avoid any extra work of zeroing things out.eeprom_fallback()uses a plainkmalloc(), change it to zalloc.Fixes 96d971e307cc ("ethtool: Add fallback to get_module_eeprom from netlink command")Signed-off-by Jakub Kicinski <[email protected]>
Maxime
Quoted 31 lines
---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- net/ethtool/eeprom.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)net/ethtool/eeprom.c +4
-1@@ -44,6 +44,9 @@ static int fallback_set_params(struct eeprom_req_info *request,if (offset >= modinfo->eeprom_len)return -EINVAL ; +if (length > modinfo->eeprom_len - offset) +return -EINVAL ; + eeprom->cmd =ETHTOOL_GMODULEEEPROM ; eeprom->len = length; eeprom->offset = offset;@@ -69,7 +72,7 @@ static int eeprom_fallback(struct eeprom_req_info *request,if (err <0 )return err; - data =kmalloc (eeprom.len,GFP_KERNEL ); + data =kzalloc (eeprom.len,GFP_KERNEL );if (!data)return -ENOMEM ; err =ethtool_get_module_eeprom_call (dev, &eeprom, data);
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 20 lines · On Tue, 26 May 2026 08:35:23 -0700 you wrote:
Last week I sent two patch sets - one fixing bugs in RSS handling, and one fixing CMIS / module handling. This set contains the remaining fixes. There's a concentration of fixes around PHY and timestamp config handling but not enough to break those out as separate sets.
Jakub Kicinski (10):
ethtool: coalesce: cap profile updates atNET_DIM_PARAMS_NUM_PROFILES
ethtool: tsconfig: fix reply error handling
ethtool: linkstate: fix unbalancedethnl_ops_complete()on PHY lookup
error
ethtool: pse-pd: fix missingethnl_ops_complete()
ethtool: tsconfig: fix missingethnl_ops_complete()
ethtool: tsinfo: fix uninitialized stats on the by-PHC path
ethtool: tsinfo: don't passERR_PTRtogenlmsg_cancelon prepare
failure
ethtool: strset: fix header attribute index inethnl_req_get_phydev()
ethtool: eeprom: add missingethnl_ops_begin()/_complete()during
fallback
ethtool: eeprom: add more safeties to EEPROM Netlink fallback
Quoted 1 line
[...]
Here is the summary with links:
- [net,01/10] ethtool: coalesce: cap profile updates at NET_DIM_PARAMS_NUM_PROFILES
https://git.kernel.org/netdev/net/c/7281b096b072 - [net,02/10] ethtool: tsconfig: fix reply error handling https://git.kernel.org/netdev/net/c/a888bbd43940 - [net,03/10] ethtool: linkstate: fix unbalanced ethnl_ops_complete() on PHY lookup error https://git.kernel.org/netdev/net/c/596c51ed9e12 - [net,04/10] ethtool: pse-pd: fix missing ethnl_ops_complete() https://git.kernel.org/netdev/net/c/ab5bf428fb6b - [net,05/10] ethtool: tsconfig: fix missing ethnl_ops_complete() https://git.kernel.org/netdev/net/c/6386bd772de6 - [net,06/10] ethtool: tsinfo: fix uninitialized stats on the by-PHC path https://git.kernel.org/netdev/net/c/1de405699c62 - [net,07/10] ethtool: tsinfo: don't pass ERR_PTR to genlmsg_cancel on prepare failure https://git.kernel.org/netdev/net/c/c3fc9976f686 - [net,08/10] ethtool: strset: fix header attribute index in ethnl_req_get_phydev() https://git.kernel.org/netdev/net/c/a8d8bef6b45b - [net,09/10] ethtool: eeprom: add missing ethnl_ops_begin() / _complete() during fallback https://git.kernel.org/netdev/net/c/2376586f85f9 - [net,10/10] ethtool: eeprom: add more safeties to EEPROM Netlink fallback https://git.kernel.org/netdev/net/c/67cfdd9210b9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html