diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2018-08-15 16:44:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-05 07:27:06 -0400 |
commit | 7e10f14ebface44a48275c8d6dc1caae3668d5a9 (patch) | |
tree | a6d69dbcdb3c191be3bb6017a90a01ff2584ab75 /drivers/usb/misc/yurex.c | |
parent | 222471f7640d9771a993218d825d84825adc805d (diff) |
USB: yurex: Fix buffer over-read in yurex_write()
If the written data starts with a digit, yurex_write() tries to parse
it as an integer using simple_strtoull(). This requires a null-
terminator, and currently there's no guarantee that there is one.
(The sample program at
https://github.com/NeoCat/YUREX-driver-for-Linux/blob/master/sample/yurex_clock.pl
writes an integer without a null terminator. It seems like it must
have worked by chance!)
Always add a null byte after the written data. Enlarge the buffer
to allow for this.
Cc: stable@vger.kernel.org
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/misc/yurex.c')
-rw-r--r-- | drivers/usb/misc/yurex.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c index 3be40eaa1ac9..1232dd49556d 100644 --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c | |||
@@ -421,13 +421,13 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, | |||
421 | { | 421 | { |
422 | struct usb_yurex *dev; | 422 | struct usb_yurex *dev; |
423 | int i, set = 0, retval = 0; | 423 | int i, set = 0, retval = 0; |
424 | char buffer[16]; | 424 | char buffer[16 + 1]; |
425 | char *data = buffer; | 425 | char *data = buffer; |
426 | unsigned long long c, c2 = 0; | 426 | unsigned long long c, c2 = 0; |
427 | signed long timeout = 0; | 427 | signed long timeout = 0; |
428 | DEFINE_WAIT(wait); | 428 | DEFINE_WAIT(wait); |
429 | 429 | ||
430 | count = min(sizeof(buffer), count); | 430 | count = min(sizeof(buffer) - 1, count); |
431 | dev = file->private_data; | 431 | dev = file->private_data; |
432 | 432 | ||
433 | /* verify that we actually have some data to write */ | 433 | /* verify that we actually have some data to write */ |
@@ -446,6 +446,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, | |||
446 | retval = -EFAULT; | 446 | retval = -EFAULT; |
447 | goto error; | 447 | goto error; |
448 | } | 448 | } |
449 | buffer[count] = 0; | ||
449 | memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE); | 450 | memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE); |
450 | 451 | ||
451 | switch (buffer[0]) { | 452 | switch (buffer[0]) { |