Merge tag 'v3.10.55' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / seccomp.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_SECCOMP_H
2#define _LINUX_SECCOMP_H
3
607ca46e 4#include <uapi/linux/seccomp.h>
e2cfabdf 5
6fa3eb70
S
6#define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC)
7
1da177e4
LT
8#ifdef CONFIG_SECCOMP
9
1da177e4
LT
10#include <linux/thread_info.h>
11#include <asm/seccomp.h>
12
e2cfabdf
WD
13struct seccomp_filter;
14/**
15 * struct seccomp - the state of a seccomp'ed process
16 *
17 * @mode: indicates one of the valid values above for controlled
18 * system calls available to a process.
6fa3eb70
S
19 * @filter: must always point to a valid seccomp-filter or NULL as it is
20 * accessed without locking during system call entry.
e2cfabdf
WD
21 *
22 * @filter must only be accessed from the context of current as there
6fa3eb70 23 * is no read locking.
e2cfabdf 24 */
932ecebb
WD
25struct seccomp {
26 int mode;
e2cfabdf 27 struct seccomp_filter *filter;
932ecebb 28};
1da177e4 29
acf3b2c7
WD
30extern int __secure_computing(int);
31static inline int secure_computing(int this_syscall)
1da177e4
LT
32{
33 if (unlikely(test_thread_flag(TIF_SECCOMP)))
acf3b2c7
WD
34 return __secure_computing(this_syscall);
35 return 0;
1da177e4
LT
36}
37
e4da89d0
WD
38/* A wrapper for architectures supporting only SECCOMP_MODE_STRICT. */
39static inline void secure_computing_strict(int this_syscall)
40{
41 BUG_ON(secure_computing(this_syscall) != 0);
42}
43
1d9d02fe 44extern long prctl_get_seccomp(void);
e2cfabdf 45extern long prctl_set_seccomp(unsigned long, char __user *);
1d9d02fe 46
932ecebb 47static inline int seccomp_mode(struct seccomp *s)
5cec93c2
AL
48{
49 return s->mode;
50}
51
1da177e4
LT
52#else /* CONFIG_SECCOMP */
53
42a17ad2
RB
54#include <linux/errno.h>
55
932ecebb 56struct seccomp { };
e2cfabdf 57struct seccomp_filter { };
1da177e4 58
b1fa650c 59static inline int secure_computing(int this_syscall) { return 0; }
e4da89d0 60static inline void secure_computing_strict(int this_syscall) { return; }
1da177e4 61
1d9d02fe
AA
62static inline long prctl_get_seccomp(void)
63{
64 return -EINVAL;
65}
66
e2cfabdf 67static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3)
1d9d02fe
AA
68{
69 return -EINVAL;
70}
71
932ecebb 72static inline int seccomp_mode(struct seccomp *s)
5cec93c2
AL
73{
74 return 0;
75}
1da177e4
LT
76#endif /* CONFIG_SECCOMP */
77
e2cfabdf
WD
78#ifdef CONFIG_SECCOMP_FILTER
79extern void put_seccomp_filter(struct task_struct *tsk);
80extern void get_seccomp_filter(struct task_struct *tsk);
81extern u32 seccomp_bpf_load(int off);
82#else /* CONFIG_SECCOMP_FILTER */
83static inline void put_seccomp_filter(struct task_struct *tsk)
84{
85 return;
86}
87static inline void get_seccomp_filter(struct task_struct *tsk)
88{
89 return;
90}
91#endif /* CONFIG_SECCOMP_FILTER */
1da177e4 92#endif /* _LINUX_SECCOMP_H */