From: "Németh Márton" <nm127@freemail.hu>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: V4L Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH] libv4l: add NULL pointer check
Date: Mon, 31 Aug 2009 07:51:28 +0200 [thread overview]
Message-ID: <4A9B64E0.9040003@freemail.hu> (raw)
In-Reply-To: <200908302333.20933.laurent.pinchart@ideasonboard.com>
Laurent Pinchart wrote:
> On Sunday 30 August 2009 10:56:16 Németh Márton wrote:
>> From: Márton Németh <nm127@freemail.hu>
>>
>> Add NULL pointer check before the pointers are dereferenced.
>
> Applications are not supposed to pass NULL pointers to those functions. It
> would be an API violation. Instead of silently failing a segfault is better.
Actually we cannot speak about API violation because the behaviour when
passing NULL pointer as ioctl() argument is not defined as of V4L2 API
revision 0.29 available from http://linuxtv.org/hg/v4l-dvb/ . The current
implemention in Linux in kernel space is to return -EACCESS.
I don't really agree with the segfault behaviour, because:
- currently there is a different behaviour when just using the V4L2
interface and using the libv4l2 0.6.0. When using the kernel interface
it is an error in kernelspace if a NULL pointer is dereferenced, thus
kernel will return -EACCESS. When the libv4l2 0.6.0 is used then the
behaviour changes: currently there is a segfault instead of getting
a return value -1 and errno=EACCESS.
- the segfault normally results that the whole calling process is
killed. If there is a complex software like a browser, it is not
very user friendly that the whole software crashes just because an
implementation error in the V4L2 handling code.
- currently a lot of V4L2 API ioctls() return -EINVAL or -EFAULT when
passing NULL pointer as a parameter depending on whether the given
ioctl is not supported at all or it is supported but there is a problem
with the passed pointer, respectively. The use case for this would be
that an application could easily scan for the supported and not supported
V4L2 ioctls.
- dereferencing a NULL pointer is not always result segfault, see [1] and
[2]. So dereferencing a NULL pointer can be treated also as a security
risk.
- the patch I sent is only checking the pointer just before it is
dereferenced. When the libv4l just passes the pointer value to the
ioctl() then there is no additional check: this situation will be
handled in kernel space.
These are my arguments. I am open to listen to your arguments.
I think that the final solution could be that the V4L2 API specification
defines what shall happen when NULL pointer is passed as an ioctl() argument.
References:
[1] Jonathan Corbet: Fun with NULL pointers, part 1 (July 20, 2009)
http://lwn.net/Articles/342330/
[2] Jonathan Corbet: Fun with NULL pointers, part 2
http://lwn.net/Articles/342420/
Regards,
Márton Németh
next prev parent reply other threads:[~2009-08-31 5:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-30 8:56 [PATCH] libv4l: add NULL pointer check Németh Márton
2009-08-30 21:33 ` Laurent Pinchart
2009-08-31 5:51 ` Németh Márton [this message]
2009-08-31 6:52 ` Laurent Pinchart
2009-08-31 13:19 ` Mauro Carvalho Chehab
2009-08-31 20:16 ` Laurent Pinchart
2009-08-31 20:36 ` Németh Márton
2009-09-01 8:06 ` Hans de Goede
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=4A9B64E0.9040003@freemail.hu \
--to=nm127@freemail.hu \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
/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