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