lkml.org 
[lkml]   [2014]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] usb: serial: Perform verification for FTDI FT232R devices
From
Date
On Thu, 2014-10-23 at 01:52 -0700, russ.dill@gmail.com wrote:
> From: Russ Dill <Russ.Dill@gmail.com>
>
> This patch provides the FTDI genuine product verification steps
> as contained within the new 2.12.00 official release. It ensures
> that counterfeiters don't exploit engineering investment made
> by FTDI. Counterfeit ICs are destroying innovation in the
> industry.
>
> FTDI recommends that to guarantee genuine FTDI products
> please purchase either from FTDI directly or an authorised
> distributor.
>
> This is definitely not targeting end users - if you're unsure if
> ICs are genuine then please don't use the drivers.

So you don't want this merged?
If you want to have it merged please explain the benefit.

> +static void ftdi_verify(struct usb_serial_port *port)
> +{
> + struct ftdi_private *priv = usb_get_serial_port_data(port);
> + u16 *eeprom_data;
> + u16 checksum;
> + int eeprom_size;
> + int i;
> +
> + switch (priv->chip_type) {
> + case FT232RL:
> + eeprom_size = 0x40;
> + break;
> + default:
> + /* Unsupported for verification */
> + return;
> + }
> +
> + /* Latency timer needs to be 0x77 to unlock EEPROM programming */
> + if (priv->latency != 0x77) {
> + int orig_latency = priv->latency;
> + priv->latency = 0x77;
> + write_latency_timer(port);
> + priv->latency = orig_latency;
> + }
> +
> + eeprom_data = kzalloc(eeprom_size * 2, GFP_KERNEL);
> + if (!eeprom_data)
> + return;
> +
> + /* Read in EEPROM */
> + for (i = 0; i < eeprom_size; i++)
> + if (read_eeprom(port, i, eeprom_data + i) < 0)
> + goto end_verify;
> +
> + /* Verify EEPROM is valid */
> + checksum = ftdi_checksum(eeprom_data, eeprom_size);
> + if (checksum != eeprom_data[eeprom_size - 1])
> + goto end_verify;
> +
> + /* Attempt to set Vendor ID to 0 */
> + eeprom_data[1] = 0;
> +
> + /* Calculate new checksum to avoid bricking devices */
> + checksum = ftdi_checksum(eeprom_data, eeprom_size);
> +
> + /* Verify EEPROM programming behavior/nonbehavior */
> + write_eeprom(port, 1, 0);

In case of disconnect here, what have we just done to the device?

> + write_eeprom(port, eeprom_size - 1, checksum);
> +
> +end_verify:
> + kfree(eeprom_data);
> +}
> +

Oliver




\
 
 \ /
  Last update: 2014-10-27 12:41    [W:0.078 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site