linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about implementation of __qbuf_dmabuf() in videobuf2-core.c
@ 2014-04-23  0:18 n179911
  2014-04-23  7:24 ` Hans Verkuil
  0 siblings, 1 reply; 4+ messages in thread
From: n179911 @ 2014-04-23  0:18 UTC (permalink / raw)
  To: linux-media

In __qbuf_dmabuf(), it check the length and size of the buffer being
queued, like this:
http://lxr.free-electrons.com/source/drivers/media/v4l2-core/videobuf2-core.c#L1158

My question is why the range check is liked this:

1158  if (planes[plane].length < planes[plane].data_offset +
1159                     q->plane_sizes[plane]) {
        .....

Isn't  planes[plane].length + planes[plane].data_offset equals to
q->plane_sizes[plane]?

So the check should be?
 if (planes[plane].length < q->plane_sizes[plane] - planes[plane].data_offset)

Please tell me what am I missing?

Thank you

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

* Re: Question about implementation of __qbuf_dmabuf() in videobuf2-core.c
  2014-04-23  0:18 Question about implementation of __qbuf_dmabuf() in videobuf2-core.c n179911
@ 2014-04-23  7:24 ` Hans Verkuil
  2014-04-29 17:27   ` n179911
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Verkuil @ 2014-04-23  7:24 UTC (permalink / raw)
  To: n179911, linux-media

On 04/23/2014 02:18 AM, n179911 wrote:
> In __qbuf_dmabuf(), it check the length and size of the buffer being
> queued, like this:
> http://lxr.free-electrons.com/source/drivers/media/v4l2-core/videobuf2-core.c#L1158
> 
> My question is why the range check is liked this:
> 
> 1158  if (planes[plane].length < planes[plane].data_offset +
> 1159                     q->plane_sizes[plane]) {

It's a bug. It should be:

	if (planes[plane].length < q->plane_sizes[plane]) {

This has been fixed in our upstream code and will appear in 3.16.

Regards,

	Hans

>         .....
> 
> Isn't  planes[plane].length + planes[plane].data_offset equals to
> q->plane_sizes[plane]?
> 
> So the check should be?
>  if (planes[plane].length < q->plane_sizes[plane] - planes[plane].data_offset)
> 
> Please tell me what am I missing?
> 
> Thank you
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: Question about implementation of __qbuf_dmabuf() in videobuf2-core.c
  2014-04-23  7:24 ` Hans Verkuil
@ 2014-04-29 17:27   ` n179911
  2014-05-05 10:19     ` Hans Verkuil
  0 siblings, 1 reply; 4+ messages in thread
From: n179911 @ 2014-04-29 17:27 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media

Hi,

Is there a work around for this bug without upgrading to 3.16 kernel?

Is it safe to manually set the length to be data_offset + size + 1 to make sure

planes[plane].length is greater than planes[plane].data_offset +
                    q->plane_sizes[plane]?

Thank you.

On Wed, Apr 23, 2014 at 12:24 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> On 04/23/2014 02:18 AM, n179911 wrote:
>> In __qbuf_dmabuf(), it check the length and size of the buffer being
>> queued, like this:
>> http://lxr.free-electrons.com/source/drivers/media/v4l2-core/videobuf2-core.c#L1158
>>
>> My question is why the range check is liked this:
>>
>> 1158  if (planes[plane].length < planes[plane].data_offset +
>> 1159                     q->plane_sizes[plane]) {
>
> It's a bug. It should be:
>
>         if (planes[plane].length < q->plane_sizes[plane]) {
>
> This has been fixed in our upstream code and will appear in 3.16.
>
> Regards,
>
>         Hans
>
>>         .....
>>
>> Isn't  planes[plane].length + planes[plane].data_offset equals to
>> q->plane_sizes[plane]?
>>
>> So the check should be?
>>  if (planes[plane].length < q->plane_sizes[plane] - planes[plane].data_offset)
>>
>> Please tell me what am I missing?
>>
>> Thank you
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-media" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>

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

* Re: Question about implementation of __qbuf_dmabuf() in videobuf2-core.c
  2014-04-29 17:27   ` n179911
@ 2014-05-05 10:19     ` Hans Verkuil
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Verkuil @ 2014-05-05 10:19 UTC (permalink / raw)
  To: n179911; +Cc: linux-media

On 04/29/2014 07:27 PM, n179911 wrote:
> Hi,
> 
> Is there a work around for this bug without upgrading to 3.16 kernel?
> 
> Is it safe to manually set the length to be data_offset + size + 1 to make sure
> 
> planes[plane].length is greater than planes[plane].data_offset +
>                     q->plane_sizes[plane]?

Yes, that should be safe. However, if you are building the kernel yourself, then
I would recommend just fixing the kernel instead of working around it elsewhere.

Regards,

	Hans

> 
> Thank you.
> 
> On Wed, Apr 23, 2014 at 12:24 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
>> On 04/23/2014 02:18 AM, n179911 wrote:
>>> In __qbuf_dmabuf(), it check the length and size of the buffer being
>>> queued, like this:
>>> http://lxr.free-electrons.com/source/drivers/media/v4l2-core/videobuf2-core.c#L1158
>>>
>>> My question is why the range check is liked this:
>>>
>>> 1158  if (planes[plane].length < planes[plane].data_offset +
>>> 1159                     q->plane_sizes[plane]) {
>>
>> It's a bug. It should be:
>>
>>         if (planes[plane].length < q->plane_sizes[plane]) {
>>
>> This has been fixed in our upstream code and will appear in 3.16.
>>
>> Regards,
>>
>>         Hans
>>
>>>         .....
>>>
>>> Isn't  planes[plane].length + planes[plane].data_offset equals to
>>> q->plane_sizes[plane]?
>>>
>>> So the check should be?
>>>  if (planes[plane].length < q->plane_sizes[plane] - planes[plane].data_offset)
>>>
>>> Please tell me what am I missing?
>>>
>>> Thank you
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-media" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>


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

end of thread, other threads:[~2014-05-05 10:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23  0:18 Question about implementation of __qbuf_dmabuf() in videobuf2-core.c n179911
2014-04-23  7:24 ` Hans Verkuil
2014-04-29 17:27   ` n179911
2014-05-05 10:19     ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).