mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tycho Andersen <tycho@tycho.ws>
To: Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org, Jann Horn <jannh@google.com>,
	Tycho Andersen <tycho@tycho.ws>,
	Andy Lutomirski <luto@amacapital.net>
Subject: [PATCH 2/3] seccomp: change return type of seccomp_get_filter to int
Date: Fri, 28 Sep 2018 09:46:47 -0600	[thread overview]
Message-ID: <20180928154648.6320-2-tycho@tycho.ws> (raw)
In-Reply-To: <20180928154648.6320-1-tycho@tycho.ws>

As Jann pointed out in another thread, ptrace_requiest() returns an int, so
it makes sense for seccomp_get_filter() to return an int as well. The
return type of seccomp_get_filter() is bounded by the BPF_MAXINSNS check in
seccomp_prepare_filter(), so this conversion is safe.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
Reported-by: Jann Horn <jannh@google.com>
CC: Kees Cook <keescook@chromium.org>
CC: Andy Lutomirski <luto@amacapital.net>
---
 include/linux/seccomp.h | 6 +++---
 kernel/seccomp.c        | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h
index af972549a7b4..8429bdda947a 100644
--- a/include/linux/seccomp.h
+++ b/include/linux/seccomp.h
@@ -94,13 +94,13 @@ static inline void get_seccomp_filter(struct task_struct *tsk)
 #endif /* CONFIG_SECCOMP_FILTER */
 
 #if defined(CONFIG_SECCOMP_FILTER) && defined(CONFIG_CHECKPOINT_RESTORE)
-extern long seccomp_get_filter(struct task_struct *task,
+extern int seccomp_get_filter(struct task_struct *task,
 			       unsigned long filter_off, void __user *data);
 extern int seccomp_get_metadata(struct task_struct *task,
 				unsigned long filter_off, void __user *data);
 #else
-static inline long seccomp_get_filter(struct task_struct *task,
-				      unsigned long n, void __user *data)
+static inline int seccomp_get_filter(struct task_struct *task,
+				     unsigned long n, void __user *data)
 {
 	return -EINVAL;
 }
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 9f3721849747..ef80dd19f268 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -1030,12 +1030,12 @@ static struct seccomp_filter *get_nth_filter(struct task_struct *task,
 	return filter;
 }
 
-long seccomp_get_filter(struct task_struct *task, unsigned long filter_off,
-			void __user *data)
+int seccomp_get_filter(struct task_struct *task, unsigned long filter_off,
+		       void __user *data)
 {
 	struct seccomp_filter *filter;
 	struct sock_fprog_kern *fprog;
-	long ret;
+	int ret;
 
 	if (!capable(CAP_SYS_ADMIN) ||
 	    current->seccomp.mode != SECCOMP_MODE_DISABLED) {
-- 
2.17.1


  reply	other threads:[~2018-09-28 15:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28 15:46 [PATCH 1/3] seccomp: change return type of seccomp_get_metadata " Tycho Andersen
2018-09-28 15:46 ` Tycho Andersen [this message]
2018-09-28 15:46 ` [PATCH 3/3] seccomp: introduce read protection for struct seccomp Tycho Andersen
2018-09-28 20:33   ` Jann Horn
2018-09-28 20:56     ` Tycho Andersen
2018-09-28 21:10       ` Jann Horn
2018-09-28 21:35         ` Tycho Andersen
2018-09-28 21:54           ` Jann Horn
2018-09-28 22:02             ` Tycho Andersen

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=20180928154648.6320-2-tycho@tycho.ws \
    --to=tycho@tycho.ws \
    --cc=jannh@google.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    /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

Powered by JetHome