Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] media: usbtv: fix control-message timeouts
@ 2020-01-13 17:18 Johan Hovold
  2020-01-13 18:15 ` Lubomir Rintel
  2020-01-13 18:26 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2020-01-13 17:18 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-media, linux-usb, linux-kernel, Johan Hovold, stable,
	Lubomir Rintel

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.

Fixes: f3d27f34fdd7 ("[media] usbtv: Add driver for Fushicai USBTV007 video frame grabber")
Fixes: c53a846c48f2 ("[media] usbtv: add video controls")
Cc: stable <stable@vger.kernel.org>     # 3.11
Cc: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/media/usb/usbtv/usbtv-core.c  | 2 +-
 drivers/media/usb/usbtv/usbtv-video.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
index 5095c380b2c1..ee9c656d121f 100644
--- a/drivers/media/usb/usbtv/usbtv-core.c
+++ b/drivers/media/usb/usbtv/usbtv-core.c
@@ -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;
 	}
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 3d9284a09ee5..b249f037900c 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -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)
-- 
2.24.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: usbtv: fix control-message timeouts
  2020-01-13 17:18 [PATCH] media: usbtv: fix control-message timeouts Johan Hovold
@ 2020-01-13 18:15 ` Lubomir Rintel
  2020-01-13 18:26 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Lubomir Rintel @ 2020-01-13 18:15 UTC (permalink / raw)
  To: Johan Hovold, Mauro Carvalho Chehab
  Cc: linux-media, linux-usb, linux-kernel, stable

On Mon, 2020-01-13 at 18:18 +0100, Johan Hovold wrote:
> 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.
> 
> Fixes: f3d27f34fdd7 ("[media] usbtv: Add driver for Fushicai USBTV007 video frame grabber")
> Fixes: c53a846c48f2 ("[media] usbtv: add video controls")
> Cc: stable <stable@vger.kernel.org>     # 3.11
> Cc: Lubomir Rintel <lkundrak@v3.sk>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Acked-by: Lubomir Rintel <lkundrak@v3.sk>

Thank you,
Lubo

> ---
>  drivers/media/usb/usbtv/usbtv-core.c  | 2 +-
>  drivers/media/usb/usbtv/usbtv-video.c | 5 +++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
> index 5095c380b2c1..ee9c656d121f 100644
> --- a/drivers/media/usb/usbtv/usbtv-core.c
> +++ b/drivers/media/usb/usbtv/usbtv-core.c
> @@ -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;
>  	}
> diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
> index 3d9284a09ee5..b249f037900c 100644
> --- a/drivers/media/usb/usbtv/usbtv-video.c
> +++ b/drivers/media/usb/usbtv/usbtv-video.c
> @@ -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)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: usbtv: fix control-message timeouts
  2020-01-13 17:18 [PATCH] media: usbtv: fix control-message timeouts Johan Hovold
  2020-01-13 18:15 ` Lubomir Rintel
@ 2020-01-13 18:26 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2020-01-13 18:26 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Mauro Carvalho Chehab, linux-media, linux-usb, linux-kernel,
	stable, Lubomir Rintel

On Mon, Jan 13, 2020 at 06:18:18PM +0100, Johan Hovold wrote:
> 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.
> 
> Fixes: f3d27f34fdd7 ("[media] usbtv: Add driver for Fushicai USBTV007 video frame grabber")
> Fixes: c53a846c48f2 ("[media] usbtv: add video controls")
> Cc: stable <stable@vger.kernel.org>     # 3.11
> Cc: Lubomir Rintel <lkundrak@v3.sk>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-13 17:18 [PATCH] media: usbtv: fix control-message timeouts Johan Hovold
2020-01-13 18:15 ` Lubomir Rintel
2020-01-13 18:26 ` Greg KH

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git