[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220417072825.GA5737@wunner.de>
Date: Sun, 17 Apr 2022 09:28:25 +0200
From: Lukas Wunner <lukas@...ner.de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Oliver Neukum <oneukum@...e.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Jann Horn <jannh@...gle.com>,
Oleksij Rempel <o.rempel@...gutronix.de>,
netdev@...r.kernel.org, linux-usb@...r.kernel.org,
Andrew Lunn <andrew@...n.ch>,
Eric Dumazet <edumazet@...gle.com>,
Jacky Chou <jackychou@...x.com.tw>, Willy Tarreau <w@....eu>,
Lino Sanfilippo <LinoSanfilippo@....de>,
Philipp Rosenberger <p.rosenberger@...bus.com>,
Heiner Kallweit <hkallweit1@...il.com>
Subject: Re: [PATCH] usbnet: Fix use-after-free on disconnect
On Thu, Apr 14, 2022 at 01:07:35PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Apr 14, 2022 at 12:58:58PM +0200, Lukas Wunner wrote:
> > On Wed, Apr 13, 2022 at 08:59:48PM +0200, Oliver Neukum wrote:
> > > On 13.04.22 16:16, Lukas Wunner wrote:
> > > > --- a/drivers/net/usb/usbnet.c
> > > > +++ b/drivers/net/usb/usbnet.c
> > > > @@ -469,6 +469,9 @@ static enum skb_state defer_bh(struct usbnet *dev, struct sk_buff *skb,
> > > > */
> > > > void usbnet_defer_kevent (struct usbnet *dev, int work)
> > > > {
> > > > + if (dev->intf->condition == USB_INTERFACE_UNBINDING)
> > > > + return;
> > >
> > > But, no, you cannot do this. This is a very blatant layering violation.
> > > You cannot use states internal to usb core like that in a driver.
> >
> > Why do you think it's internal?
> >
> > enum usb_interface_condition is defined in include/linux/usb.h
> > for everyone to see and use. If it was meant to be private,
> > I'd expect it to be marked as such or live in drivers/usb/core/usb.h.
>
> Because we didn't think people would do crazy things like this.
I assume "crazy things" encompasses reading and writing intf->condition
without any locking or explicit memory barriers. However many drivers
do that through the exported functions:
usb_reset_device()
usb_lock_device_for_reset()
usb_driver_claim_interface()
usb_driver_release_interface()
In any case, I've decided to pursue a different approach which fixes the
issue in core networking code rather than usbnet. USB Ethernet may not
be the only culprit after all. A replacement patch superseding this one
was just submitted:
https://lore.kernel.org/netdev/18b3541e5372bc9b9fc733d422f4e698c089077c.1650177997.git.lukas@wunner.de
Thanks,
Lukas
Powered by blists - more mailing lists