diff options
author | Johan Hovold <johan@kernel.org> | 2014-08-27 11:55:19 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-10-05 14:52:13 -0700 |
commit | 78107561549eafdcbf85415902b9db0d1d418718 (patch) | |
tree | 5e3232855e39ec7c9b24eace73313783d038da75 /drivers/usb | |
parent | 61fd69fcfa96cbe4d2923036870b0fac826d0db8 (diff) | |
download | linux-stable-78107561549eafdcbf85415902b9db0d1d418718.tar.gz linux-stable-78107561549eafdcbf85415902b9db0d1d418718.tar.bz2 linux-stable-78107561549eafdcbf85415902b9db0d1d418718.zip |
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>
Diffstat (limited to 'drivers/usb')
-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 998eee67f654..9a08e18e09b9 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, num_ports = type->num_ports; } + if (num_ports > MAX_NUM_PORTS) { + dev_warn(ddev, "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; |