From: Sargun Dhillon <sargun@sargun.me>
To: linux-kernel@vger.kernel.org,
containers@lists.linux-foundation.org, linux-api@vger.kernel.org
Cc: Sargun Dhillon <sargun@sargun.me>,
christian.brauner@ubuntu.com, tycho@tycho.ws,
keescook@chromium.org, cyphar@cyphar.com,
Jeffrey Vander Stoep <jeffv@google.com>,
jannh@google.com, rsesek@google.com, palmer@google.com,
Matt Denton <mpdenton@google.com>,
Kees Cook <keescook@google.com>
Subject: [PATCH 5/5] selftests/seccomp: Add test for addfd move semantics
Date: Sun, 24 May 2020 16:39:42 -0700 [thread overview]
Message-ID: <20200524233942.8702-6-sargun@sargun.me> (raw)
In-Reply-To: <20200524233942.8702-1-sargun@sargun.me>
This introduces another call to addfd, in which the move flag is set. It
may make sense to setup a cgroup v1 hierarchy, and check that the
netprioidx is changed.
Signed-off-by: Sargun Dhillon <sargun@sargun.me>
Cc: Matt Denton <mpdenton@google.com>
Cc: Kees Cook <keescook@google.com>,
Cc: Jann Horn <jannh@google.com>,
Cc: Robert Sesek <rsesek@google.com>,
Cc: Chris Palmer <palmer@google.com>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Tycho Andersen <tycho@tycho.ws>
---
tools/testing/selftests/seccomp/seccomp_bpf.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 1ec43fef2b93..f4b50cbbde42 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -188,6 +188,8 @@ struct seccomp_metadata {
/* valid flags for seccomp_notif_addfd */
#define SECCOMP_ADDFD_FLAG_SETFD (1UL << 0) /* Specify remote fd */
+#define SECCOMP_ADDFD_FLAG_MOVE (1UL << 1)
+
struct seccomp_notif {
__u64 id;
@@ -3756,6 +3758,12 @@ TEST(user_notification_sendfd)
EXPECT_GE(ret, 0);
EXPECT_EQ(filecmp(getpid(), pid, memfd, ret), 0);
+ /* Move the FD */
+ addfd.flags = SECCOMP_ADDFD_FLAG_MOVE;
+ ret = ioctl(listener, SECCOMP_IOCTL_NOTIF_ADDFD, &addfd);
+ EXPECT_GE(ret, 0);
+ EXPECT_EQ(filecmp(getpid(), pid, memfd, ret), 0);
+
/* Verify we can set a specific remote fd */
addfd.remote_fd = 42;
addfd.flags = SECCOMP_ADDFD_FLAG_SETFD;
--
2.25.1
prev parent reply other threads:[~2020-05-24 23:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-24 23:39 [PATCH 0/5] Add seccomp notifier ioctl that enables adding fds Sargun Dhillon
2020-05-24 23:39 ` [PATCH 1/5] seccomp: Add find_notification helper Sargun Dhillon
2020-05-24 23:55 ` Tycho Andersen
2020-05-25 13:26 ` Christian Brauner
2020-05-24 23:39 ` [PATCH 2/5] seccomp: Introduce addfd ioctl to seccomp user notifier Sargun Dhillon
2020-05-24 23:57 ` Tycho Andersen
2020-05-24 23:58 ` Tycho Andersen
2020-05-25 0:05 ` Al Viro
2020-05-25 0:27 ` Sargun Dhillon
2020-05-25 0:39 ` Al Viro
2020-05-25 13:50 ` Christian Brauner
2020-05-26 6:59 ` Sargun Dhillon
2020-05-26 8:22 ` Christian Brauner
2020-05-24 23:39 ` [PATCH 3/5] selftests/seccomp: Test SECCOMP_IOCTL_NOTIF_ADDFD Sargun Dhillon
2020-05-24 23:39 ` [PATCH 4/5] seccomp: Add SECCOMP_ADDFD_FLAG_MOVE flag to add fd ioctl Sargun Dhillon
2020-05-25 14:20 ` Christian Brauner
2020-05-26 6:08 ` Sargun Dhillon
2020-05-24 23:39 ` Sargun Dhillon [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=20200524233942.8702-6-sargun@sargun.me \
--to=sargun@sargun.me \
--cc=christian.brauner@ubuntu.com \
--cc=containers@lists.linux-foundation.org \
--cc=cyphar@cyphar.com \
--cc=jannh@google.com \
--cc=jeffv@google.com \
--cc=keescook@chromium.org \
--cc=keescook@google.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpdenton@google.com \
--cc=palmer@google.com \
--cc=rsesek@google.com \
--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;
as well as URLs for NNTP newsgroup(s).