Re: indydog driver race

From: Guido Guenther (agx@sigxcpu.org)
Date: Wed Mar 27 2002 - 11:20:50 EST


On Tue, Mar 26, 2002 at 10:01:40AM -0800, Dave Hansen wrote:
> indydog_open has a race
>
> indydog_open(struct inode *inode, struct file *file)
> {
> if( indydog_alive )
> return -EBUSY;
> ...
> indydog_alive = 1;
> return 0;
> }
>
> If 2 opens happen simultaneously, there can be 2 tasks which both see
> indydog_alive as 0 and both set it to 1, successfully opening the
> device. Block and char devices hold the BKL before calling the driver's
> open function, but misc devices don't do the same.
As Dave and me discussed in private mail this can't actually happen on
non-preemtible kernels since IP22 is non-SMP(which is why I didn't
bother when I wrote it). Anyway, a race is a race, no excuses.

>
> The BKL is not needed in the release function, as far as I can see.
> Alan's softdog.c driver uses atomic ops without BKL to do the same thing
> as your driver. Patch to fix attached.
Tested and works on Mips/IP22. Thanks again Dave,
 -- Guido
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Mar 31 2002 - 22:00:13 EST