From: Christian Brauner <christian.brauner@ubuntu.com>
To: Adrian Reber <areber@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>,
Eugene Syromiatnikov <esyr@redhat.com>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] selftests: add tests for clone3()
Date: Mon, 11 Nov 2019 14:07:27 +0100 [thread overview]
Message-ID: <20191111130726.ccr6c663r6bre67x@wittgenstein> (raw)
In-Reply-To: <20191108185629.309414-1-areber@redhat.com>
On Fri, Nov 08, 2019 at 07:56:29PM +0100, Adrian Reber wrote:
> +static void test_clone3(uint64_t flags, size_t size, int expected,
> + enum test_mode test_mode)
> +{
> + int ret;
> +
> + ksft_print_msg(
> + "[%d] Trying clone3() with flags %#" PRIx64 " (size %zu)\n",
> + getpid(), flags, size);
> + ret = call_clone3(flags, size, test_mode);
> + ksft_print_msg("[%d] clone3() with flags says: %d expected %d\n",
> + getpid(), ret, expected);
> + if (ret != expected)
> + ksft_test_result_fail(
> + "[%d] Result (%d) is different than expected (%d)\n",
> + getpid(), ret, expected);
> + else
> + ksft_test_result_pass(
> + "[%d] Result (%d) matches expectation (%d)\n",
> + getpid(), ret, expected);
> +}
> +int main(int argc, char *argv[])
Nit: missing \n between } and int main().
I'll just fix that up myself.
> + /*
> + * Do a clone3() with sizeof(struct clone_args) + 8
> + * and all members set to 0. This resets exit_signal and wait()
> + * will not get a result.
That comment is not true and now also misleading since you now pass
_WALL to waitpid() above. I'll just remove it when applying.
> + */
> + test_clone3(0, sizeof(struct clone_args) + 8, 0, CLONE3_ARGS_ALL_0);
> +
> + /* Do a clone3() with > page size */
> + test_clone3(0, getpagesize() + 8, -E2BIG, CLONE3_ARGS_NO_TEST);
> +
> + /* Do a clone3() with CLONE3_ARGS_SIZE_V0 in a new PID NS. */
> + if (uid == 0)
> + test_clone3(CLONE_NEWPID, CLONE3_ARGS_SIZE_V0, 0,
> + CLONE3_ARGS_NO_TEST);
> + else
> + ksft_test_result_skip("Skipping clone3() with CLONE_NEWPID\n");
> +
> + /* Do a clone3() with CLONE3_ARGS_SIZE_V0 - 8 in a new PID NS */
> + test_clone3(CLONE_NEWPID, CLONE3_ARGS_SIZE_V0 - 8, -EINVAL,
> + CLONE3_ARGS_NO_TEST);
> +
> + /* Do a clone3() with sizeof(struct clone_args) + 8 in a new PID NS */
> + if (uid == 0)
> + test_clone3(CLONE_NEWPID, sizeof(struct clone_args) + 8, 0,
> + CLONE3_ARGS_NO_TEST);
So there's a missing test condition here, no? I've just realized you're
passing in sizeof(struct clone_args) + 8 which hits the first excess
space 64 bit value which is 0. That's good and the reason why this test
passes.
But I don't see any test for sizoef(struct clone_args_extended) or at
least sizeof(struct clone_args) + 16 such that you actually hit the
second 64 bit integer which is initialized to 1 and thus clone3() should
fail with -E2BIG.If I haven't overlooked this test, can you please add
it? It's quite important since it's a different codepath than the
sizeof(PAGE_SIZE) + 8 codepath.
Thanks!
Christian
prev parent reply other threads:[~2019-11-11 13:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 18:56 Adrian Reber
2019-11-11 13:07 ` Christian Brauner [this message]
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=20191111130726.ccr6c663r6bre67x@wittgenstein \
--to=christian.brauner@ubuntu.com \
--cc=areber@redhat.com \
--cc=esyr@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.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
all inboxes | Powered by JetHome®