lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080527125041.0fc28fd4@infradead.org>
Date:	Tue, 27 May 2008 12:50:41 -0700
From:	Arjan van de Ven <arjan@...radead.org>
To:	Mauro Carvalho Chehab <mchehab@...radead.org>
Cc:	Jonathan Corbet <corbet@....net>, Alan Cox <alan@...hat.com>,
	video4linux-list@...hat.com, linux-kernel@...r.kernel.org,
	Alan Cox <alan@...rguk.ukuu.org.uk>
Subject: Re: [PATCH] video4linux: Push down the BKL

On Tue, 27 May 2008 15:59:42 -0300
Mauro Carvalho Chehab <mchehab@...radead.org> wrote:

> On Tue, 27 May 2008 10:37:55 -0600
> Jonathan Corbet <corbet@....net> wrote:
> 
> > On Tue, 27 May 2008 13:31:00 -0300
> > Mauro Carvalho Chehab <mchehab@...radead.org> wrote:
> > 
> > > Since the other methods don't explicitly call BKL (and, AFAIK,
> > > kernel open handler don't call it neither), if a program 1 is
> > > opening a device and initializing some data, and a program 2
> > > starts doing ioctl, interrupting program 1 execution in the
> > > middle of a data initialization procedure, you may have a race
> > > condition, since some devices initialize some device global data
> > > during open [1].
> > 
> > In fact, 2.6.26 and prior kernels *do* acquire the BKL on open (for
> > char devices) - that's the behavior that the bkl-removal tree is
> > there to do away with.  So, for example, I've pushed that
> > acquisition down into video_open() instead. 
> > 
> > So, for now, open() is serialized against ioctl() in video
> > drivers.  As soon as you take the BKL out of ioctl(), though, that
> > won't happen, unless the mutex you use is also acquired in the open
> > path.
> 
> Ok.
> 
> A few drivers seem to be almost read to work without BKL. 
> 
> For example, em28xx has already a lock at the operations that change
> values at "dev" struct, including open() method. However, since the
> lock is not called at get operations, it needs to be fixed. I would
> also change it from mutex to a read/write semaphore, since two (or
> more) get operations can safely happen in parallel.
> 
\

please don't use rw/sems just because there MIGHT be parallel.
THey're more expensive than mutexes by quite a bit and you get a lot
less checking from lockdep. They make sense for very specific, very
read biased, contended cases. But please don't use them "just
because"...

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ