Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6144521iog; Thu, 23 Jun 2022 12:16:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uK9ZgdqPfE3zk1r1xAYR/gkLSYwWqgZ0KxmtnGXKNmst6oVX6gxyHEgwgQ8+oFkUhBuslu X-Received: by 2002:a05:6402:d0a:b0:425:d455:452 with SMTP id eb10-20020a0564020d0a00b00425d4550452mr12678476edb.259.1656011763063; Thu, 23 Jun 2022 12:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011763; cv=none; d=google.com; s=arc-20160816; b=r8tX3NuIMo14EsMKsS/g3r/XWZ2p5jXn3YWV2tGLQS+tu0HPjQM2Nxox/wOh8AvMTk 69pWu0kWdWRiyyxO/kEyuL+9ZzMbpNtNFHHOZmk6NXI7hr4uEc+qqGUimXwBuDDeDL8/ dbyJ/T+3k0DcLs4dRWUUUIqDQxol0c454r8t0BO9Ir51L3amMeqW3glyGG2UYHcLNmHX fsuzsXwhdoLrf+ZJsR1XoZvJZgLSH7V33HuyYMnslcSmpH+TO2G8aXu5Zs74vOgm2zvV ZCDwzC9nwH/34NMDRQM+U3FtbjOYDv7kEBcx5luR+S1yXFN5c8YC8gBUHC/ZehPlsTAq CCHg== 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=SCEMO8T6q43koky8ht1Po+98VQjCDtjTQhHpPXSHXAxoSDHdsYwrZZ1uuFWcJ/pDgV 49UiA/Nn+lUYNgZ2JMzKNaGBSNc2eMKaeYueZspXiR/hWBdEefV21szKuRX3W/ATYMr0 Lf7rNb6qGB295sm7CsFyn19U0NfNaBPPJdhFX2UqXPZrztmnTi3w1D30zgExtdn4F6bD 4INwooMIjtdx4u7VuNoX7vW11eoXyJ8Q+06bd2wbYROtk/SgCNnJLa8gGxcMMXCy6fvf nEsWN1F3gb7dW3GqJfOgKtl5AmN3okDcPw0InRRjdOp0oAEW2iDVu34lG75H0AWtF36B jlCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RlS85rlf; 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 f19-20020a50d553000000b0042b370f9819si334515edj.552.2022.06.23.12.15.38; Thu, 23 Jun 2022 12:16:03 -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=RlS85rlf; 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 S237049AbiFWSUV (ORCPT + 99 others); Thu, 23 Jun 2022 14:20:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236726AbiFWSR0 (ORCPT ); Thu, 23 Jun 2022 14:17:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F269482687; Thu, 23 Jun 2022 10:23:42 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3F808B824B8; Thu, 23 Jun 2022 17:23:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E2BBC3411B; Thu, 23 Jun 2022 17:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005020; bh=E0lgWaK+wTrtgx+NOHmYoyAHE5JLXtccaud7lMVI+84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RlS85rlfjdo1Cp6/fOtlwvn14MuxZSHC54rhGdPTMe56rRQCA8/tekbb02mc3ACJ1 rcgi6MfH1LwHF/rqD8uCgskLtpUsLQdCk1QLCsuVAzKcKo5veMRj2wuKBS5K03Urr3 oE4dwYEAzIy5a4o0xQRy0nDS8B+ojgEsu1oc0nIs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marian Postevca Subject: [PATCH 4.19 226/234] usb: gadget: u_ether: fix regression in setting fixed MAC address Date: Thu, 23 Jun 2022 18:44:53 +0200 Message-Id: <20220623164349.444968307@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@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);