Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp234147imu; Wed, 7 Nov 2018 16:19:05 -0800 (PST) X-Google-Smtp-Source: AJdET5fL4JNfiEv/zIKniNati/Ce56+R4RAEP9xfoNK7gtHEC7X6Uam7I+gm3XCCpWn8Ws7J3POG X-Received: by 2002:a17:902:8a8e:: with SMTP id p14-v6mr2391451plo.133.1541636345467; Wed, 07 Nov 2018 16:19:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541636345; cv=none; d=google.com; s=arc-20160816; b=Rrq5GEeniCgIdwr9AxMbk2luiRXXibcq7VprG1aHFAgDgIgzrCldrWOZhCeL0kT4wR Mw/lkFqM6xja9xggm6UlMglWnUccfwkF5ZkM+jh917l3tiJbjyJ4DFrA6vLykz6+XzOa R4JJdP8N+hkZbMP+TqoEYU386dL0evFWyluAiZzGORW/RukzMSCYX8qyK+yGL1trMIsZ /8DVoUW2imL0oyctzHF2GlUhl8R2OAebY9DfCeYZ9a5oWVoGkWbCbBe5TZPi09pkVX1X 16CjHhJJhEmFwKEIwEQZFLRPg7CkR2xfLx7fFmtaWpDnhHszODB3c3u4DpE5eRX+Vn9p O/Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WjaxxRiv3QgkWfdFOcf0SY/9u79jPNRVc2JdNgrT254=; b=m4wMc7a5GGAviopjO3x0513jB6Cn8XXNoqhNrK8fUEXbUZlfGDH6AjzKikapo6n9xu wxLqYC0LAVMrb8R6YMLL+I82YED8U163gzZYWtm+BffYFlVqQcOWnpur+51vqFXmILOD 9yZ0B4PQjpZ6FLaMkBM826oqCmOxrYEA26UQj1IrI0PUBGZLXgyVj4SlF1hRbBS7EBlG C8QWm1vA8eGpvYoeZKFFADFtTb6A9bSIzKSD1RFGgM/cs1ya3LnAVDIgIjbi0AUQDesi 4nvMd5aUk31gvivpMBCyRUmPl6GpqzYxIJ5/YOAp4etmSGnZqFE1QwbrrqBfbMBheCZ/ 828A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jwyTxGO2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg1-v6si2223897plb.165.2018.11.07.16.18.38; Wed, 07 Nov 2018 16:19:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jwyTxGO2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbeKHJul (ORCPT + 99 others); Thu, 8 Nov 2018 04:50:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:34388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727861AbeKHJul (ORCPT ); Thu, 8 Nov 2018 04:50:41 -0500 Received: from localhost (unknown [131.107.159.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 24A6C20857; Thu, 8 Nov 2018 00:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541636272; bh=/TeVOT9uEuMGIn9YlWXqGjgokwKVf/7Py4uaskdDfaw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jwyTxGO2PpJyl7En5iag/TwUaP3CnrSN6Lf1IH1jMLh8MyUL74q3xJTNELp6bCbD1 cLdA5wkvRBulfaXQhDDlUfvUGqUVv2jb9AWbtliKiEERq84il0JwRW6o8ZFqs27a0z 3NTOA994uZV6VBMwWIZ0epSl3/j2p2lltnF+icNo= Date: Wed, 7 Nov 2018 19:17:51 -0500 From: Sasha Levin To: Paolo Pisati Cc: Woojung Huh , Microchip Linux Driver Support , netdev@vger.kernel.org, stable@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [stable, netdev 4.4+] lan78xx: make sure RX_ADDRL & RX_ADDRH regs are always up to date Message-ID: <20181108001751.GA8097@sasha-vm> References: <1541609457-28725-1-git-send-email-p.pisati@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1541609457-28725-1-git-send-email-p.pisati@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 07, 2018 at 05:50:57PM +0100, Paolo Pisati wrote: >[partial backport upstream 760db29bdc97b73ff60b091315ad787b1deb5cf5] > >Upon invocation, lan78xx_init_mac_address() checks that the mac address present >in the RX_ADDRL & RX_ADDRH registers is a valid address, if not, it first tries >to read a new address from an external eeprom or the otp area, and in case both >read fail (or the address read back is invalid), it randomly generates a new >one. > >Unfortunately, due to the way the above logic is laid out, >if both read_eeprom() and read_otp() fail, a new mac address is correctly >generated but is never written back to RX_ADDRL & RX_ADDRH, leaving the chip in an >incosistent state and with an invalid mac address (e.g. the nic appears to be >completely dead, and doesn't receive any packet, etc): > >lan78xx_init_mac_address() >... >if (lan78xx_read_eeprom(addr ...) || lan78xx_read_otp(addr ...)) { > if (is_valid_ether_addr(addr) { > // nop... > } else { > random_ether_addr(addr); > } > > // correctly writes back the new address > lan78xx_write_reg(RX_ADDRL, addr ...); > lan78xx_write_reg(RX_ADDRH, addr ...); >} else { > // XXX if both eeprom and otp read fail, we land here and skip > // XXX the RX_ADDRL & RX_ADDRH update completely > random_ether_addr(addr); >} > >This bug went unnoticed because lan78xx_read_otp() was buggy itself and would >never fail, up until 4bfc338 "lan78xx: Correctly indicate invalid OTP" >fixed it and as a side effect uncovered this bug. > >4.18+ is fine, since the bug was implicitly fixed in 760db29 "lan78xx: Read MAC >address from DT if present" when the address change logic was reorganized, but >it's still present in all stable trees below that: linux-4.4.y, linux-4.9.y, >linux-4.14.y, etc up to linux-4.18.y (not included). > >Signed-off-by: Paolo Pisati So why not just take 760db29bdc completely? It looks safer than taking a partial backport, and will make applying future patches easier. I tried to do it and it doesn't look like there are any dependencies that would cause an issue. -- Thanks, Sasha