[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1312251002020.9215-100000@netrider.rowland.org>
Date: Wed, 25 Dec 2013 10:07:33 -0500 (EST)
From: Alan Stern <stern@...land.harvard.edu>
To: "Du, ChangbinX" <changbinx.du@...el.com>
cc: "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"sarah.a.sharp@...ux.intel.com" <sarah.a.sharp@...ux.intel.com>,
"Lan, Tianyu" <tianyu.lan@...el.com>,
"burzalodowa@...il.com" <burzalodowa@...il.com>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] usb/core: fix NULL pointer dereference in
recursively_mark_NOTATTACHED
On Tue, 24 Dec 2013, Alan Stern wrote:
> > This is my analysis, how do you think?
>
> There is another reason why usb_hub_to_struct_hub() could return NULL:
> if usb_get_intfdata(hdev->actconfig->interface[0]) is NULL. This could
> happen if recursively_mark_NOTATTACHED() is called _while_
> hub_disconnect() is running.
>
> There should be locking to prevent this, but there isn't. That's what
> we need to fix. It's not an easy problem. Can you figure out a
> correct solution?
I think this will fix it. Take a close look and do some careful
testing.
Alan Stern
Index: usb-3.13/drivers/usb/core/hub.c
===================================================================
--- usb-3.13.orig/drivers/usb/core/hub.c
+++ usb-3.13/drivers/usb/core/hub.c
@@ -1622,11 +1622,14 @@ static void hub_disconnect(struct usb_in
hub->error = 0;
hub_quiesce(hub, HUB_DISCONNECT);
- usb_set_intfdata (intf, NULL);
-
for (i = 0; i < hdev->maxchild; i++)
usb_hub_remove_port_device(hub, i + 1);
+
+ /* Avoid races with recursively_mark_NOTATTACHED() */
+ spin_lock_irq(&device_state_lock);
hub->hdev->maxchild = 0;
+ usb_set_intfdata(intf, NULL);
+ spin_unlock_irq(&device_state_lock);
if (hub->hdev->speed == USB_SPEED_HIGH)
highspeed_hubs--;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists