Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4783084pxu; Tue, 13 Oct 2020 07:07:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpnA5hu/sTcXcr/r1nH2yVXyxPG2H9G/XQpQJxcKHb7Z8vD4pZ8zTXnmkeyfGTMFbknpFA X-Received: by 2002:a05:6512:3455:: with SMTP id j21mr10440855lfr.135.1602598020353; Tue, 13 Oct 2020 07:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602598020; cv=none; d=google.com; s=arc-20160816; b=mVEFZJHiL9PvDR84Fk5wuxi6xipX/UnbriNpaPW0krxJPqebz12UiHgo+k2WoYVW/j ZeF3BzTNs93nHJOXvjjGUHsHCBX5531yoGpHyp/koPLYX1v2ImAiLAEK723g6Z9eIeuu GgS3Jl90REJGkxUh4CP8X430kEqqvJp7INk4d1jupuhhnnSX5qvhBKtkHJoDl2qY6/aC RtYf7teRZc2HWfYemYmefnhKUWWxt5FHM+hEYzrtcmwQ5gcrsGamzv0Wn7HCd1Ns1GXn /iC32UD3rJql4q8OXfn2eMGiSsRb1o/S8kOw3fQbBR7Gd1odrGJMZwPybOmpt/hPd6uB jvlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CJIzxj74bRbK6s07BM0CYFriStr95mhUR/FUtxsHOVI=; b=NdF9g5w/wMJcqmB572AuCoYsKu/SMAm6/qvuDnfffTs/fyWnBWaihTZSjoLxOFdnHb j/T0aY2628bJWLxiUh2rbkgj3/N+h6zsTR+Xe0BEgvYTfX0Wq7w/TWJ8wOoel1erveMw ih+gpD0fXZsWcY3AsTRiGFAD+Uz5iRmynWwRc0s2HQtzUyP8+5lWtgkjy8yc8Z+mJcot 8eFk2zhtRXKtN8fNlYDl+6jlS51nfhn7zxn12kJDB8oJ1jXEz5m8tiQTLSI+YwCxCz/S OoGHNkj3XpjLORRG1MSN9qWBOQrF0nrxdz+2+03H+6hSucxWc3uCu1oC/dFuhl92j85U 3RIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nucleusys.com header.s=x header.b=cyr+pQNI; 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 f13si16328888edc.249.2020.10.13.07.06.31; Tue, 13 Oct 2020 07:07:00 -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=fail header.i=@nucleusys.com header.s=x header.b=cyr+pQNI; 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 S1732072AbgJLVBU (ORCPT + 99 others); Mon, 12 Oct 2020 17:01:20 -0400 Received: from lan.nucleusys.com ([92.247.61.126]:36686 "EHLO zztop.nucleusys.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729639AbgJLVBU (ORCPT ); Mon, 12 Oct 2020 17:01:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nucleusys.com; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CJIzxj74bRbK6s07BM0CYFriStr95mhUR/FUtxsHOVI=; b=cyr+pQNICJxG1pzmfwF4K8B77P xbKi8vFMvJcXOeKnMkdUYQn+MEsresCGmf29nTQmbd+YE8gU2/8BmXmi5H0vPXAG8SOyc+5Wxrkja tTbvRUyzQ9l0MqbHI/cn0jK0BjZGcZrQFqIXMZbwNb59/nzYODrQ56QYd6+q01k8GwZA=; Received: from lan.nucleusys.com ([92.247.61.126] helo=nucleusys.com) by zztop.nucleusys.com with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kS4wN-0007CC-HJ; Tue, 13 Oct 2020 00:01:07 +0300 Date: Tue, 13 Oct 2020 00:01:06 +0300 From: Petko Manolov To: Joe Perches Cc: Sasha Levin , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Anant Thazhemadam , syzbot+abbc768b560c84d92fd3@syzkaller.appspotmail.com, "David S . Miller" , linux-usb@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH AUTOSEL 5.8 18/24] net: usb: rtl8150: set random MAC address when set_ethernet_addr() fails Message-ID: <20201012210105.GA26582@nucleusys.com> References: <20201012190239.3279198-1-sashal@kernel.org> <20201012190239.3279198-18-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Score: -1.0 (-) X-Spam-Report: Spam detection software, running on the system "zztop.nucleusys.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 20-10-12 12:11:18, Joe Perches wrote: > On Mon, 2020-10-12 at 15:02 -0400, Sasha Levin wrote: > > From: Anant Thazhemadam > > > > [ Upstream commit f45a4248ea4cc13ed50 [...] Content analysis details: (-1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20-10-12 12:11:18, Joe Perches wrote: > On Mon, 2020-10-12 at 15:02 -0400, Sasha Levin wrote: > > From: Anant Thazhemadam > > > > [ Upstream commit f45a4248ea4cc13ed50618ff066849f9587226b2 ] > > > > When get_registers() fails in set_ethernet_addr(),the uninitialized > > value of node_id gets copied over as the address. > > So, check the return value of get_registers(). > > > > If get_registers() executed successfully (i.e., it returns > > sizeof(node_id)), copy over the MAC address using ether_addr_copy() > > (instead of using memcpy()). > > > > Else, if get_registers() failed instead, a randomly generated MAC > > address is set as the MAC address instead. > > This autosel is premature. > > This patch always sets a random MAC. > See the follow on patch: https://lkml.org/lkml/2020/10/11/131 > To my knowledge, this follow-ob has yet to be applied: ACK, the follow-on patch has got the correct semantics. Petko > > diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c > [] > > @@ -274,12 +274,20 @@ static int write_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 reg) > > return 1; > > } > > > > -static inline void set_ethernet_addr(rtl8150_t * dev) > > +static void set_ethernet_addr(rtl8150_t *dev) > > { > > - u8 node_id[6]; > > + u8 node_id[ETH_ALEN]; > > + int ret; > > + > > + ret = get_registers(dev, IDR, sizeof(node_id), node_id); > > > > - get_registers(dev, IDR, sizeof(node_id), node_id); > > - memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id)); > > + if (ret == sizeof(node_id)) { > > So this needs to use > if (!ret) { > > or > if (ret < 0) > > and reversed code blocks > > > + ether_addr_copy(dev->netdev->dev_addr, node_id); > > + } else { > > + eth_hw_addr_random(dev->netdev); > > + netdev_notice(dev->netdev, "Assigned a random MAC address: %pM\n", > > + dev->netdev->dev_addr); > > + } > > } > > > > static int rtl8150_set_mac_address(struct net_device *netdev, void *p) > >