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