Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6fe2d11 authored by Vitaly Mayatskikh's avatar Vitaly Mayatskikh Committed by Linus Torvalds
Browse files

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: default avatarVitaly Mayatskikh <v.mayatskih@gmail.com>
Reviewed-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent dfe16dfa
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -1140,6 +1140,7 @@ static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p,

	put_task_struct(p);
	infop = wo->wo_info;
	if (infop) {
		if (!retval)
			retval = put_user(SIGCHLD, &infop->si_signo);
		if (!retval)
@@ -1152,6 +1153,7 @@ static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p,
			retval = put_user(uid, &infop->si_uid);
		if (!retval)
			retval = put_user(status, &infop->si_status);
	}
	if (!retval)
		retval = pid;
	return retval;