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: <20220708181235.4104943-2-frank.jungclaus@esd.eu>
Date:   Fri,  8 Jul 2022 20:12:32 +0200
From:   Frank Jungclaus <frank.jungclaus@....eu>
To:     linux-can@...r.kernel.org, Marc Kleine-Budde <mkl@...gutronix.de>,
        Wolfgang Grandegger <wg@...ndegger.com>,
        Vincent Mailhol <mailhol.vincent@...adoo.fr>
Cc:     Stefan Mätje <stefan.maetje@....eu>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        Frank Jungclaus <frank.jungclaus@....eu>
Subject: [PATCH 1/6] can: esd_usb: Allow REC and TEC to return to zero

We don't get any further EVENT from an esd CAN USB device for changes
on REC or TEC while those counters converge to 0 (with ecc == 0).
So when handling the "Back to ACTIVE"-event force txerr =
rxerr = 0, otherwise the berr-counters might stay on values like 95
forever ...

Signed-off-by: Frank Jungclaus <frank.jungclaus@....eu>
---
 drivers/net/can/usb/esd_usb.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
index 8a4bf2961f3d..0b907bc54b70 100644
--- a/drivers/net/can/usb/esd_usb.c
+++ b/drivers/net/can/usb/esd_usb.c
@@ -229,10 +229,14 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
 
 	if (id == ESD_EV_CAN_ERROR_EXT) {
 		u8 state = msg->msg.rx.data[0];
-		u8 ecc = msg->msg.rx.data[1];
+		u8 ecc   = msg->msg.rx.data[1];
 		u8 rxerr = msg->msg.rx.data[2];
 		u8 txerr = msg->msg.rx.data[3];
 
+		netdev_dbg(priv->netdev,
+			   "CAN_ERR_EV_EXT: dlc=%#02x state=%02x ecc=%02x rec=%02x tec=%02x\n",
+			   msg->msg.rx.dlc, state, ecc, rxerr, txerr);
+
 		skb = alloc_can_err_skb(priv->netdev, &cf);
 		if (skb == NULL) {
 			stats->rx_dropped++;
@@ -259,6 +263,15 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
 				break;
 			default:
 				priv->can.state = CAN_STATE_ERROR_ACTIVE;
+				/* We don't get any further EVENT for changes on
+				 * REC or TEC while converging to 0, once we are
+				 * back on ACTIVE.
+				 * So force txerr = rxerr = 0, otherwise the
+				 * berr-counters might stay on values like
+				 * 95 forever ...
+				 */
+				txerr = 0;
+				rxerr = 0;
 				break;
 			}
 		} else {
@@ -292,6 +305,7 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
 					CAN_ERR_CRTL_TX_PASSIVE :
 					CAN_ERR_CRTL_RX_PASSIVE;
 			}
+
 			cf->data[6] = txerr;
 			cf->data[7] = rxerr;
 		}
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ