linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* commit 67d7ddded32 (waitid(2): leave copyout of siginfo to syscall itself) breaks glibc posix/tst-waitid
@ 2017-07-08  9:56 Markus Trippelsdorf
  2017-07-08 13:12 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Trippelsdorf @ 2017-07-08  9:56 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

Since:
 commit 67d7ddded322db99f451a7959d56ed6c70a6c4aa
 Author: Al Viro <viro@zeniv.linux.org.uk>
 Date:   Sun May 14 20:53:13 2017 -0400

     waitid(2): leave copyout of siginfo to syscall itself

the glibc posix/tst-waitid.c testcase fails:

markus@x4 glibc-build % ./posix/tst-waitid
waitid WNOHANG on stopped status 0

-- 
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: commit 67d7ddded32 (waitid(2): leave copyout of siginfo to syscall itself) breaks glibc posix/tst-waitid
  2017-07-08  9:56 commit 67d7ddded32 (waitid(2): leave copyout of siginfo to syscall itself) breaks glibc posix/tst-waitid Markus Trippelsdorf
@ 2017-07-08 13:12 ` Al Viro
  2017-07-08 13:53   ` Markus Trippelsdorf
  0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2017-07-08 13:12 UTC (permalink / raw)
  To: Markus Trippelsdorf; +Cc: linux-kernel

On Sat, Jul 08, 2017 at 11:56:44AM +0200, Markus Trippelsdorf wrote:
> Since:
>  commit 67d7ddded322db99f451a7959d56ed6c70a6c4aa
>  Author: Al Viro <viro@zeniv.linux.org.uk>
>  Date:   Sun May 14 20:53:13 2017 -0400
> 
>      waitid(2): leave copyout of siginfo to syscall itself
> 
> the glibc posix/tst-waitid.c testcase fails:
> 
> markus@x4 glibc-build % ./posix/tst-waitid
> waitid WNOHANG on stopped status 0

I think I see what's going on...  We lose the distinction between "got
a PID" and "nothing, but that's not an error" a bit too early waitid()
case.  Could you see if there are any problems left with the following
applied?

diff --git a/kernel/exit.c b/kernel/exit.c
index 462fc25eec6e..aa5d5e4de804 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1604,9 +1604,6 @@ static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,
 	wo.wo_rusage	= ru;
 	ret = do_wait(&wo);
 
-	if (ret > 0)
-		ret = 0;
-
 	put_pid(pid);
 	return ret;
 }
@@ -1617,6 +1614,11 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
 	struct rusage r;
 	struct waitid_info info = {.status = 0};
 	long err = kernel_waitid(which, upid, &info, options, ru ? &r : NULL);
+	int signo = 0;
+	if (err > 0) {
+		signo = SIGCHLD;
+		err = 0;
+	}
 
 	if (!err) {
 		if (ru && copy_to_user(ru, &r, sizeof(struct rusage)))
@@ -1626,7 +1628,7 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
 		return err;
 
 	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((short)info.cause, &infop->si_code, Efault);
 	unsafe_put_user(info.pid, &infop->si_pid, Efault);
@@ -1728,6 +1730,11 @@ COMPAT_SYSCALL_DEFINE5(waitid,
 	struct rusage ru;
 	struct waitid_info info = {.status = 0};
 	long err = kernel_waitid(which, pid, &info, options, uru ? &ru : NULL);
+	int signo = 0;
+	if (err > 0) {
+		signo = SIGCHLD;
+		err = 0;
+	}
 
 	if (!err && uru) {
 		/* kernel_waitid() overwrites everything in ru */
@@ -1743,7 +1750,7 @@ COMPAT_SYSCALL_DEFINE5(waitid,
 		return err;
 
 	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((short)info.cause, &infop->si_code, Efault);
 	unsafe_put_user(info.pid, &infop->si_pid, Efault);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: commit 67d7ddded32 (waitid(2): leave copyout of siginfo to syscall itself) breaks glibc posix/tst-waitid
  2017-07-08 13:12 ` Al Viro
@ 2017-07-08 13:53   ` Markus Trippelsdorf
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Trippelsdorf @ 2017-07-08 13:53 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

On 2017.07.08 at 14:12 +0100, Al Viro wrote:
> On Sat, Jul 08, 2017 at 11:56:44AM +0200, Markus Trippelsdorf wrote:
> > Since:
> >  commit 67d7ddded322db99f451a7959d56ed6c70a6c4aa
> >  Author: Al Viro <viro@zeniv.linux.org.uk>
> >  Date:   Sun May 14 20:53:13 2017 -0400
> > 
> >      waitid(2): leave copyout of siginfo to syscall itself
> > 
> > the glibc posix/tst-waitid.c testcase fails:
> > 
> > markus@x4 glibc-build % ./posix/tst-waitid
> > waitid WNOHANG on stopped status 0
> 
> I think I see what's going on...  We lose the distinction between "got
> a PID" and "nothing, but that's not an error" a bit too early waitid()
> case.  Could you see if there are any problems left with the following
> applied?

No, everything looks nice now. Thanks.

-- 
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-07-08 13:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-08  9:56 commit 67d7ddded32 (waitid(2): leave copyout of siginfo to syscall itself) breaks glibc posix/tst-waitid Markus Trippelsdorf
2017-07-08 13:12 ` Al Viro
2017-07-08 13:53   ` Markus Trippelsdorf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).