]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _LINUX_SECCOMP_H |
3 | #define _LINUX_SECCOMP_H | |
4 | ||
607ca46e | 5 | #include <uapi/linux/seccomp.h> |
e2cfabdf | 6 | |
6a21cc50 TA |
7 | #define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \ |
8 | SECCOMP_FILTER_FLAG_LOG | \ | |
9 | SECCOMP_FILTER_FLAG_SPEC_ALLOW | \ | |
51891498 TA |
10 | SECCOMP_FILTER_FLAG_NEW_LISTENER | \ |
11 | SECCOMP_FILTER_FLAG_TSYNC_ESRCH) | |
c2e1f2e3 | 12 | |
1da177e4 LT |
13 | #ifdef CONFIG_SECCOMP |
14 | ||
1da177e4 LT |
15 | #include <linux/thread_info.h> |
16 | #include <asm/seccomp.h> | |
17 | ||
e2cfabdf WD |
18 | struct seccomp_filter; |
19 | /** | |
20 | * struct seccomp - the state of a seccomp'ed process | |
21 | * | |
22 | * @mode: indicates one of the valid values above for controlled | |
23 | * system calls available to a process. | |
dbd95212 KC |
24 | * @filter: must always point to a valid seccomp-filter or NULL as it is |
25 | * accessed without locking during system call entry. | |
e2cfabdf WD |
26 | * |
27 | * @filter must only be accessed from the context of current as there | |
dbd95212 | 28 | * is no read locking. |
e2cfabdf | 29 | */ |
932ecebb WD |
30 | struct seccomp { |
31 | int mode; | |
e2cfabdf | 32 | struct seccomp_filter *filter; |
932ecebb | 33 | }; |
1da177e4 | 34 | |
a4412fc9 | 35 | #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER |
2f275de5 | 36 | extern int __secure_computing(const struct seccomp_data *sd); |
fefad9ef | 37 | static inline int secure_computing(void) |
1da177e4 LT |
38 | { |
39 | if (unlikely(test_thread_flag(TIF_SECCOMP))) | |
fefad9ef | 40 | return __secure_computing(NULL); |
acf3b2c7 | 41 | return 0; |
1da177e4 | 42 | } |
a4412fc9 AL |
43 | #else |
44 | extern void secure_computing_strict(int this_syscall); | |
45 | #endif | |
e4da89d0 | 46 | |
1d9d02fe | 47 | extern long prctl_get_seccomp(void); |
a5662e4d | 48 | extern long prctl_set_seccomp(unsigned long, void __user *); |
1d9d02fe | 49 | |
932ecebb | 50 | static inline int seccomp_mode(struct seccomp *s) |
5cec93c2 AL |
51 | { |
52 | return s->mode; | |
53 | } | |
54 | ||
1da177e4 LT |
55 | #else /* CONFIG_SECCOMP */ |
56 | ||
42a17ad2 RB |
57 | #include <linux/errno.h> |
58 | ||
932ecebb | 59 | struct seccomp { }; |
e2cfabdf | 60 | struct seccomp_filter { }; |
1da177e4 | 61 | |
a4412fc9 | 62 | #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER |
fefad9ef | 63 | static inline int secure_computing(void) { return 0; } |
a4412fc9 | 64 | #else |
e4da89d0 | 65 | static inline void secure_computing_strict(int this_syscall) { return; } |
a4412fc9 | 66 | #endif |
1da177e4 | 67 | |
1d9d02fe AA |
68 | static inline long prctl_get_seccomp(void) |
69 | { | |
70 | return -EINVAL; | |
71 | } | |
72 | ||
e2cfabdf | 73 | static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3) |
1d9d02fe AA |
74 | { |
75 | return -EINVAL; | |
76 | } | |
77 | ||
932ecebb | 78 | static inline int seccomp_mode(struct seccomp *s) |
5cec93c2 | 79 | { |
221272f9 | 80 | return SECCOMP_MODE_DISABLED; |
5cec93c2 | 81 | } |
1da177e4 LT |
82 | #endif /* CONFIG_SECCOMP */ |
83 | ||
e2cfabdf WD |
84 | #ifdef CONFIG_SECCOMP_FILTER |
85 | extern void put_seccomp_filter(struct task_struct *tsk); | |
86 | extern void get_seccomp_filter(struct task_struct *tsk); | |
e2cfabdf WD |
87 | #else /* CONFIG_SECCOMP_FILTER */ |
88 | static inline void put_seccomp_filter(struct task_struct *tsk) | |
89 | { | |
90 | return; | |
91 | } | |
92 | static inline void get_seccomp_filter(struct task_struct *tsk) | |
93 | { | |
94 | return; | |
95 | } | |
96 | #endif /* CONFIG_SECCOMP_FILTER */ | |
f8e529ed TA |
97 | |
98 | #if defined(CONFIG_SECCOMP_FILTER) && defined(CONFIG_CHECKPOINT_RESTORE) | |
99 | extern long seccomp_get_filter(struct task_struct *task, | |
100 | unsigned long filter_off, void __user *data); | |
26500475 TA |
101 | extern long seccomp_get_metadata(struct task_struct *task, |
102 | unsigned long filter_off, void __user *data); | |
f8e529ed TA |
103 | #else |
104 | static inline long seccomp_get_filter(struct task_struct *task, | |
105 | unsigned long n, void __user *data) | |
106 | { | |
107 | return -EINVAL; | |
108 | } | |
26500475 TA |
109 | static inline long seccomp_get_metadata(struct task_struct *task, |
110 | unsigned long filter_off, | |
111 | void __user *data) | |
112 | { | |
113 | return -EINVAL; | |
114 | } | |
f8e529ed | 115 | #endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */ |
1da177e4 | 116 | #endif /* _LINUX_SECCOMP_H */ |