waitid(): switch copyout of siginfo to unsafe_put_user()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2017-05-14 19:27:32 -04:00
Родитель 76d9871e11
Коммит 4c48abe91b
1 изменённых файлов: 25 добавлений и 15 удалений

Просмотреть файл

@ -1625,15 +1625,18 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
if (!infop) if (!infop)
return err; return err;
if (put_user(err ? 0 : SIGCHLD, &infop->si_signo) || user_access_begin();
put_user(0, &infop->si_errno) || unsafe_put_user(err ? 0 : SIGCHLD, &infop->si_signo, Efault);
put_user((short)info.cause, &infop->si_code) || unsafe_put_user(0, &infop->si_errno, Efault);
put_user(info.pid, &infop->si_pid) || unsafe_put_user((short)info.cause, &infop->si_code, Efault);
put_user(info.uid, &infop->si_uid) || unsafe_put_user(info.pid, &infop->si_pid, Efault);
put_user(info.status, &infop->si_status)) unsafe_put_user(info.uid, &infop->si_uid, Efault);
err = -EFAULT; unsafe_put_user(info.status, &infop->si_status, Efault);
user_access_end();
return err; return err;
Efault:
user_access_end();
return -EFAULT;
} }
static long kernel_wait4(pid_t upid, int __user *stat_addr, static long kernel_wait4(pid_t upid, int __user *stat_addr,
@ -1736,13 +1739,20 @@ COMPAT_SYSCALL_DEFINE5(waitid,
return -EFAULT; return -EFAULT;
} }
if (put_user(err ? 0 : SIGCHLD, &infop->si_signo) || if (!infop)
put_user(0, &infop->si_errno) || return err;
put_user((short)info.cause, &infop->si_code) ||
put_user(info.pid, &infop->si_pid) || user_access_begin();
put_user(info.uid, &infop->si_uid) || unsafe_put_user(err ? 0 : SIGCHLD, &infop->si_signo, Efault);
put_user(info.status, &infop->si_status)) unsafe_put_user(0, &infop->si_errno, Efault);
err = -EFAULT; unsafe_put_user((short)info.cause, &infop->si_code, Efault);
unsafe_put_user(info.pid, &infop->si_pid, Efault);
unsafe_put_user(info.uid, &infop->si_uid, Efault);
unsafe_put_user(info.status, &infop->si_status, Efault);
user_access_end();
return err; return err;
Efault:
user_access_end();
return -EFAULT;
} }
#endif #endif