From: Oliver Neukum <oneukum@suse.de>
To: russ.dill@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, greg@kroah.com
Subject: Re: [PATCH] usb: serial: Perform verification for FTDI FT232R devices
Date: Mon, 27 Oct 2014 11:58:39 +0100 [thread overview]
Message-ID: <1414407519.26910.5.camel@linux-0dmf.site> (raw)
In-Reply-To: <1414054344-3688-1-git-send-email-Russ.Dill@gmail.com>
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
next prev parent reply other threads:[~2014-10-27 10:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-23 8:52 russ.dill
2014-10-23 9:40 ` Greg KH
2014-10-23 9:53 ` Frans Klaver
2014-10-23 11:18 ` One Thousand Gnomes
2014-10-23 11:19 ` Johan Hovold
2014-10-23 12:55 ` Mark Brown
2014-10-27 10:58 ` Oliver Neukum [this message]
2014-10-27 11:09 ` Oliver Neukum
2014-10-23 12:44 Hector Martin
2014-10-23 14:14 ` Russ Dill
2014-10-23 17:05 ` Hector Martin
2014-10-24 6:22 ` Perry Hung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1414407519.26910.5.camel@linux-0dmf.site \
--to=oneukum@suse.de \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=russ.dill@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome