lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230831104523.7178-1-Parthiban.Veerasooran@microchip.com>
Date: Thu, 31 Aug 2023 16:15:23 +0530
From: Parthiban Veerasooran <Parthiban.Veerasooran@...rochip.com>
To: <piergiorgio.beruto@...il.com>, <davem@...emloft.net>,
	<edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.co>,
	<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: <horatiu.vultur@...rochip.com>, <Woojung.Huh@...rochip.com>,
	<Nicolas.Ferre@...rochip.com>, <Thorsten.Kummermehr@...rochip.com>,
	"Parthiban Veerasooran" <Parthiban.Veerasooran@...rochip.com>
Subject: [PATCH net-next] ethtool: plca: fix plca enable data type while parsing the value

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 implementing plca_update_sint_from_u8() function which uses
nla_get_u8() function to extract the plca_cfg.enabled value and the
function plca_update_sint_from_u32() is used for extracting the other
values using nla_get_u32() function.

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

diff --git a/net/ethtool/plca.c b/net/ethtool/plca.c
index b238a1afe9ae..b4e80dd33590 100644
--- a/net/ethtool/plca.c
+++ b/net/ethtool/plca.c
@@ -21,8 +21,8 @@ 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)
+static void plca_update_sint_from_u32(int *dst, const struct nlattr *attr,
+				      bool *mod)
 {
 	if (!attr)
 		return;
@@ -31,6 +31,16 @@ static void plca_update_sint(int *dst, const struct nlattr *attr,
 	*mod = true;
 }
 
+static void plca_update_sint_from_u8(int *dst, const struct nlattr *attr,
+				     bool *mod)
+{
+	if (!attr)
+		return;
+
+	*dst = nla_get_u8(attr);
+	*mod = true;
+}
+
 // PLCA get configuration message ------------------------------------------- //
 
 const struct nla_policy ethnl_plca_get_cfg_policy[] = {
@@ -144,14 +154,18 @@ 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],
-			 &mod);
-	plca_update_sint(&plca_cfg.burst_tmr, tb[ETHTOOL_A_PLCA_BURST_TMR],
-			 &mod);
+	plca_update_sint_from_u8(&plca_cfg.enabled, tb[ETHTOOL_A_PLCA_ENABLED],
+				 &mod);
+	plca_update_sint_from_u32(&plca_cfg.node_id, tb[ETHTOOL_A_PLCA_NODE_ID],
+				  &mod);
+	plca_update_sint_from_u32(&plca_cfg.node_cnt,
+				  tb[ETHTOOL_A_PLCA_NODE_CNT], &mod);
+	plca_update_sint_from_u32(&plca_cfg.to_tmr, tb[ETHTOOL_A_PLCA_TO_TMR],
+				  &mod);
+	plca_update_sint_from_u32(&plca_cfg.burst_cnt,
+				  tb[ETHTOOL_A_PLCA_BURST_CNT], &mod);
+	plca_update_sint_from_u32(&plca_cfg.burst_tmr,
+				  tb[ETHTOOL_A_PLCA_BURST_TMR], &mod);
 	if (!mod)
 		return 0;
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ