netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value
  2023-09-08 14:03 Parthiban Veerasooran
@ 2023-09-07 17:11 ` Jakub Kicinski
  2023-09-08  3:44 ` Jakub Kicinski
  1 sibling, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2023-09-07 17:11 UTC (permalink / raw)
  To: Parthiban Veerasooran
  Cc: piergiorgio.beruto, davem, edumazet, pabeni, andrew, netdev,
	linux-kernel, horatiu.vultur, Woojung.Huh, Nicolas.Ferre,
	Thorsten.Kummermehr, UNGLinuxDriver

On Fri, 8 Sep 2023 19:33:46 +0530 Parthiban Veerasooran wrote:
> The ETHTOOL_A_PLCA_ENABLED data type is u8. But while parsing the
> value from the attribute, nla_get_u32() is used in the plca_update_sint()
> function instead of nla_get_u8(). So plca_cfg.enabled variable is updated
> with some garbage value instead of 0 or 1 and always enables plca even
> though plca is disabled through ethtool application. This bug has been
> fixed by parsing the values based on the attributes type in the policy.
> 
> Fixes: 8580e16c28f3 ("net/ethtool: add netlink interface for the PLCA RS")
> Signed-off-by: Parthiban Veerasooran <Parthiban.Veerasooran@microchip.com>

Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value
  2023-09-08 14:03 Parthiban Veerasooran
  2023-09-07 17:11 ` Jakub Kicinski
@ 2023-09-08  3:44 ` Jakub Kicinski
  2023-09-08  4:35   ` Parthiban.Veerasooran
  1 sibling, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2023-09-08  3:44 UTC (permalink / raw)
  To: Parthiban Veerasooran
  Cc: piergiorgio.beruto, davem, edumazet, pabeni, andrew, netdev,
	linux-kernel, horatiu.vultur, Woojung.Huh, Nicolas.Ferre,
	Thorsten.Kummermehr, UNGLinuxDriver

On Fri, 8 Sep 2023 19:33:46 +0530 Parthiban Veerasooran wrote:
> The ETHTOOL_A_PLCA_ENABLED data type is u8. But while parsing the
> value from the attribute, nla_get_u32() is used in the plca_update_sint()
> function instead of nla_get_u8(). So plca_cfg.enabled variable is updated
> with some garbage value instead of 0 or 1 and always enables plca even
> though plca is disabled through ethtool application. This bug has been
> fixed by parsing the values based on the attributes type in the policy.
> 
> Fixes: 8580e16c28f3 ("net/ethtool: add netlink interface for the PLCA RS")
> Signed-off-by: Parthiban Veerasooran <Parthiban.Veerasooran@microchip.com>

One second look you need to fix the date on your system and resend.
The patch came to us with a date 24h in the future it will confuse
patchwork.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value
  2023-09-08  3:44 ` Jakub Kicinski
@ 2023-09-08  4:35   ` Parthiban.Veerasooran
  0 siblings, 0 replies; 7+ messages in thread
From: Parthiban.Veerasooran @ 2023-09-08  4:35 UTC (permalink / raw)
  To: kuba
  Cc: piergiorgio.beruto, davem, edumazet, pabeni, andrew, netdev,
	linux-kernel, Horatiu.Vultur, Woojung.Huh, Nicolas.Ferre,
	Thorsten.Kummermehr, UNGLinuxDriver

Hi Jakub,

On 08/09/23 9:14 am, Jakub Kicinski wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Fri, 8 Sep 2023 19:33:46 +0530 Parthiban Veerasooran wrote:
>> The ETHTOOL_A_PLCA_ENABLED data type is u8. But while parsing the
>> value from the attribute, nla_get_u32() is used in the plca_update_sint()
>> function instead of nla_get_u8(). So plca_cfg.enabled variable is updated
>> with some garbage value instead of 0 or 1 and always enables plca even
>> though plca is disabled through ethtool application. This bug has been
>> fixed by parsing the values based on the attributes type in the policy.
>>
>> Fixes: 8580e16c28f3 ("net/ethtool: add netlink interface for the PLCA RS")
>> Signed-off-by: Parthiban Veerasooran <Parthiban.Veerasooran@microchip.com>
> 
> One second look you need to fix the date on your system and resend.
> The patch came to us with a date 24h in the future it will confuse
> patchwork.
Sorry, by mistake the date has been set one day ahead. I will correct it 
and resend the patch now.

Best Regards,
Parthiban V
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value
@ 2023-09-08  4:45 Parthiban Veerasooran
  2023-09-12 12:07 ` Andrew Lunn
  2023-10-03 14:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 7+ messages in thread
From: Parthiban Veerasooran @ 2023-09-08  4:45 UTC (permalink / raw)
  To: kuba, piergiorgio.beruto, davem, edumazet, pabeni, andrew, netdev,
	linux-kernel
  Cc: horatiu.vultur, Woojung.Huh, Nicolas.Ferre, Thorsten.Kummermehr,
	UNGLinuxDriver, Parthiban Veerasooran

The ETHTOOL_A_PLCA_ENABLED data type is u8. But while parsing the
value from the attribute, nla_get_u32() is used in the plca_update_sint()
function instead of nla_get_u8(). So plca_cfg.enabled variable is updated
with some garbage value instead of 0 or 1 and always enables plca even
though plca is disabled through ethtool application. This bug has been
fixed by parsing the values based on the attributes type in the policy.

Fixes: 8580e16c28f3 ("net/ethtool: add netlink interface for the PLCA RS")
Signed-off-by: Parthiban Veerasooran <Parthiban.Veerasooran@microchip.com>
---
 net/ethtool/plca.c | 45 +++++++++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/net/ethtool/plca.c b/net/ethtool/plca.c
index b238a1afe9ae..b1e2e3b5027f 100644
--- a/net/ethtool/plca.c
+++ b/net/ethtool/plca.c
@@ -21,16 +21,6 @@ struct plca_reply_data {
 #define PLCA_REPDATA(__reply_base) \
 	container_of(__reply_base, struct plca_reply_data, base)
 
-static void plca_update_sint(int *dst, const struct nlattr *attr,
-			     bool *mod)
-{
-	if (!attr)
-		return;
-
-	*dst = nla_get_u32(attr);
-	*mod = true;
-}
-
 // PLCA get configuration message ------------------------------------------- //
 
 const struct nla_policy ethnl_plca_get_cfg_policy[] = {
@@ -38,6 +28,29 @@ const struct nla_policy ethnl_plca_get_cfg_policy[] = {
 		NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
+static void plca_update_sint(int *dst, struct nlattr **tb, u32 attrid,
+			     bool *mod)
+{
+	const struct nlattr *attr = tb[attrid];
+
+	if (!attr ||
+	    WARN_ON_ONCE(attrid >= ARRAY_SIZE(ethnl_plca_set_cfg_policy)))
+		return;
+
+	switch (ethnl_plca_set_cfg_policy[attrid].type) {
+	case NLA_U8:
+		*dst = nla_get_u8(attr);
+		break;
+	case NLA_U32:
+		*dst = nla_get_u32(attr);
+		break;
+	default:
+		WARN_ON_ONCE(1);
+	}
+
+	*mod = true;
+}
+
 static int plca_get_cfg_prepare_data(const struct ethnl_req_info *req_base,
 				     struct ethnl_reply_data *reply_base,
 				     const struct genl_info *info)
@@ -144,13 +157,13 @@ ethnl_set_plca(struct ethnl_req_info *req_info, struct genl_info *info)
 		return -EOPNOTSUPP;
 
 	memset(&plca_cfg, 0xff, sizeof(plca_cfg));
-	plca_update_sint(&plca_cfg.enabled, tb[ETHTOOL_A_PLCA_ENABLED], &mod);
-	plca_update_sint(&plca_cfg.node_id, tb[ETHTOOL_A_PLCA_NODE_ID], &mod);
-	plca_update_sint(&plca_cfg.node_cnt, tb[ETHTOOL_A_PLCA_NODE_CNT], &mod);
-	plca_update_sint(&plca_cfg.to_tmr, tb[ETHTOOL_A_PLCA_TO_TMR], &mod);
-	plca_update_sint(&plca_cfg.burst_cnt, tb[ETHTOOL_A_PLCA_BURST_CNT],
+	plca_update_sint(&plca_cfg.enabled, tb, ETHTOOL_A_PLCA_ENABLED, &mod);
+	plca_update_sint(&plca_cfg.node_id, tb, ETHTOOL_A_PLCA_NODE_ID, &mod);
+	plca_update_sint(&plca_cfg.node_cnt, tb, ETHTOOL_A_PLCA_NODE_CNT, &mod);
+	plca_update_sint(&plca_cfg.to_tmr, tb, ETHTOOL_A_PLCA_TO_TMR, &mod);
+	plca_update_sint(&plca_cfg.burst_cnt, tb, ETHTOOL_A_PLCA_BURST_CNT,
 			 &mod);
-	plca_update_sint(&plca_cfg.burst_tmr, tb[ETHTOOL_A_PLCA_BURST_TMR],
+	plca_update_sint(&plca_cfg.burst_tmr, tb, ETHTOOL_A_PLCA_BURST_TMR,
 			 &mod);
 	if (!mod)
 		return 0;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value
@ 2023-09-08 14:03 Parthiban Veerasooran
  2023-09-07 17:11 ` Jakub Kicinski
  2023-09-08  3:44 ` Jakub Kicinski
  0 siblings, 2 replies; 7+ messages in thread
From: Parthiban Veerasooran @ 2023-09-08 14:03 UTC (permalink / raw)
  To: kuba, piergiorgio.beruto, davem, edumazet, pabeni, andrew, netdev,
	linux-kernel
  Cc: horatiu.vultur, Woojung.Huh, Nicolas.Ferre, Thorsten.Kummermehr,
	UNGLinuxDriver, Parthiban Veerasooran

The ETHTOOL_A_PLCA_ENABLED data type is u8. But while parsing the
value from the attribute, nla_get_u32() is used in the plca_update_sint()
function instead of nla_get_u8(). So plca_cfg.enabled variable is updated
with some garbage value instead of 0 or 1 and always enables plca even
though plca is disabled through ethtool application. This bug has been
fixed by parsing the values based on the attributes type in the policy.

Fixes: 8580e16c28f3 ("net/ethtool: add netlink interface for the PLCA RS")
Signed-off-by: Parthiban Veerasooran <Parthiban.Veerasooran@microchip.com>
---
 net/ethtool/plca.c | 45 +++++++++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/net/ethtool/plca.c b/net/ethtool/plca.c
index b238a1afe9ae..b1e2e3b5027f 100644
--- a/net/ethtool/plca.c
+++ b/net/ethtool/plca.c
@@ -21,16 +21,6 @@ struct plca_reply_data {
 #define PLCA_REPDATA(__reply_base) \
 	container_of(__reply_base, struct plca_reply_data, base)
 
-static void plca_update_sint(int *dst, const struct nlattr *attr,
-			     bool *mod)
-{
-	if (!attr)
-		return;
-
-	*dst = nla_get_u32(attr);
-	*mod = true;
-}
-
 // PLCA get configuration message ------------------------------------------- //
 
 const struct nla_policy ethnl_plca_get_cfg_policy[] = {
@@ -38,6 +28,29 @@ const struct nla_policy ethnl_plca_get_cfg_policy[] = {
 		NLA_POLICY_NESTED(ethnl_header_policy),
 };
 
+static void plca_update_sint(int *dst, struct nlattr **tb, u32 attrid,
+			     bool *mod)
+{
+	const struct nlattr *attr = tb[attrid];
+
+	if (!attr ||
+	    WARN_ON_ONCE(attrid >= ARRAY_SIZE(ethnl_plca_set_cfg_policy)))
+		return;
+
+	switch (ethnl_plca_set_cfg_policy[attrid].type) {
+	case NLA_U8:
+		*dst = nla_get_u8(attr);
+		break;
+	case NLA_U32:
+		*dst = nla_get_u32(attr);
+		break;
+	default:
+		WARN_ON_ONCE(1);
+	}
+
+	*mod = true;
+}
+
 static int plca_get_cfg_prepare_data(const struct ethnl_req_info *req_base,
 				     struct ethnl_reply_data *reply_base,
 				     const struct genl_info *info)
@@ -144,13 +157,13 @@ ethnl_set_plca(struct ethnl_req_info *req_info, struct genl_info *info)
 		return -EOPNOTSUPP;
 
 	memset(&plca_cfg, 0xff, sizeof(plca_cfg));
-	plca_update_sint(&plca_cfg.enabled, tb[ETHTOOL_A_PLCA_ENABLED], &mod);
-	plca_update_sint(&plca_cfg.node_id, tb[ETHTOOL_A_PLCA_NODE_ID], &mod);
-	plca_update_sint(&plca_cfg.node_cnt, tb[ETHTOOL_A_PLCA_NODE_CNT], &mod);
-	plca_update_sint(&plca_cfg.to_tmr, tb[ETHTOOL_A_PLCA_TO_TMR], &mod);
-	plca_update_sint(&plca_cfg.burst_cnt, tb[ETHTOOL_A_PLCA_BURST_CNT],
+	plca_update_sint(&plca_cfg.enabled, tb, ETHTOOL_A_PLCA_ENABLED, &mod);
+	plca_update_sint(&plca_cfg.node_id, tb, ETHTOOL_A_PLCA_NODE_ID, &mod);
+	plca_update_sint(&plca_cfg.node_cnt, tb, ETHTOOL_A_PLCA_NODE_CNT, &mod);
+	plca_update_sint(&plca_cfg.to_tmr, tb, ETHTOOL_A_PLCA_TO_TMR, &mod);
+	plca_update_sint(&plca_cfg.burst_cnt, tb, ETHTOOL_A_PLCA_BURST_CNT,
 			 &mod);
-	plca_update_sint(&plca_cfg.burst_tmr, tb[ETHTOOL_A_PLCA_BURST_TMR],
+	plca_update_sint(&plca_cfg.burst_tmr, tb, ETHTOOL_A_PLCA_BURST_TMR,
 			 &mod);
 	if (!mod)
 		return 0;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value
  2023-09-08  4:45 [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value Parthiban Veerasooran
@ 2023-09-12 12:07 ` Andrew Lunn
  2023-10-03 14:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2023-09-12 12:07 UTC (permalink / raw)
  To: Parthiban Veerasooran
  Cc: kuba, piergiorgio.beruto, davem, edumazet, pabeni, netdev,
	linux-kernel, horatiu.vultur, Woojung.Huh, Nicolas.Ferre,
	Thorsten.Kummermehr, UNGLinuxDriver

On Fri, Sep 08, 2023 at 10:15:48AM +0530, Parthiban Veerasooran wrote:
> The ETHTOOL_A_PLCA_ENABLED data type is u8. But while parsing the
> value from the attribute, nla_get_u32() is used in the plca_update_sint()
> function instead of nla_get_u8(). So plca_cfg.enabled variable is updated
> with some garbage value instead of 0 or 1 and always enables plca even
> though plca is disabled through ethtool application. This bug has been
> fixed by parsing the values based on the attributes type in the policy.
> 
> Fixes: 8580e16c28f3 ("net/ethtool: add netlink interface for the PLCA RS")
> Signed-off-by: Parthiban Veerasooran <Parthiban.Veerasooran@microchip.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value
  2023-09-08  4:45 [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value Parthiban Veerasooran
  2023-09-12 12:07 ` Andrew Lunn
@ 2023-10-03 14:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-03 14:40 UTC (permalink / raw)
  To: Parthiban Veerasooran
  Cc: kuba, piergiorgio.beruto, davem, edumazet, pabeni, andrew, netdev,
	linux-kernel, horatiu.vultur, Woojung.Huh, Nicolas.Ferre,
	Thorsten.Kummermehr, UNGLinuxDriver

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 8 Sep 2023 10:15:48 +0530 you wrote:
> The ETHTOOL_A_PLCA_ENABLED data type is u8. But while parsing the
> value from the attribute, nla_get_u32() is used in the plca_update_sint()
> function instead of nla_get_u8(). So plca_cfg.enabled variable is updated
> with some garbage value instead of 0 or 1 and always enables plca even
> though plca is disabled through ethtool application. This bug has been
> fixed by parsing the values based on the attributes type in the policy.
> 
> [...]

Here is the summary with links:
  - [net,v2] ethtool: plca: fix plca enable data type while parsing the value
    https://git.kernel.org/netdev/net/c/8957261cd814

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] 7+ messages in thread

end of thread, other threads:[~2023-10-03 14:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-08  4:45 [PATCH net v2] ethtool: plca: fix plca enable data type while parsing the value Parthiban Veerasooran
2023-09-12 12:07 ` Andrew Lunn
2023-10-03 14:40 ` patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2023-09-08 14:03 Parthiban Veerasooran
2023-09-07 17:11 ` Jakub Kicinski
2023-09-08  3:44 ` Jakub Kicinski
2023-09-08  4:35   ` Parthiban.Veerasooran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).