]> asedeno.scripts.mit.edu Git - linux.git/commit
media: uvcvideo: Fix 'type' check leading to overflow
authorAlistair Strachan <astrachan@google.com>
Wed, 19 Dec 2018 01:32:48 +0000 (20:32 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 7 Feb 2019 16:54:14 +0000 (11:54 -0500)
commit47bb117911b051bbc90764a8bff96543cbd2005f
tree888c4dadbb2393f158b69e5cb790f960c9feacb0
parent69a9005789ad18806490bd8dc70dd6458319cd28
media: uvcvideo: Fix 'type' check leading to overflow

When initially testing the Camera Terminal Descriptor wTerminalType
field (buffer[4]), no mask is used. Later in the function, the MSB is
overloaded to store the descriptor subtype, and so a mask of 0x7fff
is used to check the type.

If a descriptor is specially crafted to set this overloaded bit in the
original wTerminalType field, the initial type check will fail (falling
through, without adjusting the buffer size), but the later type checks
will pass, assuming the buffer has been made suitably large, causing an
overflow.

Avoid this problem by checking for the MSB in the wTerminalType field.
If the bit is set, assume the descriptor is bad, and abort parsing it.

Originally reported here:
https://groups.google.com/forum/#!topic/syzkaller/Ot1fOE6v1d8
A similar (non-compiling) patch was provided at that time.

Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Alistair Strachan <astrachan@google.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/usb/uvc/uvc_driver.c