mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Cc: Laurent Pinchart <laurent.pinchart@skynet.be>,
	linux-uvc-devel@lists.berlios.de,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [Linux-uvc-devel] [BUG] NULL pointer dereference caused by uvcvideo stress test
Date: Fri, 24 Oct 2008 12:31:29 -0200	[thread overview]
Message-ID: <20081024123129.3c373b90@pedra.chehab.org> (raw)
In-Reply-To: <48F710F7.9030608@tuffmail.co.uk>

On Thu, 16 Oct 2008 11:01:27 +0100
Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:

> Laurent Pinchart wrote:
> > Hi Alan,
> >
> > On Wednesday 15 October 2008, Alan Jenkins wrote:
> >   
> >> Laurent Pinchart wrote:
> >>     
> >>> On Wednesday 15 October 2008, Alan Jenkins wrote:
> >>>       
> >>>> If you look at the trace, it happens as "hald-probe-video" opens the
> >>>> video device.  This is from Ubuntu 8.04.  Possibly it's significant that
> >>>> I use the camera first, to make sure it works (I use Kopete, the
> >>>> settings dialogue includes a video test).
> >>>>         
> >>> The NULL pointer (or rather 0x00000030 pointer) dereference happens in
> >>> video_open:
> >>>
> >>>         file->f_op = fops_get(vfl->fops);
> >>>         if (file->f_op->open)
> >>>                 err = file->f_op->open(inode, file);
> >>>
> >>> file->f_op ends up being NULL. Either vfl->fops is NULL to begin with, or
> >>> fops_get failed to get a reference to the file_operations structure.
> >>>
> >>> I'd be surprised if vfl->fops was NULL. To rule out that case, can you
> >>> add a BUG_ON(vfl->fops == NULL) before the call to fops_get ?
> >>>
> >>> I'm not too familiar with the module loader, but a quick look at the code
> >>> shows that the module could be marked as being unloaded
> >>> (MODULE_STATE_GOING) before its exit function is called. If this is the
> >>> case video_open would still be called, as the video device would still be
> >>> registered, but fops_get would fail in try_module_get and return a NULL
> >>> pointer. It seems the pointer returned by fops_get should be tested in
> >>> video_open.
> >>>
> >>> I've CC'ed the v4l maintainer to get his opinion on this.

Sorry for being late with this. Too much work here...

I suspect that you only hit this bug due to BKL removal from open/close fops.
maybe you're calling open() before having the device fully initialized?

Anyway, I think that the proposed check is interesting on other places where
there are similar code.

Cheers,
Mauro

  parent reply	other threads:[~2008-10-24 14:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <gbiduj$9p3$1@ger.gmane.org>
     [not found] ` <200810151417.14661.laurent.pinchart@skynet.be>
2008-10-15 16:43   ` Alan Jenkins
2008-10-15 18:17     ` Laurent Pinchart
2008-10-15 18:54       ` Alan Jenkins
2008-10-15 21:19         ` Laurent Pinchart
2008-10-16 10:01           ` Alan Jenkins
2008-10-16 12:03             ` Laurent Pinchart
2008-10-16 12:22               ` Alan Jenkins
2008-10-24 14:31             ` Mauro Carvalho Chehab [this message]
2008-10-25 11:19               ` Laurent Pinchart

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=20081024123129.3c373b90@pedra.chehab.org \
    --to=mchehab@infradead.org \
    --cc=alan-jenkins@tuffmail.co.uk \
    --cc=laurent.pinchart@skynet.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-uvc-devel@lists.berlios.de \
    /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

all inboxes | Powered by JetHome®