Messages in this thread | | | Date | Wed, 4 Dec 2013 10:21:07 -0500 (EST) | From | Alan Stern <> | Subject | Re: [PATCH] usb: core: Abort deauthorization if unsetting configuration fails |
| |
On Tue, 3 Dec 2013, Julius Werner wrote:
> usb_deauthorize_device() tries to unset the configuration of a USB > device and then unconditionally blows away the configuration descriptors > with usb_destroy_configuration(). This is bad if the > usb_set_configuration() call failed before the configuration could be > correctly unset, since pointers like udev->actconfig can keep pointing > to the now invalid memory. We have encountered hard to reproduce crashes > from devices disconnected during suspend due to this, where khubd's > disconnect handling races with userspace tools that change authorization > on resume. > > This patch ensures that usb_deauthorize_device() aborts when > usb_set_configuration() fails, and the underlying status code (such as > ENODEV) is returned to userspace.
I don't like this approach at all. It should always be possible to deauthorize a device, no matter what.
Instead, how about changing usb_set_configuration() so that it will never fail when the new config is -1? Except perhaps for -ENODEV errors (the device has been disconnected), which usb_deauthorize_device() could check for.
Alan Stern
| |