Skip to content

Commit 2f4b3bf

Browse files
keestorvalds
authored andcommitted
/proc/pid/status: add "Seccomp" field
It is currently impossible to examine the state of seccomp for a given process. While attaching with gdb and attempting "call prctl(PR_GET_SECCOMP,...)" will work with some situations, it is not reliable. If the process is in seccomp mode 1, this query will kill the process (prctl not allowed), if the process is in mode 2 with prctl not allowed, it will similarly be killed, and in weird cases, if prctl is filtered to return errno 0, it can look like seccomp is disabled. When reviewing the state of running processes, there should be a way to externally examine the seccomp mode. ("Did this build of Chrome end up using seccomp?" "Did my distro ship ssh with seccomp enabled?") This adds the "Seccomp" line to /proc/$pid/status. Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: James Morris <jmorris@namei.org> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 834f82e commit 2f4b3bf

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎Documentation/filesystems/proc.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ read the file /proc/PID/status:
181181
CapPrm: 0000000000000000
182182
CapEff: 0000000000000000
183183
CapBnd: ffffffffffffffff
184+
Seccomp: 0
184185
voluntary_ctxt_switches: 0
185186
nonvoluntary_ctxt_switches: 1
186187

@@ -237,6 +238,7 @@ Table 1-2: Contents of the status files (as of 2.6.30-rc7)
237238
CapPrm bitmap of permitted capabilities
238239
CapEff bitmap of effective capabilities
239240
CapBnd bitmap of capabilities bounding set
241+
Seccomp seccomp mode, like prctl(PR_GET_SECCOMP, ...)
240242
Cpus_allowed mask of CPUs on which this process may run
241243
Cpus_allowed_list Same as previous, but in "list format"
242244
Mems_allowed mask of memory nodes allowed to this process

‎fs/proc/array.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ static inline void task_cap(struct seq_file *m, struct task_struct *p)
336336
render_cap_t(m, "CapBnd:\t", &cap_bset);
337337
}
338338

339+
static inline void task_seccomp(struct seq_file *m, struct task_struct *p)
340+
{
341+
#ifdef CONFIG_SECCOMP
342+
seq_printf(m, "Seccomp:\t%d\n", p->seccomp.mode);
343+
#endif
344+
}
345+
339346
static inline void task_context_switch_counts(struct seq_file *m,
340347
struct task_struct *p)
341348
{
@@ -369,6 +376,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
369376
}
370377
task_sig(m, task);
371378
task_cap(m, task);
379+
task_seccomp(m, task);
372380
task_cpus_allowed(m, task);
373381
cpuset_task_status_allowed(m, task);
374382
task_context_switch_counts(m, task);

0 commit comments

Comments
 (0)