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