Re: more signal locking bugs?

Linus Torvalds
2003-02-16T19:17:56Z

On Sun, 16 Feb 2003, Martin J. Bligh wrote:
>
> task_lock nests *inside* tasklist_lock but ... :

Yeah, this is a problem with any signal, not just SAK.

In fact, in general it is always _wrong_ to nest a non-interrupt-safe
lock inside an interrupt-safe spinlock, because then you can never take
the non-interrupt-safe one on its own (because an interrupt may come in
and take the interrupt-safe lock, at which point that CPU has now
violated ordering).

And if you always nest the interrupt-unsafee one inside the interrupt-
safe one, you might as well not have the interrupt-unsafe one in the first
place, since the outer lock _always_ protects the code in question anyway.

Which implies that either
- the task lock should be _outside_ the tasklist_lock
or
- the task lock should be made interrupt-safe.

If we make the tasklock one interrupt-safe, that should fix the signal
issue, and we can use the tasklock to protect "task->signal" and
"task->sighand".

In short, everything really seems to be pointing that way: the current
task lock simply _is_ broken, and has apparently always been broken (but
the ABBA deadlock is just extremely rare in practice, since you have to
get an interrupt at just the right point on one CPU, while you have the AB
case on another).

Linus