From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] uvcvideo: Also validate buffers in BULK mode
Date: Tue, 05 Jun 2018 11:52:19 +0300 [thread overview]
Message-ID: <2206409.jVpTcjFX6j@avalon> (raw)
In-Reply-To: <20180605002415.11421-1-nicolas.dufresne@collabora.com>
Hi Nicolas,
Thank you for the patch.
On Tuesday, 5 June 2018 03:24:15 EEST Nicolas Dufresne wrote:
> Just like for ISOC, validate the decoded BULK buffer size when possible.
> This avoids sending corrupted or partial buffers to userspace, which may
> lead to application crash or run-time failure.
>
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
> drivers/media/usb/uvc/uvc_video.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c
> b/drivers/media/usb/uvc/uvc_video.c index aa0082fe5833..46df4d01e31b 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -1307,8 +1307,10 @@ static void uvc_video_decode_bulk(struct urb *urb,
> struct uvc_streaming *stream, if (stream->bulk.header_size == 0 &&
> !stream->bulk.skip_payload) { do {
> ret = uvc_video_decode_start(stream, buf, mem, len);
> - if (ret == -EAGAIN)
> + if (ret == -EAGAIN) {
> + uvc_video_validate_buffer(stream, buf);
> uvc_video_next_buffers(stream, &buf, &meta_buf);
Wouldn't it be simpler to move the uvc_video_validate_buffer() call to
uvc_video_next_buffers() ?
> + }
> } while (ret == -EAGAIN);
>
> /* If an error occurred skip the rest of the payload. */
> @@ -1342,8 +1344,10 @@ static void uvc_video_decode_bulk(struct urb *urb,
> struct uvc_streaming *stream, if (!stream->bulk.skip_payload && buf !=
> NULL) {
> uvc_video_decode_end(stream, buf, stream->bulk.header,
> stream->bulk.payload_size);
> - if (buf->state == UVC_BUF_STATE_READY)
> + if (buf->state == UVC_BUF_STATE_READY) {
> + uvc_video_validate_buffer(stream, buf);
> uvc_video_next_buffers(stream, &buf, &meta_buf);
> + }
> }
>
> stream->bulk.header_size = 0;
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2018-06-05 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 0:24 [PATCH] uvcvideo: Also validate buffers in BULK mode Nicolas Dufresne
2018-06-05 8:52 ` Laurent Pinchart [this message]
2018-06-05 14:07 ` Nicolas Dufresne
2018-06-05 23:46 ` [PATCH v2] " Nicolas Dufresne
2019-12-10 2:27 ` Nicolas Dufresne
2019-12-10 2:30 ` Nicolas Dufresne
2019-12-13 0:12 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2206409.jVpTcjFX6j@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=nicolas.dufresne@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox