Return-Path: Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Johan Hovold" , "Greg Kroah-Hartman" Date: Thu, 11 Sep 2014 13:32:13 +0100 Message-ID: Subject: [PATCH 3.2 094/131] USB: serial: fix potential heap buffer overflow In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: 3.2.63-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold 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 Signed-off-by: Greg Kroah-Hartman [bwh: Backported to 3.2: s/ddev/\&interface->dev/] Signed-off-by: Ben Hutchings --- drivers/usb/serial/usb-serial.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -888,6 +888,11 @@ int usb_serial_probe(struct usb_interfac 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;