lkml.org 
[lkml]   [2013]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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



\
 
 \ /
  Last update: 2013-12-04 16:41    [W:0.080 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site