]> git.hungrycats.org Git - linux/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>
Mon, 5 Oct 2009 16:32:02 +0000 (09:32 -0700)
commit78c953d674dd53256c617e03c3aec81be3697cb8
treef9400a2e4421173ce79164c2a91122859303d41a
parentb7c8b54df8c2a82757d8aab48aaac198a49e2ff9
USB: usbtmc: sanity checks for DEV_DEP_MSG_IN urbs

commit 665d7662d15441b4b3e54131a9418a1a198d0d31 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/class/usbtmc.c