lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+G9fYsEwvzW1yLsPtiETGzcEnMSsEdU-0r_OJ+S6h9Bbsntqg@mail.gmail.com>
Date:   Fri, 2 Oct 2020 23:01:34 +0530
From:   Naresh Kamboju <naresh.kamboju@...aro.org>
To:     Christian Brauner <christian.brauner@...ntu.com>
Cc:     "open list:KERNEL SELFTEST FRAMEWORK" 
        <linux-kselftest@...r.kernel.org>, linux-api@...r.kernel.org,
        open list <linux-kernel@...r.kernel.org>,
        Christian Brauner <christian@...uner.io>,
        Kees Cook <keescook@...omium.org>,
        "Peter Zijlstra (Intel)" <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Oleg Nesterov <oleg@...hat.com>,
        "Eric W. Biederman" <ebiederm@...ssion.com>,
        Sargun Dhillon <sargun@...gun.me>,
        Aleksa Sarai <cyphar@...har.com>,
        Josh Triplett <josh@...htriplett.org>,
        Jens Axboe <axboe@...nel.dk>, Shuah Khan <shuah@...nel.org>,
        lkft-triage@...ts.linaro.org
Subject: Re: selftests: pidfd: pidfd_wait hangs on linux next kernel on all devices

On Thu, 24 Sep 2020 at 21:51, Christian Brauner
<christian.brauner@...ntu.com> wrote:
>
> 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@...aro.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:

I have tested this patch and the pidfd_wait test did not hang this time.

Tested-by: Naresh Kamboju <naresh.kamboju@...aro.org>

test log link
https://lkft.validation.linaro.org/scheduler/job/1813223

>
> 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);
>

- Naresh

> Christian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ