Merge tag 'perf-tools-fixes-for-v6.9-2024-04-19' of git://git.kernel.org/pub/scm...
[linux-2.6-block.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>
a6e1420c 6#include <linux/seccomp_types.h>
e2cfabdf 7
6a21cc50
TA
8#define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \
9 SECCOMP_FILTER_FLAG_LOG | \
10 SECCOMP_FILTER_FLAG_SPEC_ALLOW | \
51891498 11 SECCOMP_FILTER_FLAG_NEW_LISTENER | \
c2aa2dfe
SD
12 SECCOMP_FILTER_FLAG_TSYNC_ESRCH | \
13 SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV)
c2e1f2e3 14
7cf97b12
SD
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
18
1da177e4
LT
19#ifdef CONFIG_SECCOMP
20
1da177e4 21#include <linux/thread_info.h>
c818c03b 22#include <linux/atomic.h>
1da177e4
LT
23#include <asm/seccomp.h>
24
a4412fc9 25#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
2f275de5 26extern int __secure_computing(const struct seccomp_data *sd);
fefad9ef 27static inline int secure_computing(void)
1da177e4 28{
23d67a54 29 if (unlikely(test_syscall_work(SECCOMP)))
fefad9ef 30 return __secure_computing(NULL);
acf3b2c7 31 return 0;
1da177e4 32}
a4412fc9
AL
33#else
34extern void secure_computing_strict(int this_syscall);
35#endif
e4da89d0 36
1d9d02fe 37extern long prctl_get_seccomp(void);
a5662e4d 38extern long prctl_set_seccomp(unsigned long, void __user *);
1d9d02fe 39
932ecebb 40static inline int seccomp_mode(struct seccomp *s)
5cec93c2
AL
41{
42 return s->mode;
43}
44
1da177e4
LT
45#else /* CONFIG_SECCOMP */
46
42a17ad2
RB
47#include <linux/errno.h>
48
3135f5b7 49struct seccomp_data;
1da177e4 50
a4412fc9 51#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
fefad9ef 52static inline int secure_computing(void) { return 0; }
3135f5b7 53static inline int __secure_computing(const struct seccomp_data *sd) { return 0; }
a4412fc9 54#else
e4da89d0 55static inline void secure_computing_strict(int this_syscall) { return; }
a4412fc9 56#endif
1da177e4 57
1d9d02fe
AA
58static inline long prctl_get_seccomp(void)
59{
60 return -EINVAL;
61}
62
e2cfabdf 63static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3)
1d9d02fe
AA
64{
65 return -EINVAL;
66}
67
932ecebb 68static inline int seccomp_mode(struct seccomp *s)
5cec93c2 69{
221272f9 70 return SECCOMP_MODE_DISABLED;
5cec93c2 71}
1da177e4
LT
72#endif /* CONFIG_SECCOMP */
73
e2cfabdf 74#ifdef CONFIG_SECCOMP_FILTER
3a15fb6e 75extern void seccomp_filter_release(struct task_struct *tsk);
e2cfabdf 76extern void get_seccomp_filter(struct task_struct *tsk);
e2cfabdf 77#else /* CONFIG_SECCOMP_FILTER */
3a15fb6e 78static inline void seccomp_filter_release(struct task_struct *tsk)
e2cfabdf
WD
79{
80 return;
81}
82static inline void get_seccomp_filter(struct task_struct *tsk)
83{
84 return;
85}
86#endif /* CONFIG_SECCOMP_FILTER */
f8e529ed
TA
87
88#if defined(CONFIG_SECCOMP_FILTER) && defined(CONFIG_CHECKPOINT_RESTORE)
89extern long seccomp_get_filter(struct task_struct *task,
90 unsigned long filter_off, void __user *data);
26500475
TA
91extern long seccomp_get_metadata(struct task_struct *task,
92 unsigned long filter_off, void __user *data);
f8e529ed
TA
93#else
94static inline long seccomp_get_filter(struct task_struct *task,
95 unsigned long n, void __user *data)
96{
97 return -EINVAL;
98}
26500475
TA
99static inline long seccomp_get_metadata(struct task_struct *task,
100 unsigned long filter_off,
101 void __user *data)
102{
103 return -EINVAL;
104}
f8e529ed 105#endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */
0d8315dd
YZ
106
107#ifdef CONFIG_SECCOMP_CACHE_DEBUG
108struct seq_file;
6d5e9d63
KO
109struct pid_namespace;
110struct pid;
0d8315dd
YZ
111
112int proc_pid_seccomp_cache(struct seq_file *m, struct pid_namespace *ns,
113 struct pid *pid, struct task_struct *task);
114#endif
1da177e4 115#endif /* _LINUX_SECCOMP_H */