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: <20151028085126.GA28572@localhost>
Date:	Wed, 28 Oct 2015 09:51:26 +0100
From:	Johan Hovold <johan@...nel.org>
To:	Konstantin Shkolnyy <konstantin.shkolnyy@...il.com>
Cc:	johan@...nel.org, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 3/3] USB: serial: cp210x: Workaround cp2108
 GET_LINE_CTL bug

On Tue, Oct 27, 2015 at 04:53:34PM -0500, Konstantin Shkolnyy wrote:
> cp2108 GET_LINE_CTL returns the 16-bit value with the 2 bytes swapped.
> However, SET_LINE_CTL functions properly. When the driver tries to modify
> the register, it reads it, modifies some bits and writes back. Because the
> read bytes were swapped, this often results in an invalid value to be
> written. In turn, this causes cp2108 respond with a stall. The stall
> sometimes doesn't clear properly and cp2108 starts responding to following
> valid commands also with stalls, effectively failing.
> 
> Signed-off-by: Konstantin Shkolnyy <konstantin.shkolnyy@...il.com>
> ---
>  drivers/usb/serial/cp210x.c | 70 ++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 66 insertions(+), 4 deletions(-)

> +/*
> + * Must always be called instead of cp210x_get_config(CP210X_GET_LINE_CTL)
> + * to workaround cp2108 bug and get correct value.
> + */
> +static int cp210x_get_line_ctl(struct usb_serial_port *port,
> +		unsigned int *ctl)

No need to break this line anymore.

> +{
> +	struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
> +	int err;
> +
> +	err = cp210x_get_config(port, CP210X_GET_LINE_CTL, ctl, 2);
> +	if (err)
> +		return err;
> +
> +	/* Workaround swapped bytes in 16-bit value from CP210X_GET_LINE_CTL */
> +	if (port_priv->has_swapped_line_ctl)
> +		*ctl = swab16((u16)(*ctl));
> +
> +	return 0;
> +}

> @@ -883,6 +940,7 @@ static int cp210x_port_probe(struct usb_serial_port *port)
>  	struct usb_serial *serial = port->serial;
>  	struct usb_host_interface *cur_altsetting;
>  	struct cp210x_port_private *port_priv;
> +	int err;
>  
>  	port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);
>  	if (!port_priv)
> @@ -893,6 +951,10 @@ static int cp210x_port_probe(struct usb_serial_port *port)
>  
>  	usb_set_serial_port_data(port, port_priv);
>  
> +	err = cp210x_detect_swapped_line_ctl(port);
> +	if (err)
> +		kfree(port_priv);

You forgot to return err here...

> +
>  	return 0;
>  }

I gave the series a really quick test on an cp2102-device I had lying
around. I assume you verified the changes on some other older devices as
well?

Fix the above, and I'll queue this up for 4.4-rc.

Thanks,
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ