From: Kees Cook <keescook@chromium.org>
To: Sargun Dhillon <sargun@sargun.me>
Cc: LKML <linux-kernel@vger.kernel.org>,
Christian Brauner <christian.brauner@ubuntu.com>,
Aleksa Sarai <cyphar@cyphar.com>, Tycho Andersen <tycho@tycho.ws>
Subject: Re: [PATCH] selftests/seccomp: Test kernel catches garbage on SECCOMP_IOCTL_NOTIF_RECV
Date: Mon, 30 Dec 2019 14:02:45 -0800 [thread overview]
Message-ID: <201912301402.DAA6ED9A0@keescook> (raw)
In-Reply-To: <20191230203811.4996-1-sargun@sargun.me>
On Mon, Dec 30, 2019 at 12:38:11PM -0800, Sargun Dhillon wrote:
> This adds to the user_notification_basic to set a field of seccomp_notif
> to an invalid value to ensure that the kernel returns EINVAL if any of the
> seccomp_notif fields are set to invalid values.
>
> Signed-off-by: Sargun Dhillon <sargun@sargun.me>
> Suggested-by: Christian Brauner <christian.brauner@ubuntu.com>
> Cc: Kees Cook <keescook@chromium.org>
Thanks! Applied. :)
-Kees
> ---
> tools/testing/selftests/seccomp/seccomp_bpf.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index f53f14971bff..393578a78dbc 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -3158,6 +3158,13 @@ TEST(user_notification_basic)
> EXPECT_GT(poll(&pollfd, 1, -1), 0);
> EXPECT_EQ(pollfd.revents, POLLIN);
>
> + /* Test that we can't pass garbage to the kernel. */
> + memset(&req, 0, sizeof(req));
> + req.pid = -1;
> + EXPECT_EQ(-1, ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req));
> + EXPECT_EQ(EINVAL, errno);
> +
> + req.pid = 0;
> EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
>
> pollfd.fd = listener;
> --
> 2.20.1
>
--
Kees Cook
next prev parent reply other threads:[~2019-12-30 22:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-30 20:38 Sargun Dhillon
2019-12-30 22:02 ` Kees Cook [this message]
2019-12-31 14:04 ` Christian Brauner
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=201912301402.DAA6ED9A0@keescook \
--to=keescook@chromium.org \
--cc=christian.brauner@ubuntu.com \
--cc=cyphar@cyphar.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sargun@sargun.me \
--cc=tycho@tycho.ws \
/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®