All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Will Deacon <will@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Will Drewry <wad@chromium.org>,
	Keno Fischer <keno@juliacomputing.com>,
	Oleg Nesterov <oleg@redhat.com>, Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] selftests/seccomp: Check ENOSYS under tracing
Date: Sun, 5 Jul 2020 00:01:09 -0700	[thread overview]
Message-ID: <202007050000.40DCED12@keescook> (raw)
In-Reply-To: <20200705061232.4151319-4-keescook@chromium.org>

On Sat, Jul 04, 2020 at 11:12:32PM -0700, Kees Cook wrote:
> There should be no difference between -1 and other negative syscalls
> while tracing.
> 
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Will Drewry <wad@chromium.org>
> Cc: Will Deacon <will@kernel.org>
> Cc: Keno Fischer <keno@juliacomputing.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  tools/testing/selftests/seccomp/seccomp_bpf.c | 26 +++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index 966dec340ea8..bf6aa06c435c 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -1973,6 +1973,32 @@ FIXTURE_TEARDOWN(TRACE_syscall)
>  	teardown_trace_fixture(_metadata, self->tracer);
>  }
>  
> +TEST(negative_ENOSYS)
> +{
> +	/* Untraced negative syscalls should return ENOSYS. */
> +	errno = 0;
> +	EXPECT_EQ(-1, syscall(-1));
> +	EXPECT_EQ(errno, ENOSYS);
> +	errno = 0;
> +	EXPECT_EQ(-1, syscall(-101));
> +	EXPECT_EQ(errno, ENOSYS);
> +}
> +
> +TEST_F(TRACE_syscall, negative_ENOSYS)
> +{
> +	/*
> +	 * There should be no difference between an "internal" skip
> +	 * and userspace asking for syscall "-1".
> +	 */
> +	errno = 0;
> +	EXPECT_EQ(-1, syscall(-1));
> +	EXPECT_EQ(errno, ENOSYS);
> +	/* And no difference for "still not valid but not -1". */
> +	errno = 0;
> +	EXPECT_EQ(-1, syscall(-101));
> +	EXPECT_EQ(errno, ENOSYS);
> +}
> +

I realized after sending this that the second function could just be:

+TEST_F(TRACE_syscall, negative_ENOSYS)
+{
+	negative_ENOSYS(_metadata);
+}

:)

>  TEST_F(TRACE_syscall, syscall_allowed)
>  {
>  	/* getppid works as expected (no changes). */
> -- 
> 2.25.1
> 

-- 
Kees Cook

  reply	other threads:[~2020-07-05  7:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-05  6:12 [PATCH for-next/seccomp 0/3] Check ENOSYS under tracing Kees Cook
2020-07-05  6:12 ` [PATCH 1/3] selftests/harness: Clean up kern-doc for fixtures Kees Cook
2020-07-05 16:53   ` Jakub Kicinski
2020-07-05  6:12 ` [PATCH 2/3] selftests/seccomp: Refactor to use fixture variants Kees Cook
2020-07-05 16:53   ` Jakub Kicinski
2020-07-05  6:12 ` [PATCH 3/3] selftests/seccomp: Check ENOSYS under tracing Kees Cook
2020-07-05  7:01   ` Kees Cook [this message]
2020-07-10 12:40 ` [PATCH for-next/seccomp 0/3] " Will Deacon
2020-07-10 16:11   ` Kees Cook

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=202007050000.40DCED12@keescook \
    --to=keescook@chromium.org \
    --cc=keno@juliacomputing.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=shuah@kernel.org \
    --cc=wad@chromium.org \
    --cc=will@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.