Re: [PATCH -rt] race condition in fs/compat.c with compat_sys_ioctl

Steven Rostedt
2005-11-16T09:41:01Z

On Wed, 2005-11-16 at 09:32 +0100, Ingo Molnar wrote:
> * Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > down_read(&ioctl32_sem);
> > for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) {
> > - if (t->cmd == cmd)
> > + if (t->cmd == cmd) {
> > + handler = t->handler;
> > + up_read(&ioctl32_sem);
> > goto found_handler;
> > + }
> > }
> > up_read(&ioctl32_sem);
>
> i think this problem only triggers on RT kernels, because the RT kernel
> only allows a single reader within a read-semaphore. This works well in
> 99.9% of the cases. You just found the remaining 0.1% :-| The better
> solution within -rt would be to change ioctl32_sem to a compat
> semaphore, via the patch below. Can you confirm that this solves the
> bootup problem too?
>

ACK:

Well duh! OK, I blame lack of sleep on missing the obvious (and getting
up at 4am to go to the bathroom, and then responding to this doesn't
help ;)

I just applied this patch and it works. I didn't even notice the word
"read" in down_read and up_read, otherwise I would have sent you this
patch. I was just so frustrated at getting this to work that I just
assumed that this was a normal down and up. Oh well. At least now I
don't have to see why this works in the non-rt case.

Thanks Ingo, yes go ahead and apply your patch. That is definitely a
better solution.

-- Steve