linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] USB: serial: Add boundry check for read_urbs array access
@ 2018-03-07 20:23 sathyanarayanan.kuppuswamy
  2018-03-07 20:58 ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: sathyanarayanan.kuppuswamy @ 2018-03-07 20:23 UTC (permalink / raw)
  To: gregkh, johan; +Cc: linux-usb, linux-kernel, Kuppuswamy Sathyanarayanan

From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

In usb_serial_generic_submit_read_urb() function we are accessing the
port->read_urbs array without any boundry checks. This might lead to
kernel panic when index value goes above array length.

One posible call path for this issue is,

usb_serial_generic_read_bulk_callback()
{
 ...
 if (!port->throttled) {
	usb_serial_generic_submit_read_urb(port, i, GFP_ATOMIC);
 ...
}

This patch fixes this issue.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---
 drivers/usb/serial/generic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 2274d96..72ebdde 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -306,6 +306,9 @@ static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port,
 {
 	int res;
 
+	if (index >= ARRAY_SIZE(port->read_urbs))
+		return -EINVAL;
+
 	if (!test_and_clear_bit(index, &port->read_urbs_free))
 		return 0;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-03-09  0:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07 20:23 [PATCH v1 1/1] USB: serial: Add boundry check for read_urbs array access sathyanarayanan.kuppuswamy
2018-03-07 20:58 ` Greg KH
2018-03-07 21:41   ` sathyanarayanan kuppuswamy
2018-03-08  8:54     ` Oliver Neukum
2018-03-08 23:29       ` sathyanarayanan kuppuswamy
2018-03-08 23:43         ` Greg KH
2018-03-09  0:34           ` sathyanarayanan kuppuswamy
2018-03-08 14:01     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).