Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6140914iog; Thu, 23 Jun 2022 12:11:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t/dhclqLUp+AQLMYUAStQlY2l1ZauNjJuKRlOmNF4zvJHqZAIrZy1fMCjVCrtlM3HOPCke X-Received: by 2002:a17:902:d405:b0:16a:131f:c54a with SMTP id b5-20020a170902d40500b0016a131fc54amr28084104ple.38.1656011505869; Thu, 23 Jun 2022 12:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011505; cv=none; d=google.com; s=arc-20160816; b=SdxliZ9BCWZT3O19NsIOp50XnYmNB8Yc5hpfd8ElzmOFIw+B1+EH16ZlSep+6ckM5v MSvff+ze9ToGQ1x3ToPudmUT4ZnZg42qL/GGtqin8dDAGNXAdzUSvR7DL/NsguPJQ1si e8prEp737XbZH7bYopz91K4m54QoRHSQUsh3D0KgB8Kh5KS2GdPvNjm10GEgIIP8rcQK yfPVA80NFdszOsavfxFIcKyQAIdARJoxn8QvZVaRhcC6kdL2tymOytqBA338114IyLWx cOw4x8OLdMMTr41xIJRkPV15ISAqm0chJGaMMwUj5IpLbbZS8MGgUrzGNwhN/+HVM93N gCXA== 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=WnV7AyoOmP+HcRqYDj1zLus6LKjV6HCtSUn5jnNtLWU=; b=nk+Jd+lK22NUi2TwXAF4of9QsP1WVuu76g9WXn97eW0cfeUFbRM0ip/2apaTtpg2f0 5pmpqt+82qMJMmzcZKtc21exQNHISx7DiT3zxjAJoe+1DdnklKBQwbzH2pf5W4qhHA/Z TDe2RlEYy9oiWWFUG9U5T3MnhLjyfR3MrnGRWFEgFD2db3nJ4sXIawcA6MrWOb+T5PUi W4N6Uu0Xgds9AbVYoKGWAPjnLRyOz7XOoh86OTkPl2FILBaZAP4Q/hfc/0w7YsLLMq/K cwvLvHEw/o/SPK41bjnfJPEW3utETjMs9br6+uF9WS7INgnWgTT92M8vqSF5rYUoMoti e9qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hotup2oB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a170902e84600b00153b640ed90si472435plg.38.2022.06.23.12.11.34; Thu, 23 Jun 2022 12:11:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hotup2oB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237265AbiFWSW0 (ORCPT + 99 others); Thu, 23 Jun 2022 14:22:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237363AbiFWSSS (ORCPT ); Thu, 23 Jun 2022 14:18:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46677B62B1; Thu, 23 Jun 2022 10:24:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C9DF961EE3; Thu, 23 Jun 2022 17:24:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B98CC3411B; Thu, 23 Jun 2022 17:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005082; bh=E0lgWaK+wTrtgx+NOHmYoyAHE5JLXtccaud7lMVI+84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hotup2oBVPwoGjIyBJbLssZ1RnrVcwwrYqnOZ5nM80wBeKxFLxtB4Okcb/L8M44ri qBBp4X/Si0bgJ8uLDVgG5rvc0ggroLm8dZfrSpWFXGO94/XDHYut9z3NUWs7ijtMju sE/cZ0AmYqACtd58b5+JTtSqCgKaly9dk3cc8WgI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marian Postevca Subject: [PATCH 5.4 03/11] usb: gadget: u_ether: fix regression in setting fixed MAC address Date: Thu, 23 Jun 2022 18:45:07 +0200 Message-Id: <20220623164321.298588956@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marian Postevca commit b337af3a4d6147000b7ca6b3438bf5c820849b37 upstream. In systemd systems setting a fixed MAC address through the "dev_addr" module argument fails systematically. When checking the MAC address after the interface is created it always has the same but different MAC address to the one supplied as argument. This is partially caused by systemd which by default will set an internally generated permanent MAC address for interfaces that are marked as having a randomly generated address. Commit 890d5b40908bfd1a ("usb: gadget: u_ether: fix race in setting MAC address in setup phase") didn't take into account the fact that the interface must be marked as having a set MAC address when it's set as module argument. Fixed by marking the interface with NET_ADDR_SET when the "dev_addr" module argument is supplied. Fixes: 890d5b40908bfd1a ("usb: gadget: u_ether: fix race in setting MAC address in setup phase") Cc: stable@vger.kernel.org Signed-off-by: Marian Postevca Link: https://lore.kernel.org/r/20220603153459.32722-1-posteuca@mutex.one Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_ether.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -772,9 +772,13 @@ struct eth_dev *gether_setup_name(struct dev->qmult = qmult; snprintf(net->name, sizeof(net->name), "%s%%d", netname); - if (get_ether_addr(dev_addr, net->dev_addr)) + if (get_ether_addr(dev_addr, net->dev_addr)) { + net->addr_assign_type = NET_ADDR_RANDOM; dev_warn(&g->dev, "using random %s ethernet address\n", "self"); + } else { + net->addr_assign_type = NET_ADDR_SET; + } if (get_ether_addr(host_addr, dev->host_mac)) dev_warn(&g->dev, "using random %s ethernet address\n", "host"); @@ -831,6 +835,9 @@ struct net_device *gether_setup_name_def INIT_LIST_HEAD(&dev->tx_reqs); INIT_LIST_HEAD(&dev->rx_reqs); + /* by default we always have a random MAC address */ + net->addr_assign_type = NET_ADDR_RANDOM; + skb_queue_head_init(&dev->rx_frames); /* network device setup */ @@ -868,7 +875,6 @@ int gether_register_netdev(struct net_de g = dev->gadget; memcpy(net->dev_addr, dev->dev_mac, ETH_ALEN); - net->addr_assign_type = NET_ADDR_RANDOM; status = register_netdev(net); if (status < 0) { @@ -908,6 +914,7 @@ int gether_set_dev_addr(struct net_devic if (get_ether_addr(dev_addr, new_addr)) return -EINVAL; memcpy(dev->dev_mac, new_addr, ETH_ALEN); + net->addr_assign_type = NET_ADDR_SET; return 0; } EXPORT_SYMBOL_GPL(gether_set_dev_addr);