LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch
@ 2015-02-25  7:29 Sudip JAIN
  2015-02-25 18:23 ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch Jeremiah Mahler
  0 siblings, 1 reply; 7+ messages in thread
From: Sudip JAIN @ 2015-02-25  7:29 UTC (permalink / raw)
  To: linux-media; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 148 bytes --]

Dear Maintainer,

PFA attached patch that prevents user from being returned garbage bytesused value from vb2 framework.

Regards,
Sudip Jain
 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch --]
[-- Type: text/x-patch; name="0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch", Size: 1634 bytes --]

From 804e76f89d73d10b9fd7b25a48a6edc31faa40a9 Mon Sep 17 00:00:00 2001
From: Sudip Jain <sudip.jain@st.com>
Date: Wed, 25 Feb 2015 12:24:53 +0530
Subject: [PATCH] media: vb2: Fill vb2_buffer with bytesused from user

In vb2_qbuf for dmabuf memory type, userside bytesused is not copied in
vb2 buffer. This leads to garbage value being copied from __qbuf_dmabuf()
back to user in __fill_v4l2_buffer().

As a default case, the vb2 framework must return the default value to the user,
if the driver's buffer prepare function prefers not to modify/update.

Change-Id: Ieda389403898935f59c2e2994106f3e5238cfefd
Signed-off-by: Sudip Jain <sudip.jain@st.com>
---
 drivers/media/v4l2-core/videobuf2-core.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 5e47ba4..54fe9c9 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -919,6 +919,8 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
 					b->m.planes[plane].m.fd;
 				v4l2_planes[plane].length =
 					b->m.planes[plane].length;
+				v4l2_planes[plane].bytesused =
+					b->m.planes[plane].bytesused;
 				v4l2_planes[plane].data_offset =
 					b->m.planes[plane].data_offset;
 			}
@@ -943,6 +945,7 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
 		if (b->memory == V4L2_MEMORY_DMABUF) {
 			v4l2_planes[0].m.fd = b->m.fd;
 			v4l2_planes[0].length = b->length;
+			v4l2_planes[0].bytesused = b->bytesused;
 			v4l2_planes[0].data_offset = 0;
 		}
 
-- 
1.7.9.5


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

* Re: 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch
  2015-02-25  7:29 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch Sudip JAIN
@ 2015-02-25 18:23 ` Jeremiah Mahler
  2015-02-25 19:44   ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch Jean-Michel Hautbois
  2015-02-26  5:18   ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69 Sudip JAIN
  0 siblings, 2 replies; 7+ messages in thread
From: Jeremiah Mahler @ 2015-02-25 18:23 UTC (permalink / raw)
  To: Sudip JAIN; +Cc: linux-media, linux-kernel

Sudip,

On Wed, Feb 25, 2015 at 03:29:22PM +0800, Sudip JAIN wrote:
> Dear Maintainer,
> 
> PFA attached patch that prevents user from being returned garbage bytesused value from vb2 framework.
> 
> Regards,
> Sudip Jain
>  

Patches should never be submitted as attachments, they should be inline.

See Documentation/SubmittingPatches for more info.

[...]

-- 
- Jeremiah Mahler

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

* Re: 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch
  2015-02-25 18:23 ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch Jeremiah Mahler
@ 2015-02-25 19:44   ` Jean-Michel Hautbois
  2015-02-26  5:18   ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69 Sudip JAIN
  1 sibling, 0 replies; 7+ messages in thread
From: Jean-Michel Hautbois @ 2015-02-25 19:44 UTC (permalink / raw)
  To: Jeremiah Mahler, Sudip JAIN, linux-media, linux-kernel

Hi Sudip,

2015-02-25 19:23 GMT+01:00 Jeremiah Mahler <jmmahler@gmail.com>:
> Sudip,
>
> On Wed, Feb 25, 2015 at 03:29:22PM +0800, Sudip JAIN wrote:
>> Dear Maintainer,
>>
>> PFA attached patch that prevents user from being returned garbage bytesused value from vb2 framework.
>>
>> Regards,
>> Sudip Jain
>>
>
> Patches should never be submitted as attachments, they should be inline.
>
> See Documentation/SubmittingPatches for more info.

You also can have a look here :
http://linuxtv.org/wiki/index.php/Development:_How_to_submit_patches

In fact, is the patch on top of master tree ? According to line
numbers, I would say no.

Thx,
JM

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

* RE: 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69
  2015-02-25 18:23 ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch Jeremiah Mahler
  2015-02-25 19:44   ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch Jean-Michel Hautbois
@ 2015-02-26  5:18   ` Sudip JAIN
  2015-02-26  8:58     ` Hans Verkuil
  2015-02-26 17:09     ` Jeremiah Mahler
  1 sibling, 2 replies; 7+ messages in thread
From: Sudip JAIN @ 2015-02-26  5:18 UTC (permalink / raw)
  To: Jeremiah Mahler; +Cc: linux-media, linux-kernel

Hello Jeremiah,

Please find the patch  "inline"

commit 3390900680e5182998916c8fa231bc79cd84046b
Author: Sudip Jain <sudip.jain@st.com>
Date:   Thu Feb 26 10:40:34 2015 +0530

    media: vb2: Fill vb2_buffer with bytesused from user
    
    In vb2_qbuf for dmabuf memory type, userside bytesused is not read to
    vb2 buffer. This leads garbage value being copied from __qbuf_dmabuf()
    back to user in __fill_v4l2_buffer().
    
    As a default case, the vb2 framework must trust the userside value,
    and also allow driver's buffer prepare function prefer modify/update
    or not to.
    
    Applied on kernel version 3.10.69
    
    Change-Id: Ieda389403898935f59c2e2994106f3e5238cfefd
    Signed-off-by: Sudip Jain <sudip.jain@st.com>

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 5e47ba4..54fe9c9 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -919,6 +919,8 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
                                        b->m.planes[plane].m.fd;
                                v4l2_planes[plane].length =
                                        b->m.planes[plane].length;
+                               v4l2_planes[plane].bytesused =
+                                       b->m.planes[plane].bytesused;
                                v4l2_planes[plane].data_offset =
                                        b->m.planes[plane].data_offset;
                        }
@@ -943,6 +945,7 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
                if (b->memory == V4L2_MEMORY_DMABUF) {
                        v4l2_planes[0].m.fd = b->m.fd;
                        v4l2_planes[0].length = b->length;
+                       v4l2_planes[0].bytesused = b->bytesused;
                        v4l2_planes[0].data_offset = 0;
                }

Thanks,
Sudip
________________________________________
From: Jeremiah Mahler [jmmahler@gmail.com]
Sent: Wednesday, February 25, 2015 11:53 PM
To: Sudip JAIN
Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch

Sudip,

On Wed, Feb 25, 2015 at 03:29:22PM +0800, Sudip JAIN wrote:
> Dear Maintainer,
>
> PFA attached patch that prevents user from being returned garbage bytesused value from vb2 framework.
>
> Regards,
> Sudip Jain
>

Patches should never be submitted as attachments, they should be inline.

See Documentation/SubmittingPatches for more info.

[...]

--
- Jeremiah Mahler

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

* Re: 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69
  2015-02-26  5:18   ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69 Sudip JAIN
@ 2015-02-26  8:58     ` Hans Verkuil
  2015-02-26 17:09     ` Jeremiah Mahler
  1 sibling, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2015-02-26  8:58 UTC (permalink / raw)
  To: Sudip JAIN, Jeremiah Mahler; +Cc: linux-media, linux-kernel

Hi Jeremiah,

On 02/26/15 06:18, Sudip JAIN wrote:
> Hello Jeremiah,
> 
> Please find the patch  "inline"
> 
> commit 3390900680e5182998916c8fa231bc79cd84046b
> Author: Sudip Jain <sudip.jain@st.com>
> Date:   Thu Feb 26 10:40:34 2015 +0530
> 
>     media: vb2: Fill vb2_buffer with bytesused from user
>     
>     In vb2_qbuf for dmabuf memory type, userside bytesused is not read to
>     vb2 buffer. This leads garbage value being copied from __qbuf_dmabuf()
>     back to user in __fill_v4l2_buffer().
>     
>     As a default case, the vb2 framework must trust the userside value,
>     and also allow driver's buffer prepare function prefer modify/update
>     or not to.
>     
>     Applied on kernel version 3.10.69

This kernel is way, way too old. If you provide a patch then you should
use the latest released kernel, or, even better, the master branch of the
media development git repository: http://git.linuxtv.org/cgit.cgi/media_tree.git/

Also, bytesused only needs to be set for output buffers, never for capture
buffers: the driver will set bytesused when a frame is captured. So this
patch makes no sense.

Regards,

	Hans

>     
>     Change-Id: Ieda389403898935f59c2e2994106f3e5238cfefd
>     Signed-off-by: Sudip Jain <sudip.jain@st.com>
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index 5e47ba4..54fe9c9 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -919,6 +919,8 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
>                                         b->m.planes[plane].m.fd;
>                                 v4l2_planes[plane].length =
>                                         b->m.planes[plane].length;
> +                               v4l2_planes[plane].bytesused =
> +                                       b->m.planes[plane].bytesused;
>                                 v4l2_planes[plane].data_offset =
>                                         b->m.planes[plane].data_offset;
>                         }
> @@ -943,6 +945,7 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
>                 if (b->memory == V4L2_MEMORY_DMABUF) {
>                         v4l2_planes[0].m.fd = b->m.fd;
>                         v4l2_planes[0].length = b->length;
> +                       v4l2_planes[0].bytesused = b->bytesused;
>                         v4l2_planes[0].data_offset = 0;
>                 }
> 
> Thanks,
> Sudip


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

* Re: 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69
  2015-02-26  5:18   ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69 Sudip JAIN
  2015-02-26  8:58     ` Hans Verkuil
@ 2015-02-26 17:09     ` Jeremiah Mahler
  2015-02-27  6:25       ` Sudip JAIN
  1 sibling, 1 reply; 7+ messages in thread
From: Jeremiah Mahler @ 2015-02-26 17:09 UTC (permalink / raw)
  To: Sudip JAIN; +Cc: linux-media, linux-kernel

Sudip,

On Thu, Feb 26, 2015 at 01:18:31PM +0800, Sudip JAIN wrote:
> Hello Jeremiah,
> 
> Please find the patch  "inline"
> 
There are more problems than just not being "inline".

- The subject line wrong.
- The log message is formatted wrong.
- This patch is not in a form that can be applied.
- And there are probably more problems as well...

I would review how to submit patches and then try again.
I recommend watching the video by Greg Kroah-Hartman on how
to submit your first kernel patch [1].

  [1]: https://www.youtube.com/watch?v=LLBrBBImJt4

[...]

-- 
- Jeremiah Mahler

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

* RE: 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69
  2015-02-26 17:09     ` Jeremiah Mahler
@ 2015-02-27  6:25       ` Sudip JAIN
  0 siblings, 0 replies; 7+ messages in thread
From: Sudip JAIN @ 2015-02-27  6:25 UTC (permalink / raw)
  To: Jeremiah Mahler; +Cc: linux-media, linux-kernel

Thanks for your feedback. I will improve my patch submission.

BR,
Sudip
________________________________________
From: Jeremiah Mahler [jmmahler@gmail.com]
Sent: Thursday, February 26, 2015 10:39 PM
To: Sudip JAIN
Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69

Sudip,

On Thu, Feb 26, 2015 at 01:18:31PM +0800, Sudip JAIN wrote:
> Hello Jeremiah,
>
> Please find the patch  "inline"
>
There are more problems than just not being "inline".

- The subject line wrong.
- The log message is formatted wrong.
- This patch is not in a form that can be applied.
- And there are probably more problems as well...

I would review how to submit patches and then try again.
I recommend watching the video by Greg Kroah-Hartman on how
to submit your first kernel patch [1].

  [1]: https://www.youtube.com/watch?v=LLBrBBImJt4

[...]

--
- Jeremiah Mahler

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

end of thread, other threads:[~2015-02-27  6:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-25  7:29 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch Sudip JAIN
2015-02-25 18:23 ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch Jeremiah Mahler
2015-02-25 19:44   ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch Jean-Michel Hautbois
2015-02-26  5:18   ` 0001-media-vb2-Fill-vb2_buffer-with-bytesused-from-user.patch; kernel version 3.10.69 Sudip JAIN
2015-02-26  8:58     ` Hans Verkuil
2015-02-26 17:09     ` Jeremiah Mahler
2015-02-27  6:25       ` Sudip JAIN

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).