Re: [PATCH] usb: core: get config and string descriptors for unauthorized devices

2014-01-07 Thread Julius Werner
Hi, has there been any movement on this patch? It happens to fix a problem
that we have been experiencing with races between authorize/deauthorize and
device removal. I'd like to know if this is going to be considered for merge
or if I'll have to look elsewhere for a solution.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: core: get config and string descriptors for unauthorized devices

2014-01-07 Thread Greg KH
On Tue, Jan 07, 2014 at 01:21:15PM -0800, Julius Werner wrote:
 Hi, has there been any movement on this patch? It happens to fix a problem
 that we have been experiencing with races between authorize/deauthorize and
 device removal.

You are using wireless usb?

 I'd like to know if this is going to be considered for merge or if
 I'll have to look elsewhere for a solution.

It's queued up for 3.14-rc1 (you can always check linux-next for this
type of thing...)  Do you also need/want this in older (i.e. stable)
kernel releases?

thanks,

greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: core: get config and string descriptors for unauthorized devices

2014-01-07 Thread Julius Werner
 I'd like to know if this is going to be considered for merge or if
 I'll have to look elsewhere for a solution.

 It's queued up for 3.14-rc1 (you can always check linux-next for this
 type of thing...)  Do you also need/want this in older (i.e. stable)
 kernel releases?

Oh right... sorry, I should've had a closer look first. (I guess
Google doesn't index git.kernel.org that well or I would've found it.)
I personally don't care about the stable backport, but it does work
around a rare use-after-free bug of the udev-config pointer (when the
usb_set_configuration(-1) in usb_deauthorize_device() fails because
the device is already unplugged, but it still runs
usb_destroy_configuration() afterwards), so you might want to consider
it.

 You are using wireless usb?

Nope, but we are using the sysfs authorized node to force a
reconfiguration and driver rebinding in certain cases.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: core: get config and string descriptors for unauthorized devices

2013-12-09 Thread Thomas Pugliese
There is no need to skip querying the config and string descriptors for 
unauthorized WUSB devices when usb_new_device is called.  It is allowed 
by WUSB spec.  The only action that needs to be delayed until 
authorization time is the set config.  This change allows user mode 
tools to see the config and string descriptors earlier in enumeration 
which is needed for some WUSB devices to function properly on Android 
systems.  It also reduces the amount of divergent code paths needed 
for WUSB devices.

Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com
---
 drivers/usb/core/config.c |7 ---
 drivers/usb/core/hub.c|   39 +++
 2 files changed, 7 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index a6b2cab..548d199 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -651,10 +651,6 @@ void usb_destroy_configuration(struct usb_device *dev)
  *
  * hub-only!! ... and only in reset path, or usb_new_device()
  * (used by real hubs and virtual root hubs)
- *
- * NOTE: if this is a WUSB device and is not authorized, we skip the
- *   whole thing. A non-authorized USB device has no
- *   configurations.
  */
 int usb_get_configuration(struct usb_device *dev)
 {
@@ -666,8 +662,6 @@ int usb_get_configuration(struct usb_device *dev)
struct usb_config_descriptor *desc;
 
cfgno = 0;
-   if (dev-authorized == 0)   /* Not really an error */
-   goto out_not_authorized;
result = -ENOMEM;
if (ncfg  USB_MAXCONFIG) {
dev_warn(ddev, too many configurations: %d, 
@@ -751,7 +745,6 @@ int usb_get_configuration(struct usb_device *dev)
 
 err:
kfree(desc);
-out_not_authorized:
dev-descriptor.bNumConfigurations = cfgno;
 err2:
if (result == -ENOMEM)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a7c04e2..32e1035 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2235,17 +2235,13 @@ static int usb_enumerate_device(struct usb_device *udev)
return err;
}
}
-   if (udev-wusb == 1  udev-authorized == 0) {
-   udev-product = kstrdup(n/a (unauthorized), GFP_KERNEL);
-   udev-manufacturer = kstrdup(n/a (unauthorized), GFP_KERNEL);
-   udev-serial = kstrdup(n/a (unauthorized), GFP_KERNEL);
-   } else {
-   /* read the standard strings and cache them if present */
-   udev-product = usb_cache_string(udev, 
udev-descriptor.iProduct);
-   udev-manufacturer = usb_cache_string(udev,
- 
udev-descriptor.iManufacturer);
-   udev-serial = usb_cache_string(udev, 
udev-descriptor.iSerialNumber);
-   }
+
+   /* read the standard strings and cache them if present */
+   udev-product = usb_cache_string(udev, udev-descriptor.iProduct);
+   udev-manufacturer = usb_cache_string(udev,
+ udev-descriptor.iManufacturer);
+   udev-serial = usb_cache_string(udev, udev-descriptor.iSerialNumber);
+
err = usb_enumerate_device_otg(udev);
if (err  0)
return err;
@@ -2427,16 +2423,6 @@ int usb_deauthorize_device(struct usb_device *usb_dev)
usb_dev-authorized = 0;
usb_set_configuration(usb_dev, -1);
 
-   kfree(usb_dev-product);
-   usb_dev-product = kstrdup(n/a (unauthorized), GFP_KERNEL);
-   kfree(usb_dev-manufacturer);
-   usb_dev-manufacturer = kstrdup(n/a (unauthorized), GFP_KERNEL);
-   kfree(usb_dev-serial);
-   usb_dev-serial = kstrdup(n/a (unauthorized), GFP_KERNEL);
-
-   usb_destroy_configuration(usb_dev);
-   usb_dev-descriptor.bNumConfigurations = 0;
-
 out_unauthorized:
usb_unlock_device(usb_dev);
return 0;
@@ -2464,17 +2450,7 @@ int usb_authorize_device(struct usb_device *usb_dev)
goto error_device_descriptor;
}
 
-   kfree(usb_dev-product);
-   usb_dev-product = NULL;
-   kfree(usb_dev-manufacturer);
-   usb_dev-manufacturer = NULL;
-   kfree(usb_dev-serial);
-   usb_dev-serial = NULL;
-
usb_dev-authorized = 1;
-   result = usb_enumerate_device(usb_dev);
-   if (result  0)
-   goto error_enumerate;
/* Choose and set the configuration.  This registers the interfaces
 * with the driver core and lets interface drivers bind to them.
 */
@@ -2490,7 +2466,6 @@ int usb_authorize_device(struct usb_device *usb_dev)
}
dev_info(usb_dev-dev, authorized to connect\n);
 
-error_enumerate:
 error_device_descriptor:
usb_autosuspend_device(usb_dev);
 error_autoresume:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at