]> git.baikalelectronics.ru Git - kernel.git/commit
USB: usbtmc: sanity checks for DEV_DEP_MSG_IN urbs
authorGuus Sliepen <guus@sliepen.org>
Wed, 22 Jul 2009 15:39:42 +0000 (17:39 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 23 Sep 2009 13:46:30 +0000 (06:46 -0700)
commita34659bb2381dd18f74f9416e54cb5e6fdf63160
tree029c210e11d5f9befee6a51457a9dcd79b7934b6
parent699a1cb632b7eb2eec6833c20cabae1ef1913687
USB: usbtmc: sanity checks for DEV_DEP_MSG_IN urbs

According to the specifications, an instrument should not return more data in a
DEV_DEP_MSG_IN urb than requested.  However, some instruments can send more
than requested. This could cause the kernel to write the extra data past the
end of the buffer provided by read().

Fix this by checking that the value of the TranserSize field is not larger than
the urb itself and not larger than the size of the userspace buffer. Also
correctly decrement the remaining size of the buffer when userspace read()s
more than USBTMC_SIZE_IOBUFFER.

Signed-off-by: Guus Sliepen <guus@sliepen.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/class/usbtmc.c