Skip to contentSkip to conversation

USB: visor: fix null-deref at probe

PATCH In review Johan Hovold 1 participant 3 messages Jan 12, 2016 – Jan 25, 2016

Subsystems (3)
lore
Share & tools
lore

Johan Hovold

author maintainer
#0 lore raw

PATCH 1/1 USB: visor: fix null-deref at probe

Fix null-pointer dereference at probe should a (malicious) Treo device lack the expected endpoints.

Specifically, the Treo port-setup hack was dereferencing the bulk-in and interrupt-in urbs without first making sure they had been allocated by core.

---
 drivers/usb/serial/visor.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/serial/visor.c +5 -0
index 60afb39eb73c..c53fbb3e0b8c 100644
@@ -544,6 +544,11 @@ static int treo_attach(struct usb_serial *serial)
 		(serial->num_interrupt_in == 0))
 		return 0;
 
+	if (serial->num_bulk_in < 2 || serial->num_interrupt_in < 2) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
 	/*
 	* It appears that Treos and Kyoceras want to use the
 	* 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
Signature · 1 line
2.4.10
author maintainer
#1 lore raw
Quoted 10 lines · Johan Hovold

Fix null-pointer dereference at probe should a (malicious) Treo device lack the expected endpoints.

Specifically, the Treo port-setup hack was dereferencing the bulk-in and interrupt-in urbs without first making sure they had been allocated by core.

---

Vladis,

turns out the Treo devices had a similar problem.

You should be able to just use just

	if (serial->num_bulk_out < 2)
		return -ENODEV;

for your case.

Quoted 9 lines
 drivers/usb/serial/visor.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/serial/visor.c +0 -0
index 60afb39eb73c..c53fbb3e0b8c 100644
@@ -544,6 +544,11 @@ static int treo_attach(struct usb_serial *serial)
 		(serial->num_interrupt_in == 0))

drivers/usb/serial/visor.c static int treo_attach(struct usb_serial *serial) · line 554

Quoted 10 lines
drivers/usb/serial/visor.c +5 -0
 		return 0;
 
+	if (serial->num_bulk_in < 2 || serial->num_interrupt_in < 2) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
 	/*
 	* It appears that Treos and Kyoceras want to use the
 	* 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,

Thanks,
Johan

author maintainer
#2 lore raw
In reply to Johan Hovold
Quoted 19 lines · Johan Hovold

Fix null-pointer dereference at probe should a (malicious) Treo device lack the expected endpoints.

Specifically, the Treo port-setup hack was dereferencing the bulk-in and interrupt-in urbs without first making sure they had been allocated by core.

---
 drivers/usb/serial/visor.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/serial/visor.c +0 -0
index 60afb39eb73c..c53fbb3e0b8c 100644
@@ -544,6 +544,11 @@ static int treo_attach(struct usb_serial *serial)
 		(serial->num_interrupt_in == 0))

drivers/usb/serial/visor.c static int treo_attach(struct usb_serial *serial) · line 554

Quoted 10 lines
drivers/usb/serial/visor.c +5 -0
 		return 0;
 
+	if (serial->num_bulk_in < 2 || serial->num_interrupt_in < 2) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
 	/*
 	* It appears that Treos and Kyoceras want to use the
 	* 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,

Now applied.

Johan