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