1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_SECCOMP_H
3 #define _LINUX_SECCOMP_H
5 #include <uapi/linux/seccomp.h>
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 | \
11 SECCOMP_FILTER_FLAG_TSYNC_ESRCH | \
12 SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV)
14 /* sizeof() the first published struct seccomp_notif_addfd */
15 #define SECCOMP_NOTIFY_ADDFD_SIZE_VER0 24
16 #define SECCOMP_NOTIFY_ADDFD_SIZE_LATEST SECCOMP_NOTIFY_ADDFD_SIZE_VER0
20 #include <linux/thread_info.h>
21 #include <linux/atomic.h>
22 #include <asm/seccomp.h>
24 struct seccomp_filter;
26 * struct seccomp - the state of a seccomp'ed process
28 * @mode: indicates one of the valid values above for controlled
29 * system calls available to a process.
30 * @filter: must always point to a valid seccomp-filter or NULL as it is
31 * accessed without locking during system call entry.
33 * @filter must only be accessed from the context of current as there
38 atomic_t filter_count;
39 struct seccomp_filter *filter;
42 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
43 extern int __secure_computing(const struct seccomp_data *sd);
44 static inline int secure_computing(void)
46 if (unlikely(test_syscall_work(SECCOMP)))
47 return __secure_computing(NULL);
51 extern void secure_computing_strict(int this_syscall);
54 extern long prctl_get_seccomp(void);
55 extern long prctl_set_seccomp(unsigned long, void __user *);
57 static inline int seccomp_mode(struct seccomp *s)
62 #else /* CONFIG_SECCOMP */
64 #include <linux/errno.h>
67 struct seccomp_filter { };
70 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
71 static inline int secure_computing(void) { return 0; }
72 static inline int __secure_computing(const struct seccomp_data *sd) { return 0; }
74 static inline void secure_computing_strict(int this_syscall) { return; }
77 static inline long prctl_get_seccomp(void)
82 static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3)
87 static inline int seccomp_mode(struct seccomp *s)
89 return SECCOMP_MODE_DISABLED;
91 #endif /* CONFIG_SECCOMP */
93 #ifdef CONFIG_SECCOMP_FILTER
94 extern void seccomp_filter_release(struct task_struct *tsk);
95 extern void get_seccomp_filter(struct task_struct *tsk);
96 #else /* CONFIG_SECCOMP_FILTER */
97 static inline void seccomp_filter_release(struct task_struct *tsk)
101 static inline void get_seccomp_filter(struct task_struct *tsk)
105 #endif /* CONFIG_SECCOMP_FILTER */
107 #if defined(CONFIG_SECCOMP_FILTER) && defined(CONFIG_CHECKPOINT_RESTORE)
108 extern long seccomp_get_filter(struct task_struct *task,
109 unsigned long filter_off, void __user *data);
110 extern long seccomp_get_metadata(struct task_struct *task,
111 unsigned long filter_off, void __user *data);
113 static inline long seccomp_get_filter(struct task_struct *task,
114 unsigned long n, void __user *data)
118 static inline long seccomp_get_metadata(struct task_struct *task,
119 unsigned long filter_off,
124 #endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */
126 #ifdef CONFIG_SECCOMP_CACHE_DEBUG
129 int proc_pid_seccomp_cache(struct seq_file *m, struct pid_namespace *ns,
130 struct pid *pid, struct task_struct *task);
132 #endif /* _LINUX_SECCOMP_H */