All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests/seccomp: Test kernel catches garbage on SECCOMP_IOCTL_NOTIF_RECV
@ 2019-12-30 20:38 Sargun Dhillon
  2019-12-30 22:02 ` Kees Cook
  0 siblings, 1 reply; 3+ messages in thread
From: Sargun Dhillon @ 2019-12-30 20:38 UTC (permalink / raw)
  To: LKML
  Cc: Christian Brauner, Aleksa Sarai, Tycho Andersen, Sargun Dhillon,
	Kees Cook

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/seccomp: Test kernel catches garbage on SECCOMP_IOCTL_NOTIF_RECV
  2019-12-30 20:38 [PATCH] selftests/seccomp: Test kernel catches garbage on SECCOMP_IOCTL_NOTIF_RECV Sargun Dhillon
@ 2019-12-30 22:02 ` Kees Cook
  2019-12-31 14:04   ` Christian Brauner
  0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2019-12-30 22:02 UTC (permalink / raw)
  To: Sargun Dhillon; +Cc: LKML, Christian Brauner, Aleksa Sarai, Tycho Andersen

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/seccomp: Test kernel catches garbage on SECCOMP_IOCTL_NOTIF_RECV
  2019-12-30 22:02 ` Kees Cook
@ 2019-12-31 14:04   ` Christian Brauner
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2019-12-31 14:04 UTC (permalink / raw)
  To: Kees Cook; +Cc: Sargun Dhillon, LKML, Aleksa Sarai, Tycho Andersen

On Mon, Dec 30, 2019 at 02:02:45PM -0800, Kees Cook wrote:
> 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. :)

Thanks everyone and guten Rutsch
( https://en.wiktionary.org/wiki/guten_Rutsch )
:)

Christian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-31 14:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-30 20:38 [PATCH] selftests/seccomp: Test kernel catches garbage on SECCOMP_IOCTL_NOTIF_RECV Sargun Dhillon
2019-12-30 22:02 ` Kees Cook
2019-12-31 14:04   ` Christian Brauner

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.