On Tue, 27 May 2008 09:41:44 -0600
Jonathan Corbet <corbet@lwn.net> wrote:
True, but on a quick analysis, I suspect that this is already somewhat broken
on some drivers.
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].
[1] For example: cx88 and saa7134 will change some data structures if you open
a device via /dev/radio or via /dev/video. So, if program 1 opens as radio and
program 2 opens as video, you may have a race condition. A way to fix this is to
initialize such structs only by the first program that is opening the device,
and serialize a concurrent open.
True. Yet, just looking at the code may not be enough, since people make
mistakes. The recent changes at videobuf lock showed this. The lock fix
patches caused several new locking issues.
It is safer to have a tool to test and stress the driver before going to
production.
Cheers,
Mauro
--