public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Marian Postevca <posteuca@mutex.one>
Cc: Felipe Balbi <balbi@kernel.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: u_ether: fix race in setting MAC address in setup phase
Date: Sat, 4 Dec 2021 19:47:40 +0100	[thread overview]
Message-ID: <Yau3zDEdTiLZZkRp@kroah.com> (raw)
In-Reply-To: <87ee6sxlcj.fsf@mutex.one>

On Sat, Dec 04, 2021 at 08:42:52PM +0200, Marian Postevca wrote:
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> 
> > On Tue, Nov 30, 2021 at 12:12:29AM +0200, Marian Postevca wrote:
> >> When listening for notifications through netlink of a new interface being
> >> registered, sporadically, it is possible for the MAC to be read as zero.
> >> The zero MAC address lasts a short period of time and then switches to a
> >> valid random MAC address.
> >> 
> >> This causes problems for netd in Android, which assumes that the interface
> >> is malfunctioning and will not use it.
> >> 
> >> In the good case we get this log:
> >> InterfaceController::getCfg() ifName usb0
> >>  hwAddr 92:a8:f0:73:79:5b ipv4Addr 0.0.0.0 flags 0x1002
> >> 
> >> In the error case we get these logs:
> >> InterfaceController::getCfg() ifName usb0
> >>  hwAddr 00:00:00:00:00:00 ipv4Addr 0.0.0.0 flags 0x1002
> >> 
> >> netd : interfaceGetCfg("usb0")
> >> netd : interfaceSetCfg() -> ServiceSpecificException
> >>  (99, "[Cannot assign requested address] : ioctl() failed")
> >> 
> >> The reason for the issue is the order in which the interface is setup,
> >> it is first registered through register_netdev() and after the MAC
> >> address is set.
> >> 
> >> Fixed by first setting the MAC address of the net_device and after that
> >> calling register_netdev().
> >> 
> >> Signed-off-by: Marian Postevca <posteuca@mutex.one>
> >> ---
> >>  drivers/usb/gadget/function/u_ether.c | 16 ++++++----------
> >>  1 file changed, 6 insertions(+), 10 deletions(-)
> >
> > What commit does this fix?  Should it go to stable kernel releases?
> >
> > thanks,
> >
> > greg k-h
> 
> This fixes bcd4a1c40bee885e ("usb: gadget: u_ether: construct with
> default values and add setters/getters").
> 
> I think it should go to stable kernel releases.
> 
> Should I send a second version of the patch with a Fixes tag?

Yes please, and a cc: stable on the line after the fixes tag.

thanks,

greg k-h

      reply	other threads:[~2021-12-04 18:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-29 22:12 [PATCH] usb: gadget: u_ether: fix race in setting MAC address in setup phase Marian Postevca
2021-12-03 12:50 ` Greg Kroah-Hartman
2021-12-04 18:42   ` Marian Postevca
2021-12-04 18:47     ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yau3zDEdTiLZZkRp@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=balbi@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=posteuca@mutex.one \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox