]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/seccomp.h
Merge tag 'rxrpc-next-20171111' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-bionic-kernel.git] / include / linux / seccomp.h
CommitLineData
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
15struct 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
27struct seccomp {
28 int mode;
e2cfabdf 29 struct seccomp_filter *filter;
932ecebb 30};
1da177e4 31
a4412fc9 32#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
2f275de5
AL
33extern int __secure_computing(const struct seccomp_data *sd);
34static 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
41extern void secure_computing_strict(int this_syscall);
42#endif
e4da89d0 43
1d9d02fe 44extern long prctl_get_seccomp(void);
e2cfabdf 45extern long prctl_set_seccomp(unsigned long, char __user *);
1d9d02fe 46
932ecebb 47static 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 56struct seccomp { };
e2cfabdf 57struct seccomp_filter { };
1da177e4 58
a4412fc9 59#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
2f275de5 60static inline int secure_computing(struct seccomp_data *sd) { return 0; }
a4412fc9 61#else
e4da89d0 62static inline void secure_computing_strict(int this_syscall) { return; }
a4412fc9 63#endif
1da177e4 64
1d9d02fe
AA
65static inline long prctl_get_seccomp(void)
66{
67 return -EINVAL;
68}
69
e2cfabdf 70static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3)
1d9d02fe
AA
71{
72 return -EINVAL;
73}
74
932ecebb 75static 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
82extern void put_seccomp_filter(struct task_struct *tsk);
83extern void get_seccomp_filter(struct task_struct *tsk);
e2cfabdf
WD
84#else /* CONFIG_SECCOMP_FILTER */
85static inline void put_seccomp_filter(struct task_struct *tsk)
86{
87 return;
88}
89static 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)
96extern long seccomp_get_filter(struct task_struct *task,
97 unsigned long filter_off, void __user *data);
98#else
99static 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 */