Skip to content

Commit c4fc234

Browse files
hailfingergregkh
authored andcommitted
USB: Add "authorized_default" parameter to the usbcore module
The "authorized_default" module parameter of usbcore controls the default for the authorized_default variable of each USB host controller. -1 is authorized for all devices except wireless (default, old behaviour) 0 is unauthorized for all devices 1 is authorized for all devices Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 6806817 commit c4fc234

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Documentation/kernel-parameters.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
25382538
unknown_nmi_panic
25392539
[X86] Cause panic on unknown NMI.
25402540

2541+
usbcore.authorized_default=
2542+
[USB] Default USB device authorization:
2543+
(default -1 = authorized except for wireless USB,
2544+
0 = not authorized, 1 = authorized)
2545+
25412546
usbcore.autosuspend=
25422547
[USB] The autosuspend time delay (in seconds) used
25432548
for newly-detected USB devices (default 2). This

drivers/usb/core/hcd.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,17 @@ static const u8 ss_rh_config_descriptor[] = {
337337
0x02, 0x00 /* __le16 ss_wBytesPerInterval; 15 bits for max 15 ports */
338338
};
339339

340+
/* authorized_default behaviour:
341+
* -1 is authorized for all devices except wireless (old behaviour)
342+
* 0 is unauthorized for all devices
343+
* 1 is authorized for all devices
344+
*/
345+
static int authorized_default = -1;
346+
module_param(authorized_default, int, S_IRUGO|S_IWUSR);
347+
MODULE_PARM_DESC(authorized_default,
348+
"Default USB device authorization: 0 is not authorized, 1 is "
349+
"authorized, -1 is authorized except for wireless USB (default, "
350+
"old behaviour");
340351
/*-------------------------------------------------------------------------*/
341352

342353
/**
@@ -2371,7 +2382,11 @@ int usb_add_hcd(struct usb_hcd *hcd,
23712382

23722383
dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
23732384

2374-
hcd->authorized_default = hcd->wireless? 0 : 1;
2385+
/* Keep old behaviour if authorized_default is not in [0, 1]. */
2386+
if (authorized_default < 0 || authorized_default > 1)
2387+
hcd->authorized_default = hcd->wireless? 0 : 1;
2388+
else
2389+
hcd->authorized_default = authorized_default;
23752390
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
23762391

23772392
/* HC is in reset state, but accessible. Now do the one-time init,

0 commit comments

Comments
 (0)