Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp811288pxk; Wed, 9 Sep 2020 21:41:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGoWrQ+YeCX99CLY2gjo6dP2y3VpBQFk04fkS4wHPxwW3lulD9WhmRBNaQI8NS85Il/3Kr X-Received: by 2002:a17:906:7856:: with SMTP id p22mr6829853ejm.262.1599712875574; Wed, 09 Sep 2020 21:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599712875; cv=none; d=google.com; s=arc-20160816; b=i4xzyb9qpgftFjq7Xjq0+aR+//AOjBREtS9legobdKbxyJdSa/AH/rzOaGsxAZUyhv moQPxRD9hN8WEwDRJGeN/ThaL99KwmffsCc9JJchNC7ICVb9/xoFaduOGkXBZAdjUMPJ 4D7RdOSBtRONZaWgdyou7p326Y6MolCkKBXuCxUiv0mT23fOvnkxOpQASGjx/GyDawRV CbsdQ1qlbhD0DpN5DkW6lO7xgMjQ8Eqy0azQj/Xj55K65Zw/RPcFzy8DCObM4z8/dvis AJdK1DTGOxzBP2m3RXvCeof5bLbcCSpVpaRU4JO+zX9fA2v//olFRspeT2t9enJIZ9cM v81g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mc9SNJlcG+CRra5ZD7ro4UIYeqbPZf8MuQyyBF3eIN4=; b=A0E/+yFOvn2ANpbm2o/7DRmwz5sp0/P6l/Y++Bfqq2DqJyDNHQs1HmNNn6SqKCnCbR wCkLVBPbW2uLvVYnN3kYT/QjDDOV+0IkVBIPiEC4qgZtnZ0K3N29A9j35qymJJuO8gca 08VDo/eXrIo2/jDjSxcwotv8ggVhiy1hYOhiseOsoSK5ohv0uV+IkR/1PBYhIiMj2MlY WfcoSRVI6vTBf9Ar0V4heYls8L/wHgiUXx0hamzEtcWBgttc/80xEqjvKLuuMCwjPGrH gB0STPHJKsuLl3jFQ7C1VQO20xE0aP7MDZW9groc3Na4clF7yfed9iLDyWJNeXbduUtY 9Dhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LTHoYaMk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mh2si2844626ejb.228.2020.09.09.21.40.52; Wed, 09 Sep 2020 21:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LTHoYaMk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726079AbgIJEkR (ORCPT + 99 others); Thu, 10 Sep 2020 00:40:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbgIJEkM (ORCPT ); Thu, 10 Sep 2020 00:40:12 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB2E7C061573; Wed, 9 Sep 2020 21:40:10 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id a9so4403950wmm.2; Wed, 09 Sep 2020 21:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mc9SNJlcG+CRra5ZD7ro4UIYeqbPZf8MuQyyBF3eIN4=; b=LTHoYaMk5cQETYo/PMWMjoLIuUg0dtbCwLfx27HE4m8ksDcqiDZUz08HtGzlvImGuA 4R/336vmqWeBNR53AtfB8dbj9NEP9zFjGqASl4MHMbute89Fvps+3Fy0HCaGzCCXD6A6 zxl/tlOefZjf4O+m4iDtaM68dQcoGnzHBKXOwDBm6GXbUQCQJSA81/xabUK2beM8XN4A Km9EfQ6FAqawq6wYGSJVD0LQoniC7rhX7X5FY0T06um1LH/3gLYMY/FJ1tRSQhMESjUn AruZDX1jcPtowc3cXe50dTdmlImFE6ImylL8PW8SRU+A+MizPZ0en8ULjVCKOEZixgPd /drw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mc9SNJlcG+CRra5ZD7ro4UIYeqbPZf8MuQyyBF3eIN4=; b=S762FsE1PBBzh3GacVhVJwalKkXVhTGRVian3dmgO+0PVkOp0IQyq2W64PcZDD5Jaj dfkgucLwVvDyo/G4CvshQw9f8Ij3n8bzqzsCPW+ZD6t2BWIpWKRwHNxHIwrMdmymT+ak 54umkhUOCTJ9Pe/NoSOAmQ9dQUSZw63UpE/JlDPF4sDUtd3kwyWD7Rq6qn2yFwcKBPuN 9nmlGf/rq/g84nCzwpBMx5xKSZC4HRt9/tr1FKqvKL8vQ1HhvT+KwP4rMCoMktAn60vZ XSyuGlRCbldEXNr3Yr9uQ43vaXKucPlT0tykh5Cl3baw5fNIitItubnpl6oOYO+GQx4Q krYw== X-Gm-Message-State: AOAM532M5XNZgqczDrnWPF4rdm3YCDIqhlDxJUXUOzfe5if3M+kO0i4G 3Rw82QTvfemTuLnaFfD8fi9HwfwAy/sMjJXTv6hauxLdEXo= X-Received: by 2002:a1c:14e:: with SMTP id 75mr6893527wmb.114.1599712809340; Wed, 09 Sep 2020 21:40:09 -0700 (PDT) MIME-Version: 1.0 References: <20200909193419.2006744-1-james.hilliard1@gmail.com> <1599706954.10822.3.camel@suse.de> <17A89C84-23A1-42DD-B541-F61BC7693560@marcansoft.com> In-Reply-To: <17A89C84-23A1-42DD-B541-F61BC7693560@marcansoft.com> From: James Hilliard Date: Wed, 9 Sep 2020 22:39:56 -0600 Message-ID: Subject: Re: [PATCH v2] usb: serial: Repair FTDI FT232R bricked eeprom To: Hector Martin marcan Cc: Oliver Neukum , linux-usb@vger.kernel.org, Johan Hovold , Greg Kroah-Hartman , Linux Kernel Mailing List , Russ Dill Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 9, 2020 at 9:49 PM Hector Martin "marcan" wrote: > > > > On September 10, 2020 12:46:20 PM GMT+09:00, James Hilliard wrote: > >On Wed, Sep 9, 2020 at 9:17 PM Hector Martin "marcan" > > wrote: > >> > >> > >> > >> On September 10, 2020 12:02:34 PM GMT+09:00, Oliver Neukum > > wrote: > >> >Am Mittwoch, den 09.09.2020, 13:34 -0600 schrieb James Hilliard: > >> >> This patch detects and reverses the effects of the malicious FTDI > >> >> Windows driver version 2.12.00(FTDIgate). > >> > > >> >Hi, > >> > > >> >this raises questions. > >> >Should we do this unconditionally without asking? > >> >Does this belong into kernel space? > >> > >> I agree; this is very cute, but does it really need to be an > >automatic Linux feature? Presumably someone looking to fix a bricked > >FTDI chip can just run my script, and those who just want to use those > >chips with Linux already can since the driver binds to the zero PID. > >Well for one your script is not easily useable with embedded platforms > >like mine where I ran into this issue, I have no python2 interpreter > >available in my production builds. > > Surely you can port the exact same algorithm to plain userspace C, as you did to kernel space C :) Sure, but it would be significantly more complex, require a lot more code and testing since there can be other userspace apps interacting with the hardware, in addition to being less reliable and potentially difficult to install for some setups. Detecting and dealing with this issue in the kernel is very simple and reliable in comparison. There's also potentially permissions issues if one wants to do this from userspace from my understanding. > > >> > >> I am deeply amused by the idea of Linux automatically fixing problems > >caused by malicious Windows drivers, but thinking objectively, I'm not > >sure if that's the right thing to do. > >From my understanding Linux fixing up hardware issues caused > >by faulty/weird Windows drivers isn't exactly unusual. > > I'm not aware of any instances like this where nonvolatile memory is modified. At most you'll get things like resetting devices that a previous windows warm boot misconfigured, I think? Yeah, I think it's mostly nonvolatile memory, I've seen this issue quite a bit with some of the Realtek ethernet drivers. I think user experience for devices should be that one can move a USB device from Linux to Windows and back without having to manually reprogram an eeprom. The sheer amount of resources FTDI has wasted with their malicious Windows driver is crazy and likely far exceeds any losses from counterfeiting. I think due to how widespread this issue is it makes sense to aggressively and automatically mitigate the damages wherever possible, it's also likely a major source of ewaste since people may throw out perfectly functional hardware without knowing it can be fixed easily. > > >> > >> > > >> >> +static int ftdi_repair_brick(struct usb_serial_port *port) > >> >> +{ > >> >> + struct ftdi_private *priv = usb_get_serial_port_data(port); > >> >> + int orig_latency; > >> >> + int rv; > >> >> + u16 *eeprom_data; > >> >> + u16 checksum; > >> >> + int eeprom_size; > >> >> + int result; > >> >> + > >> >> + switch (priv->chip_type) { > >> >> + case FT232RL: > >> >> + eeprom_size = 0x40; > >> >> + break; > >> >> + default: > >> >> + /* Unsupported for brick repair */ > >> >> + return 0; > >> >> + } > >> >> + > >> >> + /* Latency timer needs to be 0x77 to unlock EEPROM > >programming */ > >> >> + if (priv->latency != 0x77) { > >> >> + orig_latency = priv->latency; > >> >> + priv->latency = 0x77; > >> >> + rv = write_latency_timer(port); > >> >> + priv->latency = orig_latency; > >> >> + if (rv < 0) > >> >> + return -EIO; > >> >> + } > >> > > >> >Do you really want to change this without returning to the original? > >> > > >> > Regards > >> > Oliver > >> > >> -- > >> Hector Martin "marcan" (hector@marcansoft.com) > >> Public key: https://mrcn.st/pub > > -- > Hector Martin "marcan" (hector@marcansoft.com) > Public key: https://mrcn.st/pub