mirror of
https://github.com/S3NEO/android_kernel_samsung_msm8226.git
synced 2024-11-07 03:47:13 +00:00
add toggle for disabling newly added USB devices
Based on the public grsecurity patches. Change-Id: I2cbea91b351cda7d098f4e1aa73dff1acbd23cce Signed-off-by: Daniel Micay <danielmicay@gmail.com> Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
This commit is contained in:
parent
07bee0ffb8
commit
fcf033cefd
2 changed files with 21 additions and 0 deletions
|
@ -115,6 +115,8 @@ struct usb_hub {
|
|||
void **port_owners;
|
||||
};
|
||||
|
||||
int deny_new_usb = 0;
|
||||
|
||||
static inline int hub_is_superspeed(struct usb_device *hdev)
|
||||
{
|
||||
return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS);
|
||||
|
@ -3664,6 +3666,11 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
|
|||
return;
|
||||
}
|
||||
|
||||
if (deny_new_usb) {
|
||||
dev_err(hub_dev, "denied insert of USB device on port %d\n", port1);
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (i = 0; i < SET_CONFIG_TRIES; i++) {
|
||||
|
||||
/* reallocate for each attempt, since references
|
||||
|
|
|
@ -93,6 +93,9 @@
|
|||
#if defined(CONFIG_SYSCTL)
|
||||
|
||||
/* External variables not in a header file. */
|
||||
#ifdef CONFIG_USB
|
||||
extern int deny_new_usb;
|
||||
#endif
|
||||
extern int sysctl_overcommit_memory;
|
||||
extern int sysctl_overcommit_ratio;
|
||||
extern int max_threads;
|
||||
|
@ -733,6 +736,17 @@ static struct ctl_table kern_table[] = {
|
|||
.extra1 = &zero,
|
||||
.extra2 = &two,
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_USB
|
||||
{
|
||||
.procname = "deny_new_usb",
|
||||
.data = &deny_new_usb,
|
||||
.maxlen = sizeof(int),
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_minmax_sysadmin,
|
||||
.extra1 = &zero,
|
||||
.extra2 = &one,
|
||||
},
|
||||
#endif
|
||||
{
|
||||
.procname = "ngroups_max",
|
||||
|
|
Loading…
Reference in a new issue