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]
Date:   Sat, 28 May 2022 09:35:02 +0200
From:   Jimmy Assarsson <extja@...ser.com>
To:     Anssi Hannula <anssi.hannula@...wise.fi>
Cc:     linux-can@...r.kernel.org, Marc Kleine-Budde <mkl@...gutronix.de>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 05/12] can: kvaser_usb_leaf: Set Warning state even
 without bus errors

On 5/16/22 15:47, Anssi Hannula wrote:
> kvaser_usb_leaf_rx_error_update_can_state() sets error state according
> to error counters when the hardware does not indicate a specific state
> directly.
> 
> However, this is currently gated behind a check for
> M16C_STATE_BUS_ERROR which does not always seem to be set when error
> counters are increasing, and may not be set when error counters are
> decreasing.
> 
> This causes the CAN_STATE_ERROR_WARNING state to not be set in some
> cases even when appropriate.
> 
> Change the code to set error state from counters even without
> M16C_STATE_BUS_ERROR.
> 
> The Error-Passive case seems superfluous as it is already set via
> M16C_STATE_BUS_PASSIVE flag above, but it is kept for now.
> 
> Tested with 0bfd:0124 Kvaser Mini PCI Express 2xHS FW 4.18.778.
> 
> Fixes: 080f40a6fa28 ("can: kvaser_usb: Add support for Kvaser CAN/USB devices")
> Signed-off-by: Anssi Hannula <anssi.hannula@...wise.fi>

Looks good to me.
Tested-by: Jimmy Assarsson <extja@...ser.com>

> ---
>   .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c  | 20 ++++++++-----------
>   1 file changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
> index 09ade66256b2..d7f2d64a8083 100644
> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
> @@ -775,20 +775,16 @@ kvaser_usb_leaf_rx_error_update_can_state(struct kvaser_usb_net_priv *priv,
>   		new_state = CAN_STATE_BUS_OFF;
>   	} else if (es->status & M16C_STATE_BUS_PASSIVE) {
>   		new_state = CAN_STATE_ERROR_PASSIVE;
> -	} else if (es->status & M16C_STATE_BUS_ERROR) {
> +	} else if ((es->status & M16C_STATE_BUS_ERROR) &&
> +		   cur_state >= CAN_STATE_BUS_OFF) {
>   		/* Guard against spurious error events after a busoff */
> -		if (cur_state < CAN_STATE_BUS_OFF) {
> -			if (es->txerr >= 128 || es->rxerr >= 128)
> -				new_state = CAN_STATE_ERROR_PASSIVE;
> -			else if (es->txerr >= 96 || es->rxerr >= 96)
> -				new_state = CAN_STATE_ERROR_WARNING;
> -			else if (cur_state > CAN_STATE_ERROR_ACTIVE)
> -				new_state = CAN_STATE_ERROR_ACTIVE;
> -		}
> -	}
> -
> -	if (!es->status)
> +	} else if (es->txerr >= 128 || es->rxerr >= 128) {
> +		new_state = CAN_STATE_ERROR_PASSIVE;
> +	} else if (es->txerr >= 96 || es->rxerr >= 96) {
> +		new_state = CAN_STATE_ERROR_WARNING;
> +	} else {
>   		new_state = CAN_STATE_ERROR_ACTIVE;
> +	}
>   
>   	if (new_state != cur_state) {
>   		tx_state = (es->txerr >= es->rxerr) ? new_state : 0;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ