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