Re: [PATCH -stable] kthreads: fix kthread_create() vs kthread_stop() race

From: Rusty Russell
Date: Tue Aug 25 2009 - 10:36:20 EST


On Mon, 24 Aug 2009 08:15:29 pm Oleg Nesterov wrote:
> The bug should be "accidently" fixed by recent changes in 2.6.31,
> all kernels <= 2.6.30 need the fix. The problem was never noticed before,
> it was found because it causes mysterious failures with GFS mount/umount.
>
> Credits to Robert Peterson. He blaimed kthread.c from the very beginning.
> But, despite my promise, I forgot to inspect the old implementation until
> he did a lot of testing and reminded me. This led to huge delay in fixing
> this bug.
>
> kthread_stop() does put_task_struct(k) before it clears kthread_stop_info.k.
> This means another kthread_create() can re-use this task_struct, but the
> new kthread can still see kthread_should_stop() == T and exit even without
> calling threadfn().
>
> Reported-by: Robert Peterson <rpeterso@xxxxxxxxxx>
> Tested-by: Robert Peterson <rpeterso@xxxxxxxxxx>
> Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>

Acked-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>

Thanks, good catch!
Rusty.
--
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/