Skip to contentSkip to conversation

watchdog: pcwd_usb: overflow in usb_pcwd_send_command()

PATCH Superseded Dan Carpenter 3 participants 8 messages Nov 7, 2013 – Nov 17, 2013

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

PATCH 1/1 watchdog: pcwd_usb: overflow in usb_pcwd_send_command()

We changed "buf" from being an array of 6 chars to being a pointer this sizeof(buf) needs to be updated as well.

Fixes 2ddb8089a7e5 ('watchdog: pcwd_usb: Use allocated buffer for usb_control_msg')
drivers/watchdog/pcwd_usb.c +1 -1
index 53598e8..7031b9b 100644
@@ -258,7 +258,7 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
 
 	if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0),
 			HID_REQ_SET_REPORT, HID_DT_REPORT,
-			0x0200, usb_pcwd->interface_number, buf, sizeof(buf),
+			0x0200, usb_pcwd->interface_number, buf, 6,
 			USB_COMMAND_TIMEOUT) != sizeof(buf)) {
 		dbg("usb_pcwd_send_command: error in usb_control_msg for "
 				"cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb);
#1 lore raw

Hi Dan,

Quoted 11 lines

We changed "buf" from being an array of 6 chars to being a pointer this sizeof(buf) needs to be updated as well.

Fixes 2ddb8089a7e5 ('watchdog: pcwd_usb: Use allocated buffer for usb_control_msg')
drivers/watchdog/pcwd_usb.c +0 -0
index 53598e8..7031b9b 100644

drivers/watchdog/pcwd_usb.c static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, · line 264

Quoted 8 lines
drivers/watchdog/pcwd_usb.c +1 -1
@@ -258,7 +258,7 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
 
 	if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0),
 			HID_REQ_SET_REPORT, HID_DT_REPORT,
-			0x0200, usb_pcwd->interface_number, buf, sizeof(buf),
+			0x0200, usb_pcwd->interface_number, buf, 6,
 			USB_COMMAND_TIMEOUT) != sizeof(buf)) {
 		dbg("usb_pcwd_send_command: error in usb_control_msg for "
 				"cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb);

Added to linux-watchdog-next.

Kind regards,
Wim.

maintainer
#2 lore raw
In reply to Dan Carpenter
Quoted 3 lines · Dan Carpenter

We changed "buf" from being an array of 6 chars to being a pointer this sizeof(buf) needs to be updated as well.

oops ...

Quoted 8 lines
Fixes 2ddb8089a7e5 ('watchdog: pcwd_usb: Use allocated buffer for usb_control_msg')
drivers/watchdog/pcwd_usb.c +0 -0
index 53598e8..7031b9b 100644

drivers/watchdog/pcwd_usb.c static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, · line 262

Quoted 6 lines
drivers/watchdog/pcwd_usb.c +1 -1
@@ -258,7 +258,7 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
 
  	if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0),
  			HID_REQ_SET_REPORT, HID_DT_REPORT,
-			0x0200, usb_pcwd->interface_number, buf, sizeof(buf),
+			0x0200, usb_pcwd->interface_number, buf, 6,
  			USB_COMMAND_TIMEOUT) != sizeof(buf)) {

Doesn't it have to be fixed here as well ?

Thanks,
Guenter

Quoted 8 lines
drivers/watchdog/pcwd_usb.c +0 -1
  		dbg("usb_pcwd_send_command: error in usb_control_msg for "
  				"cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb);
--

To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 15 lines · Guenter Roeck
Quoted 3 lines · Dan Carpenter

We changed "buf" from being an array of 6 chars to being a pointer this sizeof(buf) needs to be updated as well.

oops ...

Quoted 9 lines
Fixes 2ddb8089a7e5 ('watchdog: pcwd_usb: Use allocated buffer for usb_control_msg')
drivers/watchdog/pcwd_usb.c +0 -0
index 53598e8..7031b9b 100644
@@ -258,7 +258,7 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
 
Quoted 7 lines

drivers/watchdog/pcwd_usb.c static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, · line 262

Quoted 5 lines
drivers/watchdog/pcwd_usb.c +1 -1
 	if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0),
 			HID_REQ_SET_REPORT, HID_DT_REPORT,
-			0x0200, usb_pcwd->interface_number, buf, sizeof(buf),
+			0x0200, usb_pcwd->interface_number, buf, 6,
 			USB_COMMAND_TIMEOUT) != sizeof(buf)) {

Doesn't it have to be fixed here as well ?

Yeah. Good eye. I'll send a v2.

regards,
dan carpenter

#4 lore raw

PATCH v2 1/1 watchdog: pcwd_usb: overflow in usb_pcwd_send_command()

In reply to Guenter Roeck

We changed "buf" from being an array of 6 chars to being a pointer this sizeof(buf) needs to be updated as well.

Fixes 2ddb8089a7e5 ('watchdog: pcwd_usb: Use allocated buffer for usb_control_msg')

---
v2: Fix the bug that Guenter Roeck pointed out in v1.

drivers/watchdog/pcwd_usb.c +2 -2
index 53598e8..b731b5d 100644
@@ -258,8 +258,8 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
 
 	if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0),
 			HID_REQ_SET_REPORT, HID_DT_REPORT,
-			0x0200, usb_pcwd->interface_number, buf, sizeof(buf),
-			USB_COMMAND_TIMEOUT) != sizeof(buf)) {
+			0x0200, usb_pcwd->interface_number, buf, 6,
+			USB_COMMAND_TIMEOUT) != 6) {
 		dbg("usb_pcwd_send_command: error in usb_control_msg for "
 				"cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb);
 	}
maintainer Reviewed-by on v2 1/1
#5 lore raw
Quoted 5 lines · Dan Carpenter

We changed "buf" from being an array of 6 chars to being a pointer this sizeof(buf) needs to be updated as well.

Fixes 2ddb8089a7e5 ('watchdog: pcwd_usb: Use allocated buffer for usb_control_msg')
Quoted 24 lines

---
v2: Fix the bug that Guenter Roeck pointed out in v1.

drivers/watchdog/pcwd_usb.c +2 -3
index 53598e8..b731b5d 100644
@@ -258,8 +258,8 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
 
  	if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0),
  			HID_REQ_SET_REPORT, HID_DT_REPORT,
-			0x0200, usb_pcwd->interface_number, buf, sizeof(buf),
-			USB_COMMAND_TIMEOUT) != sizeof(buf)) {
+			0x0200, usb_pcwd->interface_number, buf, 6,
+			USB_COMMAND_TIMEOUT) != 6) {
  		dbg("usb_pcwd_send_command: error in usb_control_msg for "
  				"cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb);
  	}
--

To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Reviewed-by on v2 1/1
#6 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

We changed "buf" from being an array of 6 chars to being a pointer this sizeof(buf) needs to be updated as well.

Fixes 2ddb8089a7e5 ('watchdog: pcwd_usb: Use allocated buffer for usb_control_msg')

I thought I had replied earlier, but I don't find my reply anywhere. My apologies if this is a duplicate.

Guenter

#7 lore raw
In reply to Dan Carpenter

Hi Dan,

Quoted 7 lines

We changed "buf" from being an array of 6 chars to being a pointer this sizeof(buf) needs to be updated as well.

Fixes 2ddb8089a7e5 ('watchdog: pcwd_usb: Use allocated buffer for usb_control_msg')

---
v2: Fix the bug that Guenter Roeck pointed out in v1.

This was added to linux-watchdog-next.

Kind regards,
Wim.