From: Roland Dreier <roland@digitalvampire.org>
To: Laurent Pinchart <laurent.pinchart@skynet.be>
Cc: Romano Giannetti <romano@dea.icai.upcomillas.es>,
linux-kernel@vger.kernel.org, linux-uvc-devel@berlios.de
Subject: Re: Linux 2.6.26-rc9 circular lock with uvcvideo on resume from hibernation
Date: Wed, 09 Jul 2008 12:53:26 -0700 [thread overview]
Message-ID: <87mykq96mh.fsf@shaolin.home.digitalvampire.org> (raw)
In-Reply-To: <200807092129.03679.laurent.pinchart@skynet.be> (Laurent Pinchart's message of "Wed, 9 Jul 2008 21:29:03 +0200")
> uvc_disconnect() | uvc_v4l2_open()
> ... |
> mutex_lock(&uvc_driver.open_mutex); |
> dev->state |= UVC_DEV_DISCONNECTED; |
> mutex_unlock(&uvc_driver.open_mutex); |
> |
> | mutex_lock(&uvc_driver.open_mutex);
> | vdev = video_devdata(file);
> | video = video_get_drvdata(vdev);
> |
> kref_put(&dev->kref, uvc_delete); |
> |
> | if (video->dev->state...)
>
> kref_put() in uvc_disconnect() will call uvc_delete(), which will in turn free
> the video structure. uvc_v4l2_open() will then dereference freed memory when
> testing the device state.
I don't believe this is correct. I tried to explain it in my
changelog by saying "uvc_delete() does uvc_unregister_video() (and
hence video_unregister_device(), which is synchronized with
videodev_lock) as its first thing, so there is no risk of
use-after-free in uvc_v4l2_open()."
In other words, the first thing uvc_delete() does is call
uvc_unregister_video(), which will video_unregister_device(). Since
this needs to take videodev_lock, it will wait until uvc_v4l2_open()
returns (which it will do, since state is now UVC_DEV_DISCONNECTED).
So the video struct will not be freed until after uvc_v4l2_open()
returns.
As far as I can see there is no use-after-free.
- R.
--
Roland Dreier <roland@digitalvampire.org> GPG Key: 1024D/E0EEFAC0
Fingerprint: A89F B5E9 C185 F34D BD50 4009 37E2 25CC E0EE FAC0
Sending >500KB attachments is forbidden by the Geneva Convention.
Your country may be at risk if you fail to comply.
next prev parent reply other threads:[~2008-07-09 19:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-07 10:34 Romano Giannetti
2008-07-07 17:40 ` Roland Dreier
2008-07-09 19:29 ` Laurent Pinchart
2008-07-09 19:53 ` Roland Dreier [this message]
2008-07-09 20:10 ` Laurent Pinchart
2008-07-09 20:17 ` Roland Dreier
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=87mykq96mh.fsf@shaolin.home.digitalvampire.org \
--to=roland@digitalvampire.org \
--cc=laurent.pinchart@skynet.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-uvc-devel@berlios.de \
--cc=romano@dea.icai.upcomillas.es \
/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®