media: usbtv: fix control-message timeouts
Subsystems (3)
PATCH 1/1 media: usbtv: fix control-message timeouts
The driver was issuing synchronous uninterruptible control requests without using a timeout. This could lead to the driver hanging on various user requests due to a malfunctioning (or malicious) device until the device is physically disconnected.
The USB upper limit of five seconds per request should be more than enough.
--- drivers/media/usb/usbtv/usbtv-core.c | 2 +- drivers/media/usb/usbtv/usbtv-video.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/media/usb/usbtv/usbtv-core.c +1 -1
@@ -56,7 +56,7 @@ int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size) ret =usb_control_msg (usbtv->udev, pipe,USBTV_REQUEST_REG ,USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , - value, index,NULL ,0 ,0 ); + value, index,NULL ,0 ,USB_CTRL_GET_TIMEOUT );if (ret <0 )return ret; }
drivers/media/usb/usbtv/usbtv-video.c +3 -2
@@ -800,7 +800,8 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl) ret =usb_control_msg (usbtv->udev,usb_rcvctrlpipe (usbtv->udev,0 ),USBTV_CONTROL_REG ,USB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_DEVICE , -0 ,USBTV_BASE +0x0244 , (void *)data,3 ,0 ); +0 ,USBTV_BASE +0x0244 , (void *)data,3 , +USB_CTRL_GET_TIMEOUT );if (ret <0 ) goto error; }
@@ -851,7 +852,7 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl) ret =usb_control_msg (usbtv->udev,usb_sndctrlpipe (usbtv->udev,0 ),USBTV_CONTROL_REG ,USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , -0 , index, (void *)data, size,0 ); +0 , index, (void *)data, size,USB_CTRL_SET_TIMEOUT ); error:if (ret <0 )
Signature · 1 line
2.24.1
Quoted 5 lines · Johan Hovold
The driver was issuing synchronous uninterruptible control requests without using a timeout. This could lead to the driver hanging on various user requests due to a malfunctioning (or malicious) device until the device is physically disconnected.
Quoted 8 lines
The USB upper limit of five seconds per request should be more than enough.
Fixes f3d27f34fdd7 ("[media] usbtv: Add driver for Fushicai USBTV007 video frame grabber")Fixes c53a846c48f2 ("[media] usbtv: add video controls")Cc stable <[email protected]> # 3.11Cc Lubomir Rintel <[email protected]>Signed-off-by Johan Hovold <[email protected]>
Thank you,
Lubo
Quoted 41 lines
--- drivers/media/usb/usbtv/usbtv-core.c | 2 +- drivers/media/usb/usbtv/usbtv-video.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)drivers/media/usb/usbtv/usbtv-core.c +1
-1@@ -56,7 +56,7 @@ int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size) ret =usb_control_msg (usbtv->udev, pipe,USBTV_REQUEST_REG ,USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , - value, index,NULL ,0 ,0 ); + value, index,NULL ,0 ,USB_CTRL_GET_TIMEOUT );if (ret <0 )return ret; }drivers/media/usb/usbtv/usbtv-video.c +3
-2@@ -800,7 +800,8 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl) ret =usb_control_msg (usbtv->udev,usb_rcvctrlpipe (usbtv->udev,0 ),USBTV_CONTROL_REG ,USB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_DEVICE , -0 ,USBTV_BASE +0x0244 , (void *)data,3 ,0 ); +0 ,USBTV_BASE +0x0244 , (void *)data,3 , +USB_CTRL_GET_TIMEOUT );if (ret <0 ) goto error; }@@ -851,7 +852,7 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl) ret =usb_control_msg (usbtv->udev,usb_sndctrlpipe (usbtv->udev,0 ),USBTV_CONTROL_REG ,USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , -0 , index, (void *)data, size,0 ); +0 , index, (void *)data, size,USB_CTRL_SET_TIMEOUT ); error:if (ret <0 )
Quoted 5 lines · Johan Hovold
The driver was issuing synchronous uninterruptible control requests without using a timeout. This could lead to the driver hanging on various user requests due to a malfunctioning (or malicious) device until the device is physically disconnected.
Quoted 8 lines
The USB upper limit of five seconds per request should be more than enough.
Fixes f3d27f34fdd7 ("[media] usbtv: Add driver for Fushicai USBTV007 video frame grabber")Fixes c53a846c48f2 ("[media] usbtv: add video controls")Cc stable <[email protected]> # 3.11Cc Lubomir Rintel <[email protected]>Signed-off-by Johan Hovold <[email protected]>