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> |
a6e1420c | 6 | #include <linux/seccomp_types.h> |
e2cfabdf | 7 | |
6a21cc50 TA |
8 | #define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \ |
9 | SECCOMP_FILTER_FLAG_LOG | \ | |
10 | SECCOMP_FILTER_FLAG_SPEC_ALLOW | \ | |
51891498 | 11 | SECCOMP_FILTER_FLAG_NEW_LISTENER | \ |
c2aa2dfe SD |
12 | SECCOMP_FILTER_FLAG_TSYNC_ESRCH | \ |
13 | SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV) | |
c2e1f2e3 | 14 | |
7cf97b12 SD |
15 | /* sizeof() the first published struct seccomp_notif_addfd */ |
16 | #define SECCOMP_NOTIFY_ADDFD_SIZE_VER0 24 | |
17 | #define SECCOMP_NOTIFY_ADDFD_SIZE_LATEST SECCOMP_NOTIFY_ADDFD_SIZE_VER0 | |
18 | ||
1da177e4 LT |
19 | #ifdef CONFIG_SECCOMP |
20 | ||
1da177e4 | 21 | #include <linux/thread_info.h> |
c818c03b | 22 | #include <linux/atomic.h> |
1da177e4 LT |
23 | #include <asm/seccomp.h> |
24 | ||
a4412fc9 | 25 | #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER |
2f275de5 | 26 | extern int __secure_computing(const struct seccomp_data *sd); |
fefad9ef | 27 | static inline int secure_computing(void) |
1da177e4 | 28 | { |
23d67a54 | 29 | if (unlikely(test_syscall_work(SECCOMP))) |
fefad9ef | 30 | return __secure_computing(NULL); |
acf3b2c7 | 31 | return 0; |
1da177e4 | 32 | } |
a4412fc9 AL |
33 | #else |
34 | extern void secure_computing_strict(int this_syscall); | |
35 | #endif | |
e4da89d0 | 36 | |
1d9d02fe | 37 | extern long prctl_get_seccomp(void); |
a5662e4d | 38 | extern long prctl_set_seccomp(unsigned long, void __user *); |
1d9d02fe | 39 | |
932ecebb | 40 | static inline int seccomp_mode(struct seccomp *s) |
5cec93c2 AL |
41 | { |
42 | return s->mode; | |
43 | } | |
44 | ||
1da177e4 LT |
45 | #else /* CONFIG_SECCOMP */ |
46 | ||
42a17ad2 RB |
47 | #include <linux/errno.h> |
48 | ||
3135f5b7 | 49 | struct seccomp_data; |
1da177e4 | 50 | |
a4412fc9 | 51 | #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER |
fefad9ef | 52 | static inline int secure_computing(void) { return 0; } |
3135f5b7 | 53 | static inline int __secure_computing(const struct seccomp_data *sd) { return 0; } |
a4412fc9 | 54 | #else |
e4da89d0 | 55 | static inline void secure_computing_strict(int this_syscall) { return; } |
a4412fc9 | 56 | #endif |
1da177e4 | 57 | |
1d9d02fe AA |
58 | static inline long prctl_get_seccomp(void) |
59 | { | |
60 | return -EINVAL; | |
61 | } | |
62 | ||
e2cfabdf | 63 | static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3) |
1d9d02fe AA |
64 | { |
65 | return -EINVAL; | |
66 | } | |
67 | ||
932ecebb | 68 | static inline int seccomp_mode(struct seccomp *s) |
5cec93c2 | 69 | { |
221272f9 | 70 | return SECCOMP_MODE_DISABLED; |
5cec93c2 | 71 | } |
1da177e4 LT |
72 | #endif /* CONFIG_SECCOMP */ |
73 | ||
e2cfabdf | 74 | #ifdef CONFIG_SECCOMP_FILTER |
3a15fb6e | 75 | extern void seccomp_filter_release(struct task_struct *tsk); |
e2cfabdf | 76 | extern void get_seccomp_filter(struct task_struct *tsk); |
e2cfabdf | 77 | #else /* CONFIG_SECCOMP_FILTER */ |
3a15fb6e | 78 | static inline void seccomp_filter_release(struct task_struct *tsk) |
e2cfabdf WD |
79 | { |
80 | return; | |
81 | } | |
82 | static inline void get_seccomp_filter(struct task_struct *tsk) | |
83 | { | |
84 | return; | |
85 | } | |
86 | #endif /* CONFIG_SECCOMP_FILTER */ | |
f8e529ed TA |
87 | |
88 | #if defined(CONFIG_SECCOMP_FILTER) && defined(CONFIG_CHECKPOINT_RESTORE) | |
89 | extern long seccomp_get_filter(struct task_struct *task, | |
90 | unsigned long filter_off, void __user *data); | |
26500475 TA |
91 | extern long seccomp_get_metadata(struct task_struct *task, |
92 | unsigned long filter_off, void __user *data); | |
f8e529ed TA |
93 | #else |
94 | static inline long seccomp_get_filter(struct task_struct *task, | |
95 | unsigned long n, void __user *data) | |
96 | { | |
97 | return -EINVAL; | |
98 | } | |
26500475 TA |
99 | static inline long seccomp_get_metadata(struct task_struct *task, |
100 | unsigned long filter_off, | |
101 | void __user *data) | |
102 | { | |
103 | return -EINVAL; | |
104 | } | |
f8e529ed | 105 | #endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */ |
0d8315dd YZ |
106 | |
107 | #ifdef CONFIG_SECCOMP_CACHE_DEBUG | |
108 | struct seq_file; | |
6d5e9d63 KO |
109 | struct pid_namespace; |
110 | struct pid; | |
0d8315dd YZ |
111 | |
112 | int proc_pid_seccomp_cache(struct seq_file *m, struct pid_namespace *ns, | |
113 | struct pid *pid, struct task_struct *task); | |
114 | #endif | |
1da177e4 | 115 | #endif /* _LINUX_SECCOMP_H */ |