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