All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM
@ 2009-03-18 17:48 Németh Márton
  2009-03-18 21:45 ` David Ellingsworth
  0 siblings, 1 reply; 8+ messages in thread
From: Németh Márton @ 2009-03-18 17:48 UTC (permalink / raw)
  To: Jean-Francois Moine, linux-media; +Cc: LKML

From: Márton Németh <nm127@freemail.hu>

The gspca webcam driver does not check the .type field of struct v4l2_streamparm.
This field is an input parameter for the driver according to V4L2 API specification,
revision 0.24 [1]. Add the missing check.

The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver
and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with
v4l-test 0.10.

References:
[1] V4L2 API specification, revision 0.24
    http://v4l2spec.bytesex.org/spec/r11680.htm

[2] v4l-test: Test environment for Video For Linux Two API
    http://v4l-test.sourceforge.net/

Signed-off-by: Márton Németh <nm127@freemail.hu>
---
--- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig	2009-03-14 12:29:38.000000000 +0100
+++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c	2009-03-18 16:51:03.000000000 +0100
@@ -1320,6 +1320,9 @@ static int vidioc_g_parm(struct file *fi
 {
 	struct gspca_dev *gspca_dev = priv;

+	if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;
+
 	memset(parm, 0, sizeof *parm);
 	parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 	parm->parm.capture.readbuffers = gspca_dev->nbufread;


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

* Re: [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM
  2009-03-18 17:48 [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM Németh Márton
@ 2009-03-18 21:45 ` David Ellingsworth
  2009-03-19  5:50   ` Németh Márton
  0 siblings, 1 reply; 8+ messages in thread
From: David Ellingsworth @ 2009-03-18 21:45 UTC (permalink / raw)
  To: Németh Márton; +Cc: Jean-Francois Moine, linux-media, LKML

2009/3/18 Németh Márton <nm127@freemail.hu>:
> From: Márton Németh <nm127@freemail.hu>
>
> The gspca webcam driver does not check the .type field of struct v4l2_streamparm.
> This field is an input parameter for the driver according to V4L2 API specification,
> revision 0.24 [1]. Add the missing check.
>
> The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver
> and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with
> v4l-test 0.10.
>
> References:
> [1] V4L2 API specification, revision 0.24
>    http://v4l2spec.bytesex.org/spec/r11680.htm
>
> [2] v4l-test: Test environment for Video For Linux Two API
>    http://v4l-test.sourceforge.net/
>
> Signed-off-by: Márton Németh <nm127@freemail.hu>
> ---
> --- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig     2009-03-14 12:29:38.000000000 +0100
> +++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c  2009-03-18 16:51:03.000000000 +0100
> @@ -1320,6 +1320,9 @@ static int vidioc_g_parm(struct file *fi
>  {
>        struct gspca_dev *gspca_dev = priv;
>
> +       if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +               return -EINVAL;
> +
>        memset(parm, 0, sizeof *parm);
>        parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
^^^^^^^^^^^^^^^^^^^
This line should be deleted as it's no longer needed.

>        parm->parm.capture.readbuffers = gspca_dev->nbufread;
>

Regards,

David Ellingsworth

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

* Re: [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM
  2009-03-18 21:45 ` David Ellingsworth
@ 2009-03-19  5:50   ` Németh Márton
  2009-03-19  6:52     ` Németh Márton
  2009-03-19  7:34     ` Trent Piepho
  0 siblings, 2 replies; 8+ messages in thread
From: Németh Márton @ 2009-03-19  5:50 UTC (permalink / raw)
  To: David Ellingsworth; +Cc: Jean-Francois Moine, linux-media, LKML

David Ellingsworth wrote:
> 2009/3/18 Németh Márton <nm127@freemail.hu>:
>> From: Márton Németh <nm127@freemail.hu>
>>
>> The gspca webcam driver does not check the .type field of struct v4l2_streamparm.
>> This field is an input parameter for the driver according to V4L2 API specification,
>> revision 0.24 [1]. Add the missing check.
>>
>> The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver
>> and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with
>> v4l-test 0.10.
>>
>> References:
>> [1] V4L2 API specification, revision 0.24
>>    http://v4l2spec.bytesex.org/spec/r11680.htm
>>
>> [2] v4l-test: Test environment for Video For Linux Two API
>>    http://v4l-test.sourceforge.net/
>>
>> Signed-off-by: Márton Németh <nm127@freemail.hu>
>> ---
>> --- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig     2009-03-14 12:29:38.000000000 +0100
>> +++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c  2009-03-18 16:51:03.000000000 +0100
>> @@ -1320,6 +1320,9 @@ static int vidioc_g_parm(struct file *fi
>>  {
>>        struct gspca_dev *gspca_dev = priv;
>>
>> +       if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
>> +               return -EINVAL;
>> +
>>        memset(parm, 0, sizeof *parm);
>>        parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> ^^^^^^^^^^^^^^^^^^^
> This line should be deleted as it's no longer needed.

Because memset() clears the whole parm structure this line is necessary. In other
drivers the following code is there:

    tmp = parm->type;
    memset(parm, 0, sizeof(*parm));
    parm->type = parm;

Maybe changing the code similar to this would be easier to read?

	Márton Németh

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

* Re: [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM
  2009-03-19  5:50   ` Németh Márton
@ 2009-03-19  6:52     ` Németh Márton
  2009-03-19  7:34     ` Trent Piepho
  1 sibling, 0 replies; 8+ messages in thread
From: Németh Márton @ 2009-03-19  6:52 UTC (permalink / raw)
  To: David Ellingsworth, Jean-Francois Moine; +Cc: linux-media, LKML

Németh Márton wrote:
From: Márton Németh <nm127@freemail.hu>

The gspca webcam driver does not check the .type field of struct v4l2_streamparm.
This field is an input parameter for the driver according to V4L2 API specification,
revision 0.24 [1]. Add the missing check.

The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver
and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with
v4l-test 0.10.

References:
[1] V4L2 API specification, revision 0.24
   http://v4l2spec.bytesex.org/spec/r11680.htm

[2] v4l-test: Test environment for Video For Linux Two API
    http://v4l-test.sourceforge.net/

Signed-off-by: Márton Németh <nm127@freemail.hu>
---
--- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig	2009-03-14 12:29:38.000000000 +0100
+++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c	2009-03-19 07:14:40.000000000 +0100
@@ -1319,9 +1319,14 @@ static int vidioc_g_parm(struct file *fi
 			struct v4l2_streamparm *parm)
 {
 	struct gspca_dev *gspca_dev = priv;
+	enum v4l2_buf_type type;

+	if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;
+
+	type = parm->type;
 	memset(parm, 0, sizeof *parm);
-	parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	parm->type = type;
 	parm->parm.capture.readbuffers = gspca_dev->nbufread;

 	if (gspca_dev->sd_desc->get_streamparm) {

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

* Re: [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM
  2009-03-19  5:50   ` Németh Márton
  2009-03-19  6:52     ` Németh Márton
@ 2009-03-19  7:34     ` Trent Piepho
  2009-03-19 22:14       ` Németh Márton
  1 sibling, 1 reply; 8+ messages in thread
From: Trent Piepho @ 2009-03-19  7:34 UTC (permalink / raw)
  To: Németh Márton
  Cc: David Ellingsworth, Jean-Francois Moine, linux-media, LKML

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 1879 bytes --]

On Thu, 19 Mar 2009, [ISO-8859-1] Németh Márton wrote:
> David Ellingsworth wrote:
> > 2009/3/18 Németh Márton <nm127@freemail.hu>:
> >> From: Márton Németh <nm127@freemail.hu>
> >>
> >> The gspca webcam driver does not check the .type field of struct v4l2_streamparm.
> >> This field is an input parameter for the driver according to V4L2 API specification,
> >> revision 0.24 [1]. Add the missing check.
> >>
> >> The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver
> >> and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with
> >> v4l-test 0.10.
> >>
> >> References:
> >> [1] V4L2 API specification, revision 0.24
> >>    http://v4l2spec.bytesex.org/spec/r11680.htm
> >>
> >> [2] v4l-test: Test environment for Video For Linux Two API
> >>    http://v4l-test.sourceforge.net/
> >>
> >> Signed-off-by: Márton Németh <nm127@freemail.hu>
> >> ---
> >> --- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig     2009-03-14 12:29:38.000000000 +0100
> >> +++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c  2009-03-18 16:51:03.000000000 +0100
> >> @@ -1320,6 +1320,9 @@ static int vidioc_g_parm(struct file *fi
> >>  {
> >>        struct gspca_dev *gspca_dev = priv;
> >>
> >> +       if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> >> +               return -EINVAL;
> >> +
> >>        memset(parm, 0, sizeof *parm);
> >>        parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> > ^^^^^^^^^^^^^^^^^^^
> > This line should be deleted as it's no longer needed.
>
> Because memset() clears the whole parm structure this line is necessary. In other
> drivers the following code is there:
>
>     tmp = parm->type;
>     memset(parm, 0, sizeof(*parm));
>     parm->type = parm;

The memset isn't needed anymore either, I put it into v4l2_ioctl.  I
removed most of the code like that but I may have missed some drivers.

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

* Re: [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM
  2009-03-19  7:34     ` Trent Piepho
@ 2009-03-19 22:14       ` Németh Márton
  2009-03-20  0:47         ` Trent Piepho
  0 siblings, 1 reply; 8+ messages in thread
From: Németh Márton @ 2009-03-19 22:14 UTC (permalink / raw)
  To: Jean-Francois Moine; +Cc: Trent Piepho, David Ellingsworth, linux-media, LKML

From: Márton Németh <nm127@freemail.hu>

The gspca webcam driver does not check the .type field of struct v4l2_streamparm.
This field is an input parameter for the driver according to V4L2 API specification,
revision 0.24 [1]. Add the missing check.

The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver
and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with
v4l-test 0.10.

The memset() is not necessary as V4L2 framework already have done this task when
vidioc_g_parm() is called.

References:
[1] V4L2 API specification, revision 0.24
    http://v4l2spec.bytesex.org/spec/r11680.htm

[2] v4l-test: Test environment for Video For Linux Two API
    http://v4l-test.sourceforge.net/

Signed-off-by: Márton Németh <nm127@freemail.hu>
---
--- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig	2009-03-14 12:29:38.000000000 +0100
+++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c	2009-03-19 20:38:22.000000000 +0100
@@ -1320,8 +1320,9 @@ static int vidioc_g_parm(struct file *fi
 {
 	struct gspca_dev *gspca_dev = priv;

-	memset(parm, 0, sizeof *parm);
-	parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;
+
 	parm->parm.capture.readbuffers = gspca_dev->nbufread;

 	if (gspca_dev->sd_desc->get_streamparm) {

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

* Re: [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM
  2009-03-19 22:14       ` Németh Márton
@ 2009-03-20  0:47         ` Trent Piepho
  2009-03-27 10:42           ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 8+ messages in thread
From: Trent Piepho @ 2009-03-20  0:47 UTC (permalink / raw)
  To: Németh Márton
  Cc: Jean-Francois Moine, David Ellingsworth, linux-media, LKML

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 590 bytes --]

On Thu, 19 Mar 2009, [UTF-8] Németh Márton wrote:
> The gspca webcam driver does not check the .type field of struct v4l2_streamparm.
> This field is an input parameter for the driver according to V4L2 API specification,
> revision 0.24 [1]. Add the missing check.

I think this check could go in the v4l2 core too.  It already does a
similar check for QUERYBUF, QBUF, DQBUF, etc.  If the driver doesn't
provide a method for ->vidioc_try_fmt_foo() then the v4l2 core will reject
a call with .type == V4L2_BUF_TYPE_foo.

It seems like it should be ok to do this for S_PARM and G_PARM too.

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

* Re: [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM
  2009-03-20  0:47         ` Trent Piepho
@ 2009-03-27 10:42           ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 8+ messages in thread
From: Mauro Carvalho Chehab @ 2009-03-27 10:42 UTC (permalink / raw)
  To: Trent Piepho
  Cc: Németh Márton, Jean-Francois Moine, David Ellingsworth,
	linux-media, LKML

On Thu, 19 Mar 2009 17:47:13 -0700 (PDT)
Trent Piepho <xyzzy@speakeasy.org> wrote:

> On Thu, 19 Mar 2009, [UTF-8] Németh Márton wrote:
> > The gspca webcam driver does not check the .type field of struct v4l2_streamparm.
> > This field is an input parameter for the driver according to V4L2 API specification,
> > revision 0.24 [1]. Add the missing check.
> 
> I think this check could go in the v4l2 core too.  It already does a
> similar check for QUERYBUF, QBUF, DQBUF, etc.  If the driver doesn't
> provide a method for ->vidioc_try_fmt_foo() then the v4l2 core will reject
> a call with .type == V4L2_BUF_TYPE_foo.
> 
> It seems like it should be ok to do this for S_PARM and G_PARM too.

I agree. Could you provide such patch?

Cheers,
Mauro

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

end of thread, other threads:[~2009-03-27 10:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-18 17:48 [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM Németh Márton
2009-03-18 21:45 ` David Ellingsworth
2009-03-19  5:50   ` Németh Márton
2009-03-19  6:52     ` Németh Márton
2009-03-19  7:34     ` Trent Piepho
2009-03-19 22:14       ` Németh Márton
2009-03-20  0:47         ` Trent Piepho
2009-03-27 10:42           ` Mauro Carvalho Chehab

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.