Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4341435pxu; Mon, 12 Oct 2020 16:51:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmKFO/dmzPNzSDSdxKXUmhX7h0FM8vwD3Qsg47GTFwlLzf9FTLIKCU/73fP43h4l5TJYO4 X-Received: by 2002:a17:906:715a:: with SMTP id z26mr30906675ejj.300.1602546703917; Mon, 12 Oct 2020 16:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602546703; cv=none; d=google.com; s=arc-20160816; b=Y6DJ5NLQkNHqElGVA1Is+NQ+dEFHxd3hXPAl2wWqCxoMpRgUmUIz/i2mRjiEDt5NUG OjOPMcsa7VIVazZn15nt3QlHY2Qa+uUkwTlMfRcXvgmudpA8/AyNULOP8CUr7ATu1qhp /8HxL8GgrulNPVa+ogxRKijPx00VQCWmgi3hbiPAUrwBwXxmAWPI8SQEBvisgZahZTXn u0Y9kBixj2h9H5M58dOWYjExsylmCTw65CRxMRbhuTKqljPXY8TPyrTOc8RuzUTB6UT+ c+5l8RZwLiHtHtsRJDZPg1eMQBvCc0fCmBoaUfACKXKPQS8rTFig9WtMyWU2kLhuR9KZ gnYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=S1f+W4d22G6llsgRm7rOg1BgYZCCbh5mbGVLlSSTnpY=; b=zyyYnkJV2lUNtGY3rqltWqnls3hNFAHO7yisUCC1ccWoYqovCuBvqUpurtklW7S6Hn 617nMjUl7nV9VVUNhL1urVPNBivr5fZFgritC+jFb0K36esORXC5vdCnkcFUmzD/nOCH BNxJZG0GiNA3MYVm/u6IznyTQfbITPCBzwmUcCuPqXttoZC4j6nrq+Ozpz0fOS2rKXO2 4bUEPz8NLJBBQeFmWBM5U1H4j/RQrmNlnqWNbudv6xr9YCRAy//4iz2oPFB6LJZUl3bh IvSBl9PmLQYa8V71Ekk5ae0Wbn+TIj0/93uEIaM3edVzWPEE9gfrh548wYVlA0PBvv01 sE+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=udEAG1VL; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si13974462edj.536.2020.10.12.16.51.21; Mon, 12 Oct 2020 16:51:43 -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=@kernel.org header.s=default header.b=udEAG1VL; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388978AbgJLNtO (ORCPT + 99 others); Mon, 12 Oct 2020 09:49:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:56090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731967AbgJLNsZ (ORCPT ); Mon, 12 Oct 2020 09:48:25 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 98174204EA; Mon, 12 Oct 2020 13:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510505; bh=a3Q3V8bBQ9RJ6Ep9H/etmQVXPdkvZl/om5e+Fj65gaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=udEAG1VLYoQW44PWk4Py8EpZGcuF0jszGpJefOFrSbRbOFaoQSVRwkyK0BqK0or9Q 1y9kCqtB07CjPhCBuAhRp1JGIdX/0Lq4dsC+rwYS7Fftmgbrh3UFayK3wi9BgXkC5i zvfGo3NICffW29QO0n8njn24iG/nEJh2WdwzFmZg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+abbc768b560c84d92fd3@syzkaller.appspotmail.com, Petko Manolov , Anant Thazhemadam , "David S. Miller" Subject: [PATCH 5.8 121/124] net: usb: rtl8150: set random MAC address when set_ethernet_addr() fails Date: Mon, 12 Oct 2020 15:32:05 +0200 Message-Id: <20201012133152.713096759@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012133146.834528783@linuxfoundation.org> References: <20201012133146.834528783@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anant Thazhemadam commit f45a4248ea4cc13ed50618ff066849f9587226b2 upstream. 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. Reported-by: syzbot+abbc768b560c84d92fd3@syzkaller.appspotmail.com Tested-by: syzbot+abbc768b560c84d92fd3@syzkaller.appspotmail.com Acked-by: Petko Manolov Signed-off-by: Anant Thazhemadam Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/rtl8150.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- a/drivers/net/usb/rtl8150.c +++ b/drivers/net/usb/rtl8150.c @@ -274,12 +274,20 @@ static int write_mii_word(rtl8150_t * de 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; - get_registers(dev, IDR, sizeof(node_id), node_id); - memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id)); + ret = get_registers(dev, IDR, sizeof(node_id), node_id); + + if (ret == sizeof(node_id)) { + 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)