Skip to contentSkip to conversation

mct_u232: sanity checking in probe

PATCH In review Oliver Neukum 2 participants 2 messages Mar 16, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mct_u232: sanity checking in probe

An attack using the lack of sanity checking in probe is known. This patch checks for the existance of a second port.
CVE-2016-3136

---
 drivers/usb/serial/mct_u232.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/serial/mct_u232.c +4 -0
index fd707d6..d6a36b1 100644
@@ -378,6 +378,10 @@ static int mct_u232_port_probe(struct usb_serial_port *port)
 {
 	struct mct_u232_private *priv;
 
+	/* check first to simplify error handling */
+	if (!port->serial->port[1])
+		return -ENODEV;
+
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
Signature · 1 line
2.1.4
maintainer
#1 lore raw
Quoted 16 lines · Oliver Neukum

An attack using the lack of sanity checking in probe is known. This patch checks for the existance of a second port.
CVE-2016-3136

---
 drivers/usb/serial/mct_u232.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/serial/mct_u232.c +0 -0
index fd707d6..d6a36b1 100644

drivers/usb/serial/mct_u232.c static int mct_u232_port_probe(struct usb_serial_port *port) · line 384

Quoted 7 lines
drivers/usb/serial/mct_u232.c +4 -0
@@ -378,6 +378,10 @@ static int mct_u232_port_probe(struct usb_serial_port *port)
 {
 	struct mct_u232_private *priv;
 
+	/* check first to simplify error handling */
+	if (!port->serial->port[1])
+		return -ENODEV;
+

This check is not sufficient as the second port's interrupt-in urb is also unconditionally dereferenced below. Care to fix that up?

Ideally the existence of a second interrupt-in urb should have been verified already at interface probe. But we can clean that up later.

drivers/usb/serial/mct_u232.c static int mct_u232_port_probe(struct usb_serial_port *port) · line 387

Quoted 3 lines
drivers/usb/serial/mct_u232.c +0 -0
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;

Thanks,
Johan