diff options
author | Johan Hovold <johan@kernel.org> | 2014-08-27 05:55:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-08-27 16:23:52 -0400 |
commit | 5654699fb38512bdbfc0f892ce54fce75bdc2bab (patch) | |
tree | f5f75a1cdf069e08e83f4876b460243941043ecc | |
parent | d979e9f9ecab04c1ecca741370e30a8a498893f5 (diff) |
USB: serial: fix potential heap buffer overflow
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.
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index eb0e8c6a8682..475723c006f9 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -862,6 +862,11 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
862 | num_ports = type->num_ports; | 862 | num_ports = type->num_ports; |
863 | } | 863 | } |
864 | 864 | ||
865 | if (num_ports > MAX_NUM_PORTS) { | ||
866 | dev_warn(ddev, "too many ports requested: %d\n", num_ports); | ||
867 | num_ports = MAX_NUM_PORTS; | ||
868 | } | ||
869 | |||
865 | serial->num_ports = num_ports; | 870 | serial->num_ports = num_ports; |
866 | serial->num_bulk_in = num_bulk_in; | 871 | serial->num_bulk_in = num_bulk_in; |
867 | serial->num_bulk_out = num_bulk_out; | 872 | serial->num_bulk_out = num_bulk_out; |