Skip to contentSkip to conversation

ethtool: strset: Fix reply_size value

PATCH In review Amit Cohen 4 participants 5 messages Jun 17, 2021

Subsystems (3)
lore
Share & tools
lore

Amit Cohen

author
#0 lore raw

PATCH 1/1 ethtool: strset: Fix reply_size value

strset_reply_size() does not take into account the size required for the 'ETHTOOL_A_STRSET_STRINGSETS' nested attribute.
Since commit 4d1fb7cde0cc ("ethtool: add a stricter length check") this results in the following warning in the kernel log:

ethnl cmd 1: calculated reply length 2236, but consumed 2240

WARNING: CPU: 2 PID: 30549 at net/ethtool/netlink.c:360 ethnl_default_doit+0x29f/0x310

Add the appropriate size to the calculation.

Fixes 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
---
 net/ethtool/strset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ethtool/strset.c +1 -1
index b3029fff715d..86dcb6b099b3 100644
@@ -365,7 +365,7 @@ static int strset_reply_size(const struct ethnl_req_info *req_base,
 		len += ret;
 	}
 
-	return len;
+	return nla_total_size(len);
 }
 
 /* fill one string into reply */
Signature · 1 line
2.31.1
#1 lore raw
Quoted 8 lines · Amit Cohen

strset_reply_size() does not take into account the size required for the 'ETHTOOL_A_STRSET_STRINGSETS' nested attribute.
Since commit 4d1fb7cde0cc ("ethtool: add a stricter length check") this results in the following warning in the kernel log:

ethnl cmd 1: calculated reply length 2236, but consumed 2240

WARNING: CPU: 2 PID: 30549 at net/ethtool/netlink.c:360 ethnl_default_doit+0x29f/0x310
Quoted 7 lines

Add the appropriate size to the calculation.

Fixes 71921690f974 ("ethtool: provide string sets with STRSET_GET request")

Ha, seems this is addressed by commit e175aef90269 ("ethtool: strset:
fix message length calculation") in net.git which actually motivated commit 4d1fb7cde0cc ("ethtool: add a stricter length check").

The former is still not in net-next.git, which is why the warning is triggered there.

The patch can be dropped.

#2 lore raw
In reply to Amit Cohen
Quoted 24 lines · Amit Cohen

strset_reply_size() does not take into account the size required for the 'ETHTOOL_A_STRSET_STRINGSETS' nested attribute.
Since commit 4d1fb7cde0cc ("ethtool: add a stricter length check") this results in the following warning in the kernel log:

ethnl cmd 1: calculated reply length 2236, but consumed 2240

WARNING: CPU: 2 PID: 30549 at net/ethtool/netlink.c:360 ethnl_default_doit+0x29f/0x310

Add the appropriate size to the calculation.

Fixes 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
---
 net/ethtool/strset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ethtool/strset.c +0 -0
index b3029fff715d..86dcb6b099b3 100644

net/ethtool/strset.c static int strset_reply_size(const struct ethnl_req_info *req_base, · line 371

Quoted 8 lines
net/ethtool/strset.c +1 -1
@@ -365,7 +365,7 @@ static int strset_reply_size(const struct ethnl_req_info *req_base,
 		len += ret;
 	}
 
-	return len;
+	return nla_total_size(len);
 }
 
 /* fill one string into reply */

I believe this issue has been already fixed in net tree by commit e175aef90269 ("ethtool: strset: fix message length calculation") but as this commit has not been merged into net-next yet, you could hit it with the stricter check.

Michal

#3 lore raw
Quoted 4 lines · Michal Kubecek

I believe this issue has been already fixed in net tree by commit e175aef90269 ("ethtool: strset: fix message length calculation") but as this commit has not been merged into net-next yet, you could hit it with the stricter check.

Yea. I reached the same conclusion :/

maintainer
#4 lore raw
Quoted 7 lines · On Thu, 17 Jun 2021 19:33:27 +0300 Ido Schimmel wrote:
Quoted 4 lines · Michal Kubecek

I believe this issue has been already fixed in net tree by commit e175aef90269 ("ethtool: strset: fix message length calculation") but as this commit has not been merged into net-next yet, you could hit it with the stricter check.

Yea. I reached the same conclusion :/

Ah damn, I should have waited for the merge, sorry about that :S