From: Christian Brauner <christian.brauner@ubuntu.com>
To: Naresh Kamboju <naresh.kamboju@linaro.org>
Cc: "open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>,
linux-api@vger.kernel.org,
open list <linux-kernel@vger.kernel.org>,
Christian Brauner <christian@brauner.io>,
Kees Cook <keescook@chromium.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Oleg Nesterov <oleg@redhat.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Sargun Dhillon <sargun@sargun.me>,
Aleksa Sarai <cyphar@cyphar.com>,
Josh Triplett <josh@joshtriplett.org>,
Jens Axboe <axboe@kernel.dk>, Shuah Khan <shuah@kernel.org>,
lkft-triage@lists.linaro.org
Subject: Re: selftests: pidfd: pidfd_wait hangs on linux next kernel on all devices
Date: Thu, 24 Sep 2020 18:21:26 +0200 [thread overview]
Message-ID: <20200924162126.mbthwz32w7rba7oe@wittgenstein> (raw)
In-Reply-To: <20200924143317.getruzwu423g3o3e@wittgenstein>
On Thu, Sep 24, 2020 at 04:33:17PM +0200, Christian Brauner wrote:
> On Wed, Sep 23, 2020 at 07:52:05PM +0530, Naresh Kamboju wrote:
> > selftests: pidfd: pidfd_wait hangs on linux next kernel on x86_64,
> > i386 and arm64 Juno-r2
> > These devices are using NFS mounted rootfs.
> > I have tested pidfd testcases independently and all test PASS.
> >
> > The Hang or exit from test run noticed when run by run_kselftest.sh
> >
> > pidfd_wait.c:208:wait_nonblock:Expected sys_waitid(P_PIDFD, pidfd,
> > &info, WSTOPPED, NULL) (-1) == 0 (0)
> > wait_nonblock: Test terminated by assertion
> >
> > metadata:
> > git branch: master
> > git repo: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
> > git commit: e64997027d5f171148687e58b78c8b3c869a6158
> > git describe: next-20200922
> > make_kernelversion: 5.9.0-rc6
> > kernel-config:
> > http://snapshots.linaro.org/openembedded/lkft/lkft/sumo/intel-core2-32/lkft/linux-next/865/config
> >
> > Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
>
> Thanks for reproting this. I'm taking a look now!
Ok, this is a simple race in the selftests, that I overlooked and which
is more likely to hit when there's a lot of processes running on the
system. Basically the child process hasn't SIGSTOPed itself yet but the
parent is already calling waitid() on a O_NONBLOCK pidfd. Since it
doesn't find a WSTOPPED process it returns -EAGAIN correctly.
The fix for this is to move the line where we're removing the O_NONBLOCK
property from the fd before the waitid() WSTOPPED call so we hang until
the child becomes stopped.
So I believe the fix is:
diff --git a/tools/testing/selftests/pidfd/pidfd_wait.c b/tools/testing/selftests/pidfd/pidfd_wait.c
index 4063d6f31fa4..be2943f072f6 100644
--- a/tools/testing/selftests/pidfd/pidfd_wait.c
+++ b/tools/testing/selftests/pidfd/pidfd_wait.c
@@ -205,6 +205,8 @@ TEST(wait_nonblock)
ret = sys_waitid(P_PIDFD, pidfd, &info, WEXITED | WNOHANG, NULL);
ASSERT_EQ(ret, 0);
+ ASSERT_EQ(fcntl(pidfd, F_SETFL, (flags & ~O_NONBLOCK)), 0);
+
ASSERT_EQ(sys_waitid(P_PIDFD, pidfd, &info, WSTOPPED, NULL), 0);
ASSERT_EQ(info.si_signo, SIGCHLD);
ASSERT_EQ(info.si_code, CLD_STOPPED);
@@ -212,8 +214,6 @@ TEST(wait_nonblock)
ASSERT_EQ(sys_pidfd_send_signal(pidfd, SIGCONT, NULL, 0), 0);
- ASSERT_EQ(fcntl(pidfd, F_SETFL, (flags & ~O_NONBLOCK)), 0);
-
ASSERT_EQ(sys_waitid(P_PIDFD, pidfd, &info, WEXITED, NULL), 0);
ASSERT_EQ(info.si_signo, SIGCHLD);
ASSERT_EQ(info.si_code, CLD_EXITED);
Christian
next prev parent reply other threads:[~2020-09-24 16:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 14:22 selftests: pidfd: pidfd_wait hangs on linux next kernel on all devices Naresh Kamboju
2020-09-24 14:33 ` Christian Brauner
2020-09-24 16:21 ` Christian Brauner [this message]
2020-09-25 6:09 ` Naresh Kamboju
2020-10-02 17:31 ` Naresh Kamboju
2020-10-09 9:58 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200924162126.mbthwz32w7rba7oe@wittgenstein \
--to=christian.brauner@ubuntu.com \
--cc=axboe@kernel.dk \
--cc=christian@brauner.io \
--cc=cyphar@cyphar.com \
--cc=ebiederm@xmission.com \
--cc=josh@joshtriplett.org \
--cc=keescook@chromium.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lkft-triage@lists.linaro.org \
--cc=mingo@kernel.org \
--cc=naresh.kamboju@linaro.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=sargun@sargun.me \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox