From: Lukas Wunner <lukas@wunner.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Oliver Neukum <oneukum@suse.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jann Horn <jannh@google.com>,
Oleksij Rempel <o.rempel@pengutronix.de>,
netdev@vger.kernel.org, linux-usb@vger.kernel.org,
Andrew Lunn <andrew@lunn.ch>, Eric Dumazet <edumazet@google.com>,
Jacky Chou <jackychou@asix.com.tw>, Willy Tarreau <w@1wt.eu>,
Lino Sanfilippo <LinoSanfilippo@gmx.de>,
Philipp Rosenberger <p.rosenberger@kunbus.com>,
Heiner Kallweit <hkallweit1@gmail.com>
Subject: Re: [PATCH] usbnet: Fix use-after-free on disconnect
Date: Sun, 17 Apr 2022 09:28:25 +0200 [thread overview]
Message-ID: <20220417072825.GA5737@wunner.de> (raw)
In-Reply-To: <YlgAd2bHWAJwgd8q@kroah.com>
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
next prev parent reply other threads:[~2022-04-17 7:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 14:16 [PATCH] usbnet: Fix use-after-free on disconnect Lukas Wunner
2022-04-13 18:59 ` Oliver Neukum
2022-04-14 10:58 ` Lukas Wunner
2022-04-14 11:07 ` Greg Kroah-Hartman
2022-04-17 7:28 ` Lukas Wunner [this message]
2022-04-14 11:20 ` Oliver Neukum
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=20220417072825.GA5737@wunner.de \
--to=lukas@wunner.de \
--cc=LinoSanfilippo@gmx.de \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hkallweit1@gmail.com \
--cc=jackychou@asix.com.tw \
--cc=jannh@google.com \
--cc=kuba@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=oneukum@suse.com \
--cc=p.rosenberger@kunbus.com \
--cc=pabeni@redhat.com \
--cc=w@1wt.eu \
/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;
as well as URLs for NNTP newsgroup(s).