public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ronald S. Bultje" <rbultje@ronald.bitfreak.net>
To: Michael Krufky <mkrufky@m1k.net>
Cc: Johannes Stezenbach <js@linuxtv.org>,
	Andrew Morton <akpm@osdl.org>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Mauro Carvalho Chehab <mauro_chehab@yahoo.com.br>,
	Michael Krufky <mkrufky@linuxtv.org>,
	Linux and Kernel Video <video4linux-list@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: Fw: zoran drivers: absense of locking?
Date: Sat, 29 Oct 2005 00:02:36 -0400	[thread overview]
Message-ID: <1130558556.2822.19.camel@localhost.localdomain> (raw)
In-Reply-To: <4362D420.5040809@m1k.net>

Hi guys,

I maintain the drivers. So, let's see:

On Fri, 2005-10-28 at 21:45 -0400, Michael Krufky wrote:
> >>From: Alexey Dobriyan <adobriyan@gmail.com>
> >>I've tried to read random part of a tree and now scratching my head
> >>with a question:
> >>
> >>	what protects the number and a list of registered codecs in
> >>	zoran drivers?
> >>
> >>Example: drivers/media/video/zr36050.c:
> >>
> >>	/* amount of chips attached via this driver */
> >>	static int zr36050_codecs = 0;
> >>
> >>Decremented in zr36050_unset().
> >>Checked for maximum value, used and incremented in zr36050_setup().
> >>
> >>[Assigment to 0 in zr36050_init_module is not needed. dprintk() in
> >>zr36050_cleanup_module() should be converted to BUG_ON, so I'll ignore
> >>them.]
> >>
> >>	zr36050_codecs
> >>		zr36050_unset()	= struct videocodec::unset
> >>		zr36050_setup()	= struct videocodec::setup
> >>
> >>The only place where ->unset and ->setup methods are called is
> >>drivers/media/video/videocodec.c:
> >>
> >>	zr36050_codecs
> >>		zr36050_unset()
> >>			videocodec_detach()
> >>		zr36050_setup()
> >>			videocodec_attach()
> >>
> >>Both videocodec functions are exported.
> >>
> >>No spinlocks or semaphores in sight.
> >>
> >>Does anybody know what protects the list of registered codecs in zoran
> >>drivers?

So, you're theoretically right, this is indeed a theory problem. Now, in
practice it isn't. Why? Because this isn't an actually exported
documented interface. This means two things: userspace cannot access it
(so no security issue), and other drivers than the ones I maintain won't
use it (so locking issues are limited to my own driver set).

It's an internal interface to the zoran driver (zoran_*.c / zr36067.ko).
The zoran driver uses publically exported interfaces (v4l/v4l2), and
those can be accessed from userspace. The zoran driver uses proper
locking everywhere and ensures that nothing goes wrong (or, well, so I
hope). So since the zoran driver is the only driver accessing zr36050.ko
(through videocodec.ko) and uses proper locking itself already, all's
fine in practice.

If other projects intend to use the videocodec interface, I'll consider
adding locking everywhere. But for now, it's fine, I guess.

Cheers,
Ronald


  reply	other threads:[~2005-10-29  4:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20051028163219.340fa347.akpm@osdl.org>
     [not found] ` <20051029013252.GC15903@linuxtv.org>
2005-10-29  1:45   ` Fw: zoran drivers: absense of locking? Michael Krufky
2005-10-29  4:02     ` Ronald S. Bultje [this message]
2005-10-30 10:03     ` Pauline Middelink

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=1130558556.2822.19.camel@localhost.localdomain \
    --to=rbultje@ronald.bitfreak.net \
    --cc=adobriyan@gmail.com \
    --cc=akpm@osdl.org \
    --cc=js@linuxtv.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mauro_chehab@yahoo.com.br \
    --cc=mkrufky@linuxtv.org \
    --cc=mkrufky@m1k.net \
    --cc=video4linux-list@redhat.com \
    /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