From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2B16C433EF for ; Sun, 17 Apr 2022 07:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233545AbiDQHbF (ORCPT ); Sun, 17 Apr 2022 03:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbiDQHbE (ORCPT ); Sun, 17 Apr 2022 03:31:04 -0400 Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [83.223.95.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AC7BD61 for ; Sun, 17 Apr 2022 00:28:27 -0700 (PDT) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1" (verified OK)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id A48B630002421; Sun, 17 Apr 2022 09:28:25 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 97A665F05A; Sun, 17 Apr 2022 09:28:25 +0200 (CEST) Date: Sun, 17 Apr 2022 09:28:25 +0200 From: Lukas Wunner To: Greg Kroah-Hartman Cc: Oliver Neukum , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Jann Horn , Oleksij Rempel , netdev@vger.kernel.org, linux-usb@vger.kernel.org, Andrew Lunn , Eric Dumazet , Jacky Chou , Willy Tarreau , Lino Sanfilippo , Philipp Rosenberger , Heiner Kallweit Subject: Re: [PATCH] usbnet: Fix use-after-free on disconnect Message-ID: <20220417072825.GA5737@wunner.de> References: <127121d9d933ebe3fc13f9f91cc33363d6a8a8ac.1649859147.git.lukas@wunner.de> <614e6498-3c3e-0104-591e-8ea296dfd887@suse.com> <20220414105858.GA9106@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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