1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_SECCOMP_H
3 #define _LINUX_SECCOMP_H
5 #include <uapi/linux/seccomp.h>
6 #include <linux/seccomp_types.h>
8 #define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \
9 SECCOMP_FILTER_FLAG_LOG | \
10 SECCOMP_FILTER_FLAG_SPEC_ALLOW | \
11 SECCOMP_FILTER_FLAG_NEW_LISTENER | \
12 SECCOMP_FILTER_FLAG_TSYNC_ESRCH | \
13 SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV)
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
21 #include <linux/thread_info.h>
22 #include <linux/atomic.h>
23 #include <asm/seccomp.h>
25 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
26 extern int __secure_computing(const struct seccomp_data *sd);
27 static inline int secure_computing(void)
29 if (unlikely(test_syscall_work(SECCOMP)))
30 return __secure_computing(NULL);
34 extern void secure_computing_strict(int this_syscall);
37 extern long prctl_get_seccomp(void);
38 extern long prctl_set_seccomp(unsigned long, void __user *);
40 static inline int seccomp_mode(struct seccomp *s)
45 #else /* CONFIG_SECCOMP */
47 #include <linux/errno.h>
51 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
52 static inline int secure_computing(void) { return 0; }
53 static inline int __secure_computing(const struct seccomp_data *sd) { return 0; }
55 static inline void secure_computing_strict(int this_syscall) { return; }
58 static inline long prctl_get_seccomp(void)
63 static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3)
68 static inline int seccomp_mode(struct seccomp *s)
70 return SECCOMP_MODE_DISABLED;
72 #endif /* CONFIG_SECCOMP */
74 #ifdef CONFIG_SECCOMP_FILTER
75 extern void seccomp_filter_release(struct task_struct *tsk);
76 extern void get_seccomp_filter(struct task_struct *tsk);
77 #else /* CONFIG_SECCOMP_FILTER */
78 static inline void seccomp_filter_release(struct task_struct *tsk)
82 static inline void get_seccomp_filter(struct task_struct *tsk)
86 #endif /* CONFIG_SECCOMP_FILTER */
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);
91 extern long seccomp_get_metadata(struct task_struct *task,
92 unsigned long filter_off, void __user *data);
94 static inline long seccomp_get_filter(struct task_struct *task,
95 unsigned long n, void __user *data)
99 static inline long seccomp_get_metadata(struct task_struct *task,
100 unsigned long filter_off,
105 #endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */
107 #ifdef CONFIG_SECCOMP_CACHE_DEBUG
109 struct pid_namespace;
112 int proc_pid_seccomp_cache(struct seq_file *m, struct pid_namespace *ns,
113 struct pid *pid, struct task_struct *task);
115 #endif /* _LINUX_SECCOMP_H */