• Alan Stern's avatar
    media: usbvision: Fix invalid accesses after device disconnect · c7a19146
    Alan Stern authored
    The syzbot fuzzer found two invalid-access bugs in the usbvision
    driver.  These bugs occur when userspace keeps the device file open
    after the device has been disconnected and usbvision_disconnect() has
    set usbvision->dev to NULL:
    
    	When the device file is closed, usbvision_radio_close() tries
    	to issue a usb_set_interface() call, passing the NULL pointer
    	as its first argument.
    
    	If userspace performs a querycap ioctl call, vidioc_querycap()
    	calls usb_make_path() with the same NULL pointer.
    
    This patch fixes the problems by making the appropriate tests
    beforehand.  Note that vidioc_querycap() is protected by
    usbvision->v4l2_lock, acquired in a higher layer of the V4L2
    subsystem.
    
    Reported-and-tested-by: syzbot+7fa38a608b1075dfd634@syzkaller.appspotmail.com
    Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
    CC: <stable@vger.kernel.org>
    Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
    c7a19146
usbvision-video.c 45.2 KB