Skip to content

Commit 5a07975

Browse files
oneukumgregkh
authored andcommitted
USB: digi_acceleport: do sanity checking for the number of ports
The driver can be crashed with devices that expose crafted descriptors with too few endpoints. See: http://seclists.org/bugtraq/2016/Mar/61 Signed-off-by: Oliver Neukum <ONeukum@suse.com> [johan: fix OOB endpoint check and add error messages ] Cc: stable <stable@vger.kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c55aee1 commit 5a07975

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Diff for: drivers/usb/serial/digi_acceleport.c

+19
Original file line numberDiff line numberDiff line change
@@ -1251,8 +1251,27 @@ static int digi_port_init(struct usb_serial_port *port, unsigned port_num)
12511251

12521252
static int digi_startup(struct usb_serial *serial)
12531253
{
1254+
struct device *dev = &serial->interface->dev;
12541255
struct digi_serial *serial_priv;
12551256
int ret;
1257+
int i;
1258+
1259+
/* check whether the device has the expected number of endpoints */
1260+
if (serial->num_port_pointers < serial->type->num_ports + 1) {
1261+
dev_err(dev, "OOB endpoints missing\n");
1262+
return -ENODEV;
1263+
}
1264+
1265+
for (i = 0; i < serial->type->num_ports + 1 ; i++) {
1266+
if (!serial->port[i]->read_urb) {
1267+
dev_err(dev, "bulk-in endpoint missing\n");
1268+
return -ENODEV;
1269+
}
1270+
if (!serial->port[i]->write_urb) {
1271+
dev_err(dev, "bulk-out endpoint missing\n");
1272+
return -ENODEV;
1273+
}
1274+
}
12561275

12571276
serial_priv = kzalloc(sizeof(*serial_priv), GFP_KERNEL);
12581277
if (!serial_priv)

0 commit comments

Comments
 (0)