From: Jeff Xu <jeffxu@google.com>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: Shuah Khan <shuah@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Daniel Verkamp <dverkamp@chromium.org>,
Kees Cook <keescook@chromium.org>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 3/3] selftests: memfd: error out test process when child test fails
Date: Wed, 19 Jul 2023 16:38:35 -0700 [thread overview]
Message-ID: <CALmYWFsusw5H6aa9Po6QyEKr7beUSTN+PmGzc0Er0tuGEmYCbA@mail.gmail.com> (raw)
In-Reply-To: <20230713143406.14342-4-cyphar@cyphar.com>
On Thu, Jul 13, 2023 at 7:34 AM Aleksa Sarai <cyphar@cyphar.com> wrote:
>
> Before this change, a test runner using this self test would see a
> return code of 0 when the tests using a child process (namely the
> MFD_NOEXEC_SEAL and MFD_EXEC tests) failed, masking test failures.
>
> Fixes: 11f75a01448f ("selftests/memfd: add tests for MFD_NOEXEC_SEAL MFD_EXEC")
> Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
> ---
> tools/testing/selftests/memfd/memfd_test.c | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
> index d8342989c547..8b7390ad81d1 100644
> --- a/tools/testing/selftests/memfd/memfd_test.c
> +++ b/tools/testing/selftests/memfd/memfd_test.c
> @@ -1219,7 +1219,24 @@ static pid_t spawn_newpid_thread(unsigned int flags, int (*fn)(void *))
>
> static void join_newpid_thread(pid_t pid)
> {
> - waitpid(pid, NULL, 0);
> + int wstatus;
> +
> + if (waitpid(pid, &wstatus, 0) < 0) {
> + printf("newpid thread: waitpid() failed: %m\n");
> + abort();
> + }
> +
> + if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != 0) {
> + printf("newpid thread: exited with non-zero error code %d\n",
> + WEXITSTATUS(wstatus));
> + abort();
> + }
> +
> + if (WIFSIGNALED(wstatus)) {
> + printf("newpid thread: killed by signal %d\n",
> + WTERMSIG(wstatus));
> + abort();
> + }
> }
>
Signed-off-by: Jeff Xu <jeffxu@google.com>
-Jeff Xu
> /*
> --
> 2.41.0
>
next prev parent reply other threads:[~2023-07-19 23:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 14:33 [RFC PATCH 0/3] memfd: cleanups for vm.memfd_noexec Aleksa Sarai
2023-07-13 14:33 ` [RFC PATCH 1/3] memfd: cleanups for vm.memfd_noexec handling Aleksa Sarai
2023-07-13 14:33 ` [RFC PATCH 2/3] memfd: remove racheting feature from vm.memfd_noexec Aleksa Sarai
2023-07-14 0:07 ` Aleksa Sarai
2023-07-13 14:33 ` [RFC PATCH 3/3] selftests: memfd: error out test process when child test fails Aleksa Sarai
2023-07-19 23:38 ` Jeff Xu [this message]
2023-08-03 2:25 ` Aleksa Sarai
2023-08-03 2:55 ` Jeff Xu
2023-07-18 0:47 ` [RFC PATCH 0/3] memfd: cleanups for vm.memfd_noexec Jeff Xu
2023-07-19 3:10 ` Aleksa Sarai
2023-07-19 7:17 ` Jeff Xu
2023-08-02 1:04 ` Aleksa Sarai
2023-08-02 19:47 ` Jeff Xu
2023-08-02 19:54 ` Jeff Xu
2023-08-02 21:38 ` Aleksa Sarai
2023-08-02 23:11 ` Jeff Xu
2023-08-03 4:39 ` Aleksa Sarai
2023-08-03 14:40 ` Jeff Xu
2023-08-02 20:45 ` Jeff Xu
2023-08-02 21:48 ` Aleksa Sarai
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=CALmYWFsusw5H6aa9Po6QyEKr7beUSTN+PmGzc0Er0tuGEmYCbA@mail.gmail.com \
--to=jeffxu@google.com \
--cc=akpm@linux-foundation.org \
--cc=cyphar@cyphar.com \
--cc=dverkamp@chromium.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shuah@kernel.org \
/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