Skip to contentSkip to conversation

PATCH: 2.6.7-rc3 drivers/usb/core/devio.c: user/kernel pointer bugs

PATCH Applied Robert T. Johnson 2 participants 2 messages Jun 9, 2004 – Jun 10, 2004 USB

lore
Share & tools
lore
#0 lore raw

Since ctrl is copied in from userspace, ctrl.data cannot safely be dereferenced. Let me know if you have any questions or if I've made a mistake.

Best,
Rob

drivers/usb/core/devio.c renamed from drivers/usb/core/devio.c.orig +2 -2
@@ -558,7 +558,7 @@ static int proc_control(struct dev_state
 			if (usbfs_snoop) {
 				dev_info(&dev->dev, "control read: data ");
 				for (j = 0; j < ctrl.wLength; ++j)
-					printk ("%02x ", (unsigned char)((char *)ctrl.data)[j]);
+					printk ("%02x ", (unsigned char)(tbuf)[j]);
 				printk("\n");
 			}
 			if (copy_to_user(ctrl.data, tbuf, ctrl.wLength)) {
@@ -578,7 +578,7 @@ static int proc_control(struct dev_state
 		if (usbfs_snoop) {
 			dev_info(&dev->dev, "control write: data: ");
 			for (j = 0; j < ctrl.wLength; ++j)
-				printk ("%02x ", (unsigned char)((char *)ctrl.data)[j]);
+				printk ("%02x ", (unsigned char)(tbuf)[j]);
 			printk("\n");
 		}
 		i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType,
Applied
#1 lore raw
Quoted 3 lines · Robert T. Johnson

Since ctrl is copied in from userspace, ctrl.data cannot safely be dereferenced. Let me know if you have any questions or if I've made a mistake.

Oops, I added this bug, sorry about that, good catch.

I've applied this to my trees, thanks.

greg k-h