From: Tycho Andersen <tycho.andersen@canonical.com>
To: Kees Cook <keescook@chromium.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Will Drewry <wad@chromium.org>, Oleg Nesterov <oleg@redhat.com>,
Andy Lutomirski <luto@amacapital.net>,
Pavel Emelyanov <xemul@parallels.com>,
"Serge E. Hallyn" <serge.hallyn@ubuntu.com>,
Daniel Borkmann <daniel@iogearbox.net>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-api@vger.kernel.org,
Tycho Andersen <tycho.andersen@canonical.com>
Subject: [PATCH v5 3/3] kcmp: add KCMP_SECCOMP_FD
Date: Fri, 2 Oct 2015 10:27:23 -0600 [thread overview]
Message-ID: <1443803243-25912-4-git-send-email-tycho.andersen@canonical.com> (raw)
In-Reply-To: <1443803243-25912-1-git-send-email-tycho.andersen@canonical.com>
This command allows for comparing the filters pointed to by two seccomp
fds. This is useful e.g. to find out if a seccomp filter is inherited,
since struct seccomp_filter are unique across tasks and are the
private_data seccomp fds.
v2: switch to KCMP_SECCOMP_FD instead of KCMP_FILE_PRIVATE_DATA
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Kees Cook <keescook@chromium.org>
CC: Will Drewry <wad@chromium.org>
CC: Oleg Nesterov <oleg@redhat.com>
CC: Andy Lutomirski <luto@amacapital.net>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Serge E. Hallyn <serge.hallyn@ubuntu.com>
CC: Alexei Starovoitov <ast@kernel.org>
CC: Daniel Borkmann <daniel@iogearbox.net>
---
include/uapi/linux/kcmp.h | 1 +
kernel/kcmp.c | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/include/uapi/linux/kcmp.h b/include/uapi/linux/kcmp.h
index 84df14b..cd7870b 100644
--- a/include/uapi/linux/kcmp.h
+++ b/include/uapi/linux/kcmp.h
@@ -10,6 +10,7 @@ enum kcmp_type {
KCMP_SIGHAND,
KCMP_IO,
KCMP_SYSVSEM,
+ KCMP_SECCOMP_FD,
KCMP_TYPES,
};
diff --git a/kernel/kcmp.c b/kernel/kcmp.c
index 0aa69ea..d53db53 100644
--- a/kernel/kcmp.c
+++ b/kernel/kcmp.c
@@ -11,6 +11,7 @@
#include <linux/bug.h>
#include <linux/err.h>
#include <linux/kcmp.h>
+#include <linux/seccomp.h>
#include <asm/unistd.h>
@@ -165,6 +166,32 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
ret = -EOPNOTSUPP;
#endif
break;
+ case KCMP_SECCOMP_FD: {
+ struct file *filp1, *filp2;
+
+ filp1 = get_file_raw_ptr(task1, idx1);
+ filp2 = get_file_raw_ptr(task2, idx2);
+
+ if (filp1 && filp2) {
+ struct seccomp_filter *filter1, *filter2;
+
+ filter1 = seccomp_filter_from_file(filp1);
+ if (IS_ERR(filter1)) {
+ ret = PTR_ERR(filter1);
+ break;
+ }
+
+ filter2 = seccomp_filter_from_file(filp2);
+ if (IS_ERR(filter2)) {
+ ret = PTR_ERR(filter2);
+ break;
+ }
+
+ ret = kcmp_ptr(filter1, filter2, KCMP_SECCOMP_FD);
+ } else
+ ret = -EBADF;
+ break;
+ }
default:
ret = -EINVAL;
break;
--
2.5.0
next prev parent reply other threads:[~2015-10-02 16:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 16:27 v5 of seccomp filter c/r patches Tycho Andersen
2015-10-02 16:27 ` [PATCH v5 1/3] seccomp: add the concept of a seccomp filter FD Tycho Andersen
2015-10-02 16:27 ` [PATCH v5 2/3] seccomp: add a ptrace command to get seccomp filter fds Tycho Andersen
2015-10-02 16:27 ` Tycho Andersen [this message]
2015-10-02 21:10 ` v5 of seccomp filter c/r patches Kees Cook
[not found] ` <CAGXu5jJJoM3NdwSmigWy8trTBATsvkGUDmbZ02QOyU=1tD0Y-w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-02 21:29 ` Andy Lutomirski
[not found] ` <CALCETrV1XnOjqq1MFZk4WghPkOqTNp7kKqrvspzUp6zwxmLDWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-02 22:02 ` Kees Cook
[not found] ` <CAGXu5jL_GVmbGk5twfASk7+M2gHyKQ1bv8+GD_CPf8B3pPF7ng-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-02 22:04 ` Andy Lutomirski
2015-10-02 22:06 ` Kees Cook
[not found] ` <CAGXu5jJGakjhuBgZqvgxN8TraDJ0TEnSJ1dQXo9gRg=HwJXmwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-02 22:16 ` Andy Lutomirski
2015-10-02 22:44 ` Tycho Andersen
2015-10-02 22:52 ` Andy Lutomirski
[not found] ` <CALCETrXOLZgPADEbBhrQNZK=sSgSzFcgXzhXv9uXQe-9HY=fzg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-02 22:56 ` Tycho Andersen
2015-10-02 22:57 ` Daniel Borkmann
[not found] ` <560F0BED.2070304-FeC+5ew28dpmcu3hnIyYJQ@public.gmane.org>
2015-10-02 22:59 ` Tycho Andersen
2015-10-02 23:00 ` 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=1443803243-25912-4-git-send-email-tycho.andersen@canonical.com \
--to=tycho.andersen@canonical.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=keescook@chromium.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=netdev@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=serge.hallyn@ubuntu.com \
--cc=wad@chromium.org \
--cc=xemul@parallels.com \
/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).