Commit e28e9e3e authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'waitid-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull waitid fix from Al Viro.

* 'waitid-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fix waitid(2) breakage
parents f263fbb8 634a8160
...@@ -1590,9 +1590,6 @@ static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop, ...@@ -1590,9 +1590,6 @@ static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,
wo.wo_rusage = ru; wo.wo_rusage = ru;
ret = do_wait(&wo); ret = do_wait(&wo);
if (ret > 0)
ret = 0;
put_pid(pid); put_pid(pid);
return ret; return ret;
} }
...@@ -1603,6 +1600,11 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *, ...@@ -1603,6 +1600,11 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
struct rusage r; struct rusage r;
struct waitid_info info = {.status = 0}; struct waitid_info info = {.status = 0};
long err = kernel_waitid(which, upid, &info, options, ru ? &r : NULL); long err = kernel_waitid(which, upid, &info, options, ru ? &r : NULL);
int signo = 0;
if (err > 0) {
signo = SIGCHLD;
err = 0;
}
if (!err) { if (!err) {
if (ru && copy_to_user(ru, &r, sizeof(struct rusage))) if (ru && copy_to_user(ru, &r, sizeof(struct rusage)))
...@@ -1612,7 +1614,7 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *, ...@@ -1612,7 +1614,7 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
return err; return err;
user_access_begin(); user_access_begin();
unsafe_put_user(err ? 0 : SIGCHLD, &infop->si_signo, Efault); unsafe_put_user(signo, &infop->si_signo, Efault);
unsafe_put_user(0, &infop->si_errno, Efault); unsafe_put_user(0, &infop->si_errno, Efault);
unsafe_put_user((short)info.cause, &infop->si_code, Efault); unsafe_put_user((short)info.cause, &infop->si_code, Efault);
unsafe_put_user(info.pid, &infop->si_pid, Efault); unsafe_put_user(info.pid, &infop->si_pid, Efault);
...@@ -1714,6 +1716,11 @@ COMPAT_SYSCALL_DEFINE5(waitid, ...@@ -1714,6 +1716,11 @@ COMPAT_SYSCALL_DEFINE5(waitid,
struct rusage ru; struct rusage ru;
struct waitid_info info = {.status = 0}; struct waitid_info info = {.status = 0};
long err = kernel_waitid(which, pid, &info, options, uru ? &ru : NULL); long err = kernel_waitid(which, pid, &info, options, uru ? &ru : NULL);
int signo = 0;
if (err > 0) {
signo = SIGCHLD;
err = 0;
}
if (!err && uru) { if (!err && uru) {
/* kernel_waitid() overwrites everything in ru */ /* kernel_waitid() overwrites everything in ru */
...@@ -1729,7 +1736,7 @@ COMPAT_SYSCALL_DEFINE5(waitid, ...@@ -1729,7 +1736,7 @@ COMPAT_SYSCALL_DEFINE5(waitid,
return err; return err;
user_access_begin(); user_access_begin();
unsafe_put_user(err ? 0 : SIGCHLD, &infop->si_signo, Efault); unsafe_put_user(signo, &infop->si_signo, Efault);
unsafe_put_user(0, &infop->si_errno, Efault); unsafe_put_user(0, &infop->si_errno, Efault);
unsafe_put_user((short)info.cause, &infop->si_code, Efault); unsafe_put_user((short)info.cause, &infop->si_code, Efault);
unsafe_put_user(info.pid, &infop->si_pid, Efault); unsafe_put_user(info.pid, &infop->si_pid, Efault);
......
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