linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Will Drewry <wad@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: kees.cook@canonical.com, torvalds@linux-foundation.org,
	tglx@linutronix.de, mingo@elte.hu, rostedt@goodmis.org,
	jmorris@namei.org, paulmck@linux.vnet.ibm.com,
	Will Drewry <wad@chromium.org>
Subject: [PATCH v5 04/13] seccomp_filter: add process state reporting
Date: Fri,  3 Jun 2011 16:50:17 -0500	[thread overview]
Message-ID: <1307137817-26731-1-git-send-email-wad@chromium.org> (raw)
In-Reply-To: <1307133252-23259-4-git-send-email-wad@chromium.org>

Adds seccomp and seccomp_filter status reporting to proc.
/proc/<pid>/seccomp_filter provides the current seccomp mode
and the list of allowed or dynamically filtered system calls.

v5: fix typos when mailing the wrong patch series
v4: move from rcu guard to mutex guard
v3: changed to using filters directly.
v2: removed status entry, added seccomp file.
    (requested by kosaki.motohiro@jp.fujitsu.com)
    allowed S_IRUGO reading of entries
    (requested by viro@zeniv.linux.org.uk)
    added flags
    got rid of the seccomp_t type
    dropped seccomp file

Signed-off-by: Will Drewry <wad@chromium.org>
---
 fs/proc/base.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index dfa5327..8673064 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -73,6 +73,7 @@
 #include <linux/security.h>
 #include <linux/ptrace.h>
 #include <linux/tracehook.h>
+#include <linux/seccomp.h>
 #include <linux/cgroup.h>
 #include <linux/cpuset.h>
 #include <linux/audit.h>
@@ -579,6 +580,28 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
 }
 #endif /* CONFIG_HAVE_ARCH_TRACEHOOK */
 
+/*
+ * Print out the current seccomp filter set for the task.
+ */
+#ifdef CONFIG_SECCOMP_FILTER
+int proc_pid_seccomp_filter_show(struct seq_file *m, struct pid_namespace *ns,
+				 struct pid *pid, struct task_struct *task)
+{
+	struct seccomp_filters *filters;
+	/* Avoid allowing other processes to incur too much added contention by
+	 * only acquiring a reference under the task-wide mutex.
+	 */
+	if (mutex_lock_killable(&task->seccomp.filters_guard))
+		return -1;
+	filters = get_seccomp_filters(task->seccomp.filters);
+	mutex_unlock(&task->seccomp.filters_guard);
+
+	seccomp_show_filters(filters, m);
+	put_seccomp_filters(filters);
+	return 0;
+}
+#endif /* CONFIG_SECCOMP_FILTER */
+
 /************************************************************************/
 /*                       Here the fs part begins                        */
 /************************************************************************/
@@ -2838,6 +2861,9 @@ static const struct pid_entry tgid_base_stuff[] = {
 #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
 	INF("syscall",    S_IRUGO, proc_pid_syscall),
 #endif
+#ifdef CONFIG_SECCOMP_FILTER
+	ONE("seccomp_filter",     S_IRUGO, proc_pid_seccomp_filter_show),
+#endif
 	INF("cmdline",    S_IRUGO, proc_pid_cmdline),
 	ONE("stat",       S_IRUGO, proc_tgid_stat),
 	ONE("statm",      S_IRUGO, proc_pid_statm),
@@ -3180,6 +3206,9 @@ static const struct pid_entry tid_base_stuff[] = {
 #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
 	INF("syscall",   S_IRUGO, proc_pid_syscall),
 #endif
+#ifdef CONFIG_SECCOMP_FILTER
+	ONE("seccomp_filter",     S_IRUGO, proc_pid_seccomp_filter_show),
+#endif
 	INF("cmdline",   S_IRUGO, proc_pid_cmdline),
 	ONE("stat",      S_IRUGO, proc_tid_stat),
 	ONE("statm",     S_IRUGO, proc_pid_statm),
-- 
1.7.0.4


  reply	other threads:[~2011-06-03 21:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 20:34 [PATCH v4 01/13] tracing: split out filter initialization and clean up Will Drewry
2011-06-03 20:34 ` [PATCH v4 02/13] tracing: split out syscall_trace_enter construction Will Drewry
2011-06-03 20:34 ` [PATCH v4 03/13] seccomp_filters: new mode with configurable syscall filters Will Drewry
2011-06-03 21:48   ` [PATCH v5 " Will Drewry
2011-06-06 16:56     ` [PATCH v6 03/14] " Will Drewry
2011-06-10 15:39       ` [PATCH v7 03/13] " Will Drewry
2011-06-13  2:24         ` [PATCH v8 " Will Drewry
2011-06-03 22:16   ` [PATCH v4 " Colin Walters
2011-06-06 12:48     ` Stephen Smalley
2011-06-06 15:25       ` Colin Walters
2011-06-06 16:36         ` Stephen Smalley
2011-06-03 20:34 ` [PATCH v4 04/13] seccomp_filter: add process state reporting Will Drewry
2011-06-03 21:50   ` Will Drewry [this message]
2011-06-10 15:40     ` [PATCH v7 " Will Drewry
2011-06-07 23:56   ` [PATCH v4 " Paul E. McKenney
2011-06-08  1:05     ` Will Drewry
2011-06-08  1:59       ` Steven Rostedt
2011-06-03 20:34 ` [PATCH v4 05/13] seccomp_filter: Document what seccomp_filter is and how it works Will Drewry
2011-06-03 20:38   ` Kees Cook
2011-06-10 15:40   ` [PATCH v7 " Will Drewry
2011-06-03 20:34 ` [PATCH v4 06/13] x86: add HAVE_SECCOMP_FILTER and seccomp_execve Will Drewry
2011-06-03 20:34 ` [PATCH v4 07/13] arm: select HAVE_SECCOMP_FILTER Will Drewry
2011-06-03 20:34 ` [PATCH v4 08/13] microblaze: select HAVE_SECCOMP_FILTER and provide seccomp_execve Will Drewry
2011-06-03 20:34 ` [PATCH v4 09/13] mips: " Will Drewry
2011-06-03 20:34 ` [PATCH v4 10/13] s390: " Will Drewry
2011-06-03 20:34 ` [PATCH v4 11/13] powerpc: " Will Drewry
2011-06-03 20:34 ` [PATCH v4 12/13] sparc: " Will Drewry
2011-06-03 23:20   ` David Miller
2011-06-03 20:34 ` [PATCH v4 13/13] sh: select HAVE_SECCOMP_FILTER Will Drewry

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=1307137817-26731-1-git-send-email-wad@chromium.org \
    --to=wad@chromium.org \
    --cc=jmorris@namei.org \
    --cc=kees.cook@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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).