Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp792319pxk; Wed, 9 Sep 2020 20:50:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6lwMC9OAAuyVv5nZEZmza6BoizVok+hmFw7uhjtAjXn++4W1QshcMCvmMhBHwrVuKKXHA X-Received: by 2002:a17:906:d78d:: with SMTP id pj13mr7001698ejb.15.1599709853525; Wed, 09 Sep 2020 20:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599709853; cv=none; d=google.com; s=arc-20160816; b=VrqyhNxsQqiRou/DicqysiqwkJZekzRCBvfTNMHjkHnlUQzCY6euAz79KH2Q1+wES+ 1LWE/LPD5nZ9/OnGrtAMSfVyvjPOErVH//uxdpn6S1pr51xTAivZpCDdjEWHzAvp/Rzu LSmM5hAqMhWQpte8V43sDzow3RxSwjnW1R32R12luIUFoRcOo1DRHKBfsHMAGGyYbJad wq0yXY/6w3L8gR/X4IHuGzWjWn5pbUnuUjfGtXmxixxgDi4hoUUgvv2YvifjwSMIwwkD XmgQMmOV4NOsggoW2ZVQYrj4TOEriJDrkL3huxzGkxi8duU+97WhARd7+IAk0gXBgkik Q5Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date; bh=HgXOw9uWQcHOb6wyQJjOoKjxogfbvfzZVmVbnXqnr+E=; b=D+11V5VjEOFhJqjRLacLZ9kcbcL9nzw4LrrdsyhVh9hU158MpzCN7+E1+7CZ/2fLhD nN9v3Y5fAK38/Sq/8zYfjdDRN81yF/nW/DmgxfQlQptuexrIPBhzUvbbLBY7OuoEwdHz KEh217BdomdExF/x4xGlYC042+XzVe7cw8DSOBu6gEkHFlXh9lyqHtBPIIYz2k03yCyi ErqUdQBXuOE8a3FnKFoPNFEeJoBKP+IwqvjKcfhFx+jXlBRUY3F+Qr9KlmoRH3czAwUh PODUYBfTNBAZ1SzCvd4nJ50oShjQ3bRzfvKQ4rMpBvljoHXRNSRr5b6ZUoAV/RrPCFes vMEA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si2662806edw.287.2020.09.09.20.50.31; Wed, 09 Sep 2020 20:50:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730092AbgIJDtJ convert rfc822-to-8bit (ORCPT + 99 others); Wed, 9 Sep 2020 23:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgIJDtJ (ORCPT ); Wed, 9 Sep 2020 23:49:09 -0400 Received: from mail.marcansoft.com (marcansoft.com [IPv6:2a01:298:fe:f::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2E43C061573; Wed, 9 Sep 2020 20:49:08 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id C898F425DF; Thu, 10 Sep 2020 03:49:05 +0000 (UTC) Date: Thu, 10 Sep 2020 12:49:01 +0900 User-Agent: K-9 Mail for Android In-Reply-To: References: <20200909193419.2006744-1-james.hilliard1@gmail.com> <1599706954.10822.3.camel@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH v2] usb: serial: Repair FTDI FT232R bricked eeprom To: James Hilliard CC: Oliver Neukum , linux-usb@vger.kernel.org, Johan Hovold , Greg Kroah-Hartman , Linux Kernel Mailing List , Russ Dill From: "Hector Martin \"marcan\"" Message-ID: <17A89C84-23A1-42DD-B541-F61BC7693560@marcansoft.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 :) >> >> 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? >> >> > >> >> +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