Skip to content

Commit b6fe2d1

Browse files
vtltorvalds
authored andcommitted
wait_noreap_copyout(): check for ->wo_info != NULL
Current behaviour of sys_waitid() looks odd. If user passes infop == NULL, sys_waitid() returns success. When user additionally specifies flag WNOWAIT, sys_waitid() returns -EFAULT on the same conditions. When user combines WNOWAIT with WCONTINUED, sys_waitid() again returns success. This patch adds check for ->wo_info in wait_noreap_copyout(). User-visible change: starting from this commit, sys_waitid() always checks infop != NULL and does not fail if it is NULL. Signed-off-by: Vitaly Mayatskikh <v.mayatskih@gmail.com> Reviewed-by: Oleg Nesterov <oleg@redhat.com> Cc: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent dfe16df commit b6fe2d1

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

‎kernel/exit.c‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,18 +1140,20 @@ static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p,
11401140

11411141
put_task_struct(p);
11421142
infop = wo->wo_info;
1143-
if (!retval)
1144-
retval = put_user(SIGCHLD, &infop->si_signo);
1145-
if (!retval)
1146-
retval = put_user(0, &infop->si_errno);
1147-
if (!retval)
1148-
retval = put_user((short)why, &infop->si_code);
1149-
if (!retval)
1150-
retval = put_user(pid, &infop->si_pid);
1151-
if (!retval)
1152-
retval = put_user(uid, &infop->si_uid);
1153-
if (!retval)
1154-
retval = put_user(status, &infop->si_status);
1143+
if (infop) {
1144+
if (!retval)
1145+
retval = put_user(SIGCHLD, &infop->si_signo);
1146+
if (!retval)
1147+
retval = put_user(0, &infop->si_errno);
1148+
if (!retval)
1149+
retval = put_user((short)why, &infop->si_code);
1150+
if (!retval)
1151+
retval = put_user(pid, &infop->si_pid);
1152+
if (!retval)
1153+
retval = put_user(uid, &infop->si_uid);
1154+
if (!retval)
1155+
retval = put_user(status, &infop->si_status);
1156+
}
11551157
if (!retval)
11561158
retval = pid;
11571159
return retval;

0 commit comments

Comments
 (0)