Commit 6b187337 authored by Richard Weinberger's avatar Richard Weinberger

um: Fix waitpid() usage in helper code

If UML is executing a helper program it is using
waitpid() with the __WCLONE flag to wait for the program
as the helper is executed from a clone()'ed thread.
While using __WCLONE is perfectly fine for clone()'ed
childs it won't detect terminated childs if the helper
has issued an execve().

We have to use __WALL to wait for both clone()'ed and
regular childs to detect the termination before and
after an execve().
Reported-and-tested-by: default avatarThomas Meyer <thomas@m3y3r.de>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 37e81a01
...@@ -96,7 +96,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv) ...@@ -96,7 +96,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
"ret = %d\n", -n); "ret = %d\n", -n);
ret = n; ret = n;
} }
CATCH_EINTR(waitpid(pid, NULL, __WCLONE)); CATCH_EINTR(waitpid(pid, NULL, __WALL));
} }
out_free2: out_free2:
...@@ -129,7 +129,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, ...@@ -129,7 +129,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
return err; return err;
} }
if (stack_out == NULL) { if (stack_out == NULL) {
CATCH_EINTR(pid = waitpid(pid, &status, __WCLONE)); CATCH_EINTR(pid = waitpid(pid, &status, __WALL));
if (pid < 0) { if (pid < 0) {
err = -errno; err = -errno;
printk(UM_KERN_ERR "run_helper_thread - wait failed, " printk(UM_KERN_ERR "run_helper_thread - wait failed, "
...@@ -148,7 +148,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, ...@@ -148,7 +148,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
int helper_wait(int pid) int helper_wait(int pid)
{ {
int ret, status; int ret, status;
int wflags = __WCLONE; int wflags = __WALL;
CATCH_EINTR(ret = waitpid(pid, &status, wflags)); CATCH_EINTR(ret = waitpid(pid, &status, wflags));
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment