public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: don't trust report_size for buffer size
@ 2010-10-11 18:28 Kees Cook
  2010-10-11 18:54 ` Németh Márton
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2010-10-11 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Oliver Neukum, Joe Perches,
	Németh Márton, linux-usb

If the iowarrior devices in this case statement support more than 8 bytes
per report, it is possible to write past the end of a kernel heap allocation.
This will probably never be possible, but change the allocation to be more
defensive anyway.

Signed-off-by: Kees Cook <kees.cook@canonical.com>
---
 drivers/usb/misc/iowarrior.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index bc88c79..8ed8d05 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -374,7 +374,7 @@ static ssize_t iowarrior_write(struct file *file,
 	case USB_DEVICE_ID_CODEMERCS_IOWPV2:
 	case USB_DEVICE_ID_CODEMERCS_IOW40:
 		/* IOW24 and IOW40 use a synchronous call */
-		buf = kmalloc(8, GFP_KERNEL);	/* 8 bytes are enough for both products */
+		buf = kmalloc(count, GFP_KERNEL);
 		if (!buf) {
 			retval = -ENOMEM;
 			goto exit;
-- 
1.7.1

-- 
Kees Cook
Ubuntu Security Team

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

end of thread, other threads:[~2010-10-11 19:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-11 18:28 [PATCH] usb: don't trust report_size for buffer size Kees Cook
2010-10-11 18:54 ` Németh Márton
2010-10-11 19:11   ` Kees Cook
2010-10-11 19:34     ` Németh Márton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox