History

usb: core: add option of only authorizing internal devices

On Chrome OS we want to use USBguard to potentially limit access to USB devices based on policy. We however to do not want to wait for userspace to come up before initializing fixed USB devices to not regress our boot times. This patch adds option to instruct the kernel to only authorize devices connected to the internal ports. Previously we could either authorize all or none (or, by default, we'd only authorize wired devices). The behavior is controlled via usbcore.authorized_default command line option.

Dmitry Torokhov committed 7 years ago

Commit 7bae0431 parent ca942a05 files · +69 −32Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/usb/hcd.h+7−3
@@ -72,6 +72,12 @@ struct giveback_urb_bh { · 71 unmodified lines
72 struct usb_host_endpoint *completing_ep;72 struct usb_host_endpoint *completing_ep;
73};73};
74 74
75enum usb_dev_authorize_policy {
76 USB_DEVICE_AUTHORIZE_NONE = 0,
77 USB_DEVICE_AUTHORIZE_ALL = 1,
78 USB_DEVICE_AUTHORIZE_INTERNAL = 2,
79};
80
75struct usb_hcd {81struct usb_hcd {
76 82
77 /*83 /*
@@ -117,7 +123,6 @@ struct usb_hcd { · 39 unmodified lines
117#define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */123#define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */
118#define HCD_FLAG_DEAD 6 /* controller has died? */124#define HCD_FLAG_DEAD 6 /* controller has died? */
119#define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */125#define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */
120#define HCD_FLAG_DEV_AUTHORIZED 8 /* authorize devices? */
121 126
122 /* The flags can be tested using these macros; they are likely to127 /* The flags can be tested using these macros; they are likely to
123 * be slightly faster than test_bit().128 * be slightly faster than test_bit().
@@ -142,8 +147,7 @@ struct usb_hcd { · 18 unmodified lines
142 * or they require explicit user space authorization; this bit is147 * or they require explicit user space authorization; this bit is
143 * settable through /sys/class/usb_host/X/authorized_default148 * settable through /sys/class/usb_host/X/authorized_default
144 */149 */
145#define HCD_DEV_AUTHORIZED(hcd) \150 enum usb_dev_authorize_policy dev_policy;
146 ((hcd)->flags & (1U << HCD_FLAG_DEV_AUTHORIZED))
147 151
148 /* Flags that get set only during HCD registration or removal. */152 /* Flags that get set only during HCD registration or removal. */
149 unsigned rh_registered:1;/* is root hub registered? */153 unsigned rh_registered:1;/* is root hub registered? */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t