RFC/patch 1/6: wusb: add authorization control for devices
Inaky Perez-Gonzalez <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Organization | Intel Corporation |
| Message-ID | <[email protected]> |
# HG changeset patch # User Inaky Perez-Gonzalez <[email protected]> # Date 1177378585 25200 # Node ID caf1be8549a3874d10978af31930b587566dd4f1 # Parent 67b01ce175a4afd1881bec0177a7fcba02bda61f wusb: add authorization control for devices This patch introduces 'struct usb_device'->authorized. Devices with that bit set can be used in the system (drivers are allow to attach). Devices that don't will have the usb_probe routine aborting driver binding. This is needed for WUSB devices: until we don't do the crypto handshake, we can't allow the device to be used -- but in the meantime, we need to be able to talk to it's default endpoint. It is also usable to implement a system lockdown from software. This still requires further code to manage lockdown and authorize devices. Signed-off-by: Inaky Perez-Gonzalez <[email protected]> diff -r 67b01ce175a4 -r caf1be8549a3 drivers/usb/core/driver.c --- a/drivers/usb/core/driver.c Tue Apr 17 16:51:32 2007 -0700 +++ b/drivers/usb/core/driver.c Mon Apr 23 18:36:25 2007 -0700 @@ -162,6 +162,11 @@ static int usb_probe_device(struct devic udev = to_usb_device(dev); + if (udev->authorized == 0) { + dev_err(&udev->dev, "Device is not authorized for usage\n"); + return -ENODEV; + } + /* TODO: Add real matching code */ /* The device should always appear to be in use @@ -199,6 +204,11 @@ static int usb_probe_interface(struct de intf = to_usb_interface(dev); udev = interface_to_usbdev(intf); + + if (udev->authorized == 0) { + dev_err(&intf->dev, "Device is not authorized for usage\n"); + return -ENODEV; + } id = usb_match_id(intf, driver->id_table); if (!id) diff -r 67b01ce175a4 -r caf1be8549a3 drivers/usb/core/hub.c --- a/drivers/usb/core/hub.c Tue Apr 17 16:51:32 2007 -0700 +++ b/drivers/usb/core/hub.c Mon Apr 23 18:36:25 2007 -0700 @@ -1464,8 +1464,10 @@ static int hub_port_wait_reset(struct us /* if we`ve finished resetting, then break out of the loop */ if (!(portstatus & USB_PORT_STAT_RESET) && (portstatus & USB_PORT_STAT_ENABLE)) { - if (hub_is_wusb(hub)) + if (hub_is_wusb(hub)) { udev->speed = USB_SPEED_VARIABLE; + udev->authorized = 0; + } else if (portstatus & USB_PORT_STAT_HIGH_SPEED) udev->speed = USB_SPEED_HIGH; else if (portstatus & USB_PORT_STAT_LOW_SPEED) diff -r 67b01ce175a4 -r caf1be8549a3 drivers/usb/core/usb.c --- a/drivers/usb/core/usb.c Tue Apr 17 16:51:32 2007 -0700 +++ b/drivers/usb/core/usb.c Mon Apr 23 18:36:25 2007 -0700 @@ -319,6 +319,7 @@ usb_alloc_dev(struct usb_device *parent, INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); dev->autosuspend_delay = usb_autosuspend_delay * HZ; #endif + dev->authorized = 1; /* If WUSB, will default to NOT auth */ return dev; } diff -r 67b01ce175a4 -r caf1be8549a3 include/linux/usb.h --- a/include/linux/usb.h Tue Apr 17 16:51:32 2007 -0700 +++ b/include/linux/usb.h Mon Apr 23 18:36:25 2007 -0700 @@ -331,6 +331,11 @@ struct usb_tt; * * Usbcore drivers should not set usbdev->state directly. Instead use * usb_set_device_state(). + * + * @authorized: (user space) policy determines if we authorize this + * device to be used or not. By default, wired USB + * devices are authorized. WUSB devices are not, until we + * authorize them from user space. FIXME -- complete doc */ struct usb_device { int devnum; /* Address on USB bus */ @@ -365,6 +370,7 @@ struct usb_device { unsigned discon_suspended:1; /* Disconnected while suspended */ unsigned have_langid:1; /* whether string_langid is valid */ + unsigned authorized:1; /* Policy has determined we can use it */ int string_langid; /* language ID for strings */ /* static strings from the device */ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel