USB: serial: fix potential heap buffer overflow

commit 5654699fb38512bdbfc0f892ce54fce75bdc2bab upstream.

Make sure to verify the number of ports requested by subdriver to avoid
writing beyond the end of fixed-size array in interface data.

The current usb-serial implementation is limited to eight ports per
interface but failed to verify that the number of ports requested by a
subdriver (which could have been determined from device descriptors) did
not exceed this limit.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[lizf: Backported to 3.4: s/ddev/\&interface->dev/]
Signed-off-by: Zefan Li <lizefan@huawei.com>
This commit is contained in:
Johan Hovold 2014-08-27 11:55:19 +02:00 committed by Zefan Li
parent 62148f769f
commit c804743181
1 changed files with 5 additions and 0 deletions

View File

@ -889,6 +889,11 @@ int usb_serial_probe(struct usb_interface *interface,
num_ports = type->num_ports;
}
if (num_ports > MAX_NUM_PORTS) {
dev_warn(&interface->dev, "too many ports requested: %d\n", num_ports);
num_ports = MAX_NUM_PORTS;
}
serial->num_ports = num_ports;
serial->num_bulk_in = num_bulk_in;
serial->num_bulk_out = num_bulk_out;