]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _LINUX_SECCOMP_H |
2 | #define _LINUX_SECCOMP_H | |
3 | ||
607ca46e | 4 | #include <uapi/linux/seccomp.h> |
e2cfabdf | 5 | |
c2e1f2e3 KC |
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 |
13 | struct 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. | |
dbd95212 KC |
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 | |
dbd95212 | 23 | * is no read locking. |
e2cfabdf | 24 | */ |
932ecebb WD |
25 | struct seccomp { |
26 | int mode; | |
e2cfabdf | 27 | struct seccomp_filter *filter; |
932ecebb | 28 | }; |
1da177e4 | 29 | |
a4412fc9 AL |
30 | #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER |
31 | extern int __secure_computing(void); | |
32 | static inline int secure_computing(void) | |
1da177e4 LT |
33 | { |
34 | if (unlikely(test_thread_flag(TIF_SECCOMP))) | |
a4412fc9 | 35 | return __secure_computing(); |
acf3b2c7 | 36 | return 0; |
1da177e4 | 37 | } |
13aa72f0 AL |
38 | |
39 | #define SECCOMP_PHASE1_OK 0 | |
40 | #define SECCOMP_PHASE1_SKIP 1 | |
41 | ||
d39bd00d | 42 | extern u32 seccomp_phase1(struct seccomp_data *sd); |
13aa72f0 | 43 | int seccomp_phase2(u32 phase1_result); |
a4412fc9 AL |
44 | #else |
45 | extern void secure_computing_strict(int this_syscall); | |
46 | #endif | |
e4da89d0 | 47 | |
1d9d02fe | 48 | extern long prctl_get_seccomp(void); |
e2cfabdf | 49 | extern long prctl_set_seccomp(unsigned long, char __user *); |
1d9d02fe | 50 | |
932ecebb | 51 | static inline int seccomp_mode(struct seccomp *s) |
5cec93c2 AL |
52 | { |
53 | return s->mode; | |
54 | } | |
55 | ||
1da177e4 LT |
56 | #else /* CONFIG_SECCOMP */ |
57 | ||
42a17ad2 RB |
58 | #include <linux/errno.h> |
59 | ||
932ecebb | 60 | struct seccomp { }; |
e2cfabdf | 61 | struct seccomp_filter { }; |
1da177e4 | 62 | |
a4412fc9 AL |
63 | #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER |
64 | static inline int secure_computing(void) { return 0; } | |
65 | #else | |
e4da89d0 | 66 | static inline void secure_computing_strict(int this_syscall) { return; } |
a4412fc9 | 67 | #endif |
1da177e4 | 68 | |
1d9d02fe AA |
69 | static inline long prctl_get_seccomp(void) |
70 | { | |
71 | return -EINVAL; | |
72 | } | |
73 | ||
e2cfabdf | 74 | static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3) |
1d9d02fe AA |
75 | { |
76 | return -EINVAL; | |
77 | } | |
78 | ||
932ecebb | 79 | static inline int seccomp_mode(struct seccomp *s) |
5cec93c2 | 80 | { |
221272f9 | 81 | return SECCOMP_MODE_DISABLED; |
5cec93c2 | 82 | } |
1da177e4 LT |
83 | #endif /* CONFIG_SECCOMP */ |
84 | ||
e2cfabdf WD |
85 | #ifdef CONFIG_SECCOMP_FILTER |
86 | extern void put_seccomp_filter(struct task_struct *tsk); | |
87 | extern void get_seccomp_filter(struct task_struct *tsk); | |
e2cfabdf WD |
88 | #else /* CONFIG_SECCOMP_FILTER */ |
89 | static inline void put_seccomp_filter(struct task_struct *tsk) | |
90 | { | |
91 | return; | |
92 | } | |
93 | static inline void get_seccomp_filter(struct task_struct *tsk) | |
94 | { | |
95 | return; | |
96 | } | |
97 | #endif /* CONFIG_SECCOMP_FILTER */ | |
f8e529ed TA |
98 | |
99 | #if defined(CONFIG_SECCOMP_FILTER) && defined(CONFIG_CHECKPOINT_RESTORE) | |
100 | extern long seccomp_get_filter(struct task_struct *task, | |
101 | unsigned long filter_off, void __user *data); | |
102 | #else | |
103 | static inline long seccomp_get_filter(struct task_struct *task, | |
104 | unsigned long n, void __user *data) | |
105 | { | |
106 | return -EINVAL; | |
107 | } | |
108 | #endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */ | |
1da177e4 | 109 | #endif /* _LINUX_SECCOMP_H */ |