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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220612213927.3004444-6-dario.binacchi@amarulasolutions.com>
Date:   Sun, 12 Jun 2022 23:39:19 +0200
From:   Dario Binacchi <dario.binacchi@...rulasolutions.com>
To:     linux-kernel@...r.kernel.org
Cc:     michael@...rulasolutions.com,
        Amarula patchwork <linux-amarula@...rulasolutions.com>,
        Oliver Hartkopp <socketcan@...tkopp.net>,
        Dario Binacchi <dario.binacchi@...rulasolutions.com>,
        Marc Kleine-Budde <mkl@...gutronix.de>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Vincent Mailhol <mailhol.vincent@...adoo.fr>,
        Wolfgang Grandegger <wg@...ndegger.com>,
        linux-can@...r.kernel.org, netdev@...r.kernel.org
Subject: [PATCH v3 05/13] can: netlink: dump bitrate 0 if can_priv::bittiming.bitrate is -1U

Adding Netlink support to the slcan driver made it necessary to set the
bitrate to a fake value (-1U) to prevent open_candev() from failing. In
this case the command `ip --details -s -s link show' would print
4294967295 as the bitrate value. The patch change this value in 0.

Suggested-by: Marc Kleine-Budde <mkl@...gutronix.de>
Signed-off-by: Dario Binacchi <dario.binacchi@...rulasolutions.com>
---

(no changes since v1)

 drivers/net/can/dev/netlink.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c
index 7633d98e3912..788a6752fcc7 100644
--- a/drivers/net/can/dev/netlink.c
+++ b/drivers/net/can/dev/netlink.c
@@ -505,11 +505,16 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
 	struct can_ctrlmode cm = {.flags = priv->ctrlmode};
 	struct can_berr_counter bec = { };
 	enum can_state state = priv->state;
+	__u32 bitrate = priv->bittiming.bitrate;
+	int ret = 0;
 
 	if (priv->do_get_state)
 		priv->do_get_state(dev, &state);
 
-	if ((priv->bittiming.bitrate &&
+	if (bitrate == -1U)
+		priv->bittiming.bitrate = 0;
+
+	if ((bitrate &&
 	     nla_put(skb, IFLA_CAN_BITTIMING,
 		     sizeof(priv->bittiming), &priv->bittiming)) ||
 
@@ -563,9 +568,10 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
 	    can_ctrlmode_ext_fill_info(skb, priv)
 	    )
 
-		return -EMSGSIZE;
+		ret = -EMSGSIZE;
 
-	return 0;
+	priv->bittiming.bitrate = bitrate;
+	return ret;
 }
 
 static size_t can_get_xstats_size(const struct net_device *dev)
-- 
2.32.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ