Re: alpha: potential race around hae_cache in RESTORE_ALL

From: Linus Torvalds
Date: Sat Sep 25 2010 - 14:43:10 EST


On Sat, Sep 25, 2010 at 11:13 AM, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>        What happens if we get to RESTORE_ALL with interrupts enabled,
> find that we want to restore HAE, get to
>        stq     $21, HAE_CACHE($19);    \
> and get hit by an interrupt right after that assignment?

Ok, so it's been absolutely ages since I touched the HAE stuff, but I
think the logic was that interrupts will always restore HAE to the
pre-interrupt state on exit, so reading it was always supposedly
race-free and didn't need any protection from normal code.

But yes, any actual _changes_ to HAE had better protect against
interrupts, so that they don't see the half-done state.

So yes, I think you found a bug.

I also don't see why that crazy RESTORE_ALL code does that reload of
$0 and $1 when it updates HAE. Is that just legacy from it having
_used_ to do the swipl PAL-call and that trashed those registers?

Anyway, I think the fix should be that we really always do have
interrupts disabled in RESTORE_ALL, rather than re-introduce the swipl
into the RESTORE_ALL sequence. A lot of the critical sequences already
do that - notably the normal return-to-user space code sequence that
is the really critical one.

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