summaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-05-14 20:39:39 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-05-21 13:11:07 -0400
commit359566faefa850504d146839d74496f0cf12d3b9 (patch)
tree2000268b17f7fa236643c9d572147d883ace81ed /kernel/exit.c
parentce72a16fa705f960ca2352e95a7c5f4801475e75 (diff)
downloadlinux-359566faefa850504d146839d74496f0cf12d3b9.tar.gz
linux-359566faefa850504d146839d74496f0cf12d3b9.tar.bz2
linux-359566faefa850504d146839d74496f0cf12d3b9.zip
kernel_wait4()/kernel_waitid(): delay copying status to userland
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index d44f12948c5f..94cdccf8e7e7 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1002,7 +1002,7 @@ struct wait_opts {
struct pid *wo_pid;
struct siginfo __user *wo_info;
- int __user *wo_stat;
+ int wo_stat;
struct rusage *wo_rusage;
wait_queue_t child_wait;
@@ -1189,8 +1189,7 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
retval = 0;
status = (p->signal->flags & SIGNAL_GROUP_EXIT)
? p->signal->group_exit_code : p->exit_code;
- if (!retval && wo->wo_stat)
- retval = put_user(status, wo->wo_stat);
+ wo->wo_stat = status;
infop = wo->wo_info;
if (!retval && infop)
@@ -1322,8 +1321,7 @@ unlock_sig:
if (wo->wo_rusage)
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
retval = 0;
- if (!retval && wo->wo_stat)
- retval = put_user((exit_code << 8) | 0x7f, wo->wo_stat);
+ wo->wo_stat = (exit_code << 8) | 0x7f;
infop = wo->wo_info;
if (!retval && infop)
@@ -1383,12 +1381,9 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p)
if (!wo->wo_info) {
if (wo->wo_rusage)
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
- retval = 0;
put_task_struct(p);
- if (!retval && wo->wo_stat)
- retval = put_user(0xffff, wo->wo_stat);
- if (!retval)
- retval = pid;
+ wo->wo_stat = 0xffff;
+ retval = pid;
} else {
retval = wait_noreap_copyout(wo, p, pid, uid,
CLD_CONTINUED, SIGCONT);
@@ -1662,7 +1657,6 @@ static long kernel_waitid(int which, pid_t upid, struct siginfo __user *infop,
wo.wo_pid = pid;
wo.wo_flags = options;
wo.wo_info = infop;
- wo.wo_stat = NULL;
wo.wo_rusage = ru;
ret = do_wait(&wo);
@@ -1734,10 +1728,12 @@ static long kernel_wait4(pid_t upid, int __user *stat_addr,
wo.wo_pid = pid;
wo.wo_flags = options | WEXITED;
wo.wo_info = NULL;
- wo.wo_stat = stat_addr;
+ wo.wo_stat = 0;
wo.wo_rusage = ru;
ret = do_wait(&wo);
put_pid(pid);
+ if (ret > 0 && stat_addr && put_user(wo.wo_stat, stat_addr))
+ ret = -EFAULT;
return ret;
}