From: Hans Verkuil <hverkuil@xs4all.nl>
To: Nikhil Devshatwar <nikhil.nd@ti.com>, linux-media@vger.kernel.org
Subject: Re: [[PATCH]] vb2: verify data_offset only if nonzero bytesused
Date: Mon, 23 Jun 2014 09:55:05 +0200 [thread overview]
Message-ID: <53A7DD59.4060401@xs4all.nl> (raw)
In-Reply-To: <1403434065-22994-1-git-send-email-nikhil.nd@ti.com>
On 06/22/2014 12:47 PM, Nikhil Devshatwar wrote:
> verify_planes would fail if the user space fills up the data_offset field
> and bytesused is left as zero. Correct this.
>
> Checking for data_offset > bytesused is not correct as it might fail some of
> the valid use cases. e.g. when working with SEQ_TB buffers, for bottom field,
> data_offset can be high but it can have less bytesused.
>
> The real check should be to verify that all the bytesused after data_offset
> fit withing the length of the plane.
>
> Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
> ---
> drivers/media/v4l2-core/videobuf2-core.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index 7c4489c..9a0ccb6 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -587,12 +587,9 @@ static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b)
> ? b->m.planes[plane].length
> : vb->v4l2_planes[plane].length;
>
> - if (b->m.planes[plane].bytesused > length)
> - return -EINVAL;
> -
> - if (b->m.planes[plane].data_offset > 0 &&
> - b->m.planes[plane].data_offset >=
> - b->m.planes[plane].bytesused)
> + if (b->m.planes[plane].bytesused > 0 &&
> + b->m.planes[plane].data_offset +
> + b->m.planes[plane].bytesused > length)
Nacked-by: Hans Verkuil <hans.verkuil@cisco.com>
bytesused *includes* data_offset. So the effective payload is
'bytesused - data_offset' starting at offset 'data_offset' from the
start of the buffer.
So your new condition is wrong.
Regards,
Hans
> return -EINVAL;
> }
> } else {
>
next prev parent reply other threads:[~2014-06-23 7:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-22 10:47 [[PATCH]] vb2: verify data_offset only if nonzero bytesused Nikhil Devshatwar
2014-06-23 7:55 ` Hans Verkuil [this message]
2014-06-23 9:42 ` Devshatwar, Nikhil
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=53A7DD59.4060401@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=nikhil.nd@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.