USB: usb_driver_claim_interface: add sanity checking
Subsystems (5)
PATCH 1/10 USB: usb_driver_claim_interface: add sanity checking
From: Oliver Neukum <[email protected]>
Attacks that trick drivers into passing a NULL pointer to usb_driver_claim_interface() using forged descriptors are known. This thwarts them by sanity checking.
--- drivers/usb/core/driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/core/driver.c +5 -1
@@ -502,11 +502,15 @@ static int usb_unbind_interface(struct device *dev)int usb_driver_claim_interface (struct usb_driver *driver,struct usb_interface *iface,void *priv) { -struct device *dev = &iface->dev; +struct device *dev;struct usb_device *udev;int retval =0 ;int lpm_disable_error; +if (!iface) +return -ENODEV ; + + dev = &iface->dev;if (dev->driver)return -EBUSY ;
Signature · 1 line
2.1.4
PATCH 2/10 USB: cdc-acm: more sanity checking
From: Oliver Neukum <[email protected]>
An attack has become available which pretends to be a quirky device circumventing normal sanity checks and crashes the kernel by an insufficient number of interfaces. This patch adds a check to the code path for quirky devices.
--- drivers/usb/class/cdc-acm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/class/cdc-acm.c +3 -0
@@ -1179,6 +1179,9 @@ static int acm_probe(struct usb_interface *intf,if (quirks ==NO_UNION_NORMAL ) { data_interface =usb_ifnum_to_if (usb_dev,1 ); control_interface =usb_ifnum_to_if (usb_dev,0 ); +/* we would crash */ +if (!data_interface || !control_interface) +return -ENODEV ; goto skip_normal_probe; }
Signature · 1 line
2.1.4
PATCH 3/10 USB: uas: Reduce can_queue to MAX_CMNDS
In reply to Lu BaoluFrom: Hans de Goede <[email protected]>
The uas driver can never queue more then MAX_CMNDS (- 1) tags and tags are shared between luns, so there is no need to claim that we can_queue some random large number.
Not claiming that we can_queue 65536 commands, fixes the uas driver failing to initialize while allocating the tag map with a "Page allocation failure (order 7)" error on systems which have been running for a while and thus have fragmented memory.
--- drivers/usb/storage/uas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/uas.c +1 -1
@@ -836,7 +836,7 @@ static struct scsi_host_template uas_host_template = { .slave_configure = uas_slave_configure, .eh_abort_handler = uas_eh_abort_handler, .eh_bus_reset_handler = uas_eh_bus_reset_handler, - .can_queue = 65536, /* Is there a limit on the _host_ ? */ + .can_queue = MAX_CMNDS, .this_id = -1, .sg_tablesize = SG_NONE, .skip_settle_delay = 1,
Signature · 1 line
2.1.4
I am sorry. This email was sent out due to an incorrect operation. Please ignore it. I am sorry for disturbing you.
Best regards,
Baolu
Quoted 34 lines · Lu Baolu
From: Oliver Neukum <[email protected]>
Attacks that trick drivers into passing a NULL pointer to
usb_driver_claim_interface()using forged descriptors are known. This thwarts them by sanity checking.Signed-off-by Oliver Neukum <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/usb/core/driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/usb/core/driver.c +5
-1@@ -502,11 +502,15 @@ static int usb_unbind_interface(struct device *dev)int usb_driver_claim_interface (struct usb_driver *driver,struct usb_interface *iface,void *priv) { -struct device *dev = &iface->dev; +struct device *dev;struct usb_device *udev;int retval =0 ;int lpm_disable_error; +if (!iface) +return -ENODEV ; + + dev = &iface->dev;if (dev->driver)return -EBUSY ;
Re: [PATCH 02/10] USB: cdc-acm: more sanity checking
In reply to Lu BaoluI am sorry. This email was sent out due to an incorrect operation. Please ignore it. I am sorry for disturbing you.
Best regards,
Baolu
Quoted 28 lines · Lu Baolu
From: Oliver Neukum <[email protected]>
An attack has become available which pretends to be a quirky device circumventing normal sanity checks and crashes the kernel by an insufficient number of interfaces. This patch adds a check to the code path for quirky devices.
Signed-off-by Oliver Neukum <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/usb/class/cdc-acm.c | 3 +++ 1 file changed, 3 insertions(+)drivers/usb/class/cdc-acm.c +3
-0@@ -1179,6 +1179,9 @@ static int acm_probe(struct usb_interface *intf,if (quirks ==NO_UNION_NORMAL ) { data_interface =usb_ifnum_to_if (usb_dev,1 ); control_interface =usb_ifnum_to_if (usb_dev,0 ); +/* we would crash */ +if (!data_interface || !control_interface) +return -ENODEV ; goto skip_normal_probe; }
Re: [PATCH 03/10] USB: uas: Reduce can_queue to MAX_CMNDS
In reply to Lu BaoluI am sorry. This email was sent out due to an incorrect operation. Please ignore it. I am sorry for disturbing you.
Best Regards,
Baolu
Quoted 32 lines · Lu Baolu
From: Hans de Goede <[email protected]>
The uas driver can never queue more then
MAX_CMNDS(- 1) tags and tags are shared between luns, so there is no need to claim that wecan_queuesome random large number.Not claiming that we
can_queue65536 commands, fixes the uas driver failing to initialize while allocating the tag map with a "Page allocation failure (order 7)" error on systems which have been running for a while and thus have fragmented memory.Reported-and-tested-by Yves-Alexis Perez <[email protected]>Signed-off-by Hans de Goede <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/usb/storage/uas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/storage/uas.c +1
-1@@ -836,7 +836,7 @@ static struct scsi_host_template uas_host_template = { .slave_configure = uas_slave_configure, .eh_abort_handler = uas_eh_abort_handler, .eh_bus_reset_handler = uas_eh_bus_reset_handler, - .can_queue = 65536, /* Is there a limit on the _host_ ? */ + .can_queue = MAX_CMNDS, .this_id = -1, .sg_tablesize = SG_NONE, .skip_settle_delay = 1,