linux/tools/testing/selftests/pidfd
Christian Brauner 01361b665a
tests: remove O_NONBLOCK before waiting for WSTOPPED
Naresh reported that 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

The reason for 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.

Fixes: cd89597bbe ("tests: add waitid() tests for non-blocking pidfds")
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Link: https://lkft.validation.linaro.org/scheduler/job/1813223
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-10-09 11:56:51 +02:00
..
.gitignore selftests/pidfd: add pidfd setns tests 2020-05-13 11:41:22 +02:00
config selftests/pidfd: add pidfd setns tests 2020-05-13 11:41:22 +02:00
Makefile selftests/pidfd: add pidfd setns tests 2020-05-13 11:41:22 +02:00
pidfd_fdinfo_test.c test: verify fdinfo for pidfd of reaped process 2019-10-17 15:36:54 +02:00
pidfd_getfd_test.c selftests: Remove unneeded selftest API headers 2020-07-06 15:59:07 -06:00
pidfd_open_test.c tests: move common definitions and functions into pidfd.h 2019-08-06 19:39:45 +02:00
pidfd_poll_test.c tests: add pidfd poll tests 2019-08-06 19:52:41 +02:00
pidfd_setns_test.c linux-kselftest-5.9-rc1 2020-08-05 10:28:25 -07:00
pidfd_test.c selftests: pidfd: skip test if unshare fails with EPERM 2020-07-07 13:28:58 -06:00
pidfd_wait.c tests: remove O_NONBLOCK before waiting for WSTOPPED 2020-10-09 11:56:51 +02:00
pidfd.h tests: add waitid() tests for non-blocking pidfds 2020-09-04 13:48:57 +02:00