Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
5654699f d979e9f9

+5
+5
drivers/usb/serial/usb-serial.c
··· 862 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 870 serial->num_ports = num_ports; 866 871 serial->num_bulk_in = num_bulk_in; 867 872 serial->num_bulk_out = num_bulk_out;