Re: [PATCH] Revert "kmod: fix race in usermodehelper code"

From: Neil Horman
Date: Wed Sep 23 2009 - 20:16:15 EST


On Thu, Sep 24, 2009 at 01:02:55AM +0200, Sebastian Andrzej Siewior wrote:
> This reverts commit c02e3f361:
> |Author: Neil Horman <nhorman@xxxxxxxxxxxxx>
> |Date: Tue Sep 22 16:43:36 2009 -0700
> |
> | kmod: fix race in usermodehelper code
> |
> | The user mode helper code has a race in it. call_usermodehelper_exec()
> | takes an allocated subprocess_info structure, which it passes to a
> | workqueue, and then passes it to a kernel thread which it creates, after
> | which it calls complete to signal to the caller of
> | call_usermodehelper_exec() that it can free the subprocess_info struct.
> |
> | But since we use that structure in the created thread, we can't call
> | complete from __call_usermodehelper(), which is where we create the kernel
> | thread. We need to call complete() from within the kernel thread and then
> | not use subprocess_info afterward in the case of UMH_WAIT_EXEC. Tested
> | successfully by me.
> |
> | Signed-off-by: Neil Horman <nhorman@xxxxxxxxxxxxx>
> | Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
> | Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> | Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
>
> The pach is wrong IMHO. UMH_WAIT_EXEC is called with VFORK what ensures
> that the child finishes prior returing back to the parent. No race. The patch
> makes it even worse because it does the thing it claims not do:
Dang, you're right. I completely missed the use of CLONE_VFORK as a mechanism
to prevent the parent from racing ahead of the child. Sorry for the noise.
Neil

>
--
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/