2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifndef _LINUX_SECCOMP_H
|
|
|
|
|
#define _LINUX_SECCOMP_H
|
|
|
|
|
|
2012-10-13 10:46:48 +01:00
|
|
|
#include <uapi/linux/seccomp.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2018-12-09 11:24:13 -07:00
|
|
|
#define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \
|
|
|
|
|
SECCOMP_FILTER_FLAG_LOG | \
|
|
|
|
|
SECCOMP_FILTER_FLAG_SPEC_ALLOW | \
|
2020-03-04 11:05:17 -07:00
|
|
|
SECCOMP_FILTER_FLAG_NEW_LISTENER | \
|
|
|
|
|
SECCOMP_FILTER_FLAG_TSYNC_ESRCH)
|
2014-06-05 00:23:17 -07:00
|
|
|
|
2020-06-02 18:10:43 -07:00
|
|
|
/* sizeof() the first published struct seccomp_notif_addfd */
|
|
|
|
|
#define SECCOMP_NOTIFY_ADDFD_SIZE_VER0 24
|
|
|
|
|
#define SECCOMP_NOTIFY_ADDFD_SIZE_LATEST SECCOMP_NOTIFY_ADDFD_SIZE_VER0
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifdef CONFIG_SECCOMP
|
|
|
|
|
|
|
|
|
|
#include <linux/thread_info.h>
|
2020-05-13 14:11:26 -07:00
|
|
|
#include <linux/atomic.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/seccomp.h>
|
|
|
|
|
|
2012-04-12 16:47:57 -05:00
|
|
|
struct seccomp_filter;
|
|
|
|
|
/**
|
|
|
|
|
* struct seccomp - the state of a seccomp'ed process
|
|
|
|
|
*
|
|
|
|
|
* @mode: indicates one of the valid values above for controlled
|
|
|
|
|
* system calls available to a process.
|
2014-06-27 15:18:48 -07:00
|
|
|
* @filter: must always point to a valid seccomp-filter or NULL as it is
|
|
|
|
|
* accessed without locking during system call entry.
|
2012-04-12 16:47:57 -05:00
|
|
|
*
|
|
|
|
|
* @filter must only be accessed from the context of current as there
|
2014-06-27 15:18:48 -07:00
|
|
|
* is no read locking.
|
2012-04-12 16:47:57 -05:00
|
|
|
*/
|
2012-04-12 16:47:54 -05:00
|
|
|
struct seccomp {
|
|
|
|
|
int mode;
|
2020-05-13 14:11:26 -07:00
|
|
|
atomic_t filter_count;
|
2012-04-12 16:47:57 -05:00
|
|
|
struct seccomp_filter *filter;
|
2012-04-12 16:47:54 -05:00
|
|
|
};
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2014-07-21 18:49:14 -07:00
|
|
|
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
|
2016-05-27 12:57:02 -07:00
|
|
|
extern int __secure_computing(const struct seccomp_data *sd);
|
2019-09-24 08:44:20 +02:00
|
|
|
static inline int secure_computing(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2020-11-16 12:42:00 -05:00
|
|
|
if (unlikely(test_syscall_work(SECCOMP)))
|
2019-09-24 08:44:20 +02:00
|
|
|
return __secure_computing(NULL);
|
2012-04-12 16:47:59 -05:00
|
|
|
return 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2014-07-21 18:49:14 -07:00
|
|
|
#else
|
|
|
|
|
extern void secure_computing_strict(int this_syscall);
|
|
|
|
|
#endif
|
2012-04-17 14:48:57 -05:00
|
|
|
|
2007-07-15 23:41:32 -07:00
|
|
|
extern long prctl_get_seccomp(void);
|
2018-12-09 11:24:12 -07:00
|
|
|
extern long prctl_set_seccomp(unsigned long, void __user *);
|
2007-07-15 23:41:32 -07:00
|
|
|
|
2012-04-12 16:47:54 -05:00
|
|
|
static inline int seccomp_mode(struct seccomp *s)
|
2011-06-05 13:50:24 -04:00
|
|
|
{
|
|
|
|
|
return s->mode;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#else /* CONFIG_SECCOMP */
|
|
|
|
|
|
2009-04-18 11:30:56 +02:00
|
|
|
#include <linux/errno.h>
|
|
|
|
|
|
2012-04-12 16:47:54 -05:00
|
|
|
struct seccomp { };
|
2012-04-12 16:47:57 -05:00
|
|
|
struct seccomp_filter { };
|
2020-07-26 18:14:43 +02:00
|
|
|
struct seccomp_data;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2014-07-21 18:49:14 -07:00
|
|
|
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
|
2019-09-24 08:44:20 +02:00
|
|
|
static inline int secure_computing(void) { return 0; }
|
2020-07-26 18:14:43 +02:00
|
|
|
static inline int __secure_computing(const struct seccomp_data *sd) { return 0; }
|
2014-07-21 18:49:14 -07:00
|
|
|
#else
|
2012-04-17 14:48:57 -05:00
|
|
|
static inline void secure_computing_strict(int this_syscall) { return; }
|
2014-07-21 18:49:14 -07:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-07-15 23:41:32 -07:00
|
|
|
static inline long prctl_get_seccomp(void)
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-12 16:47:57 -05:00
|
|
|
static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3)
|
2007-07-15 23:41:32 -07:00
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-12 16:47:54 -05:00
|
|
|
static inline int seccomp_mode(struct seccomp *s)
|
2011-06-05 13:50:24 -04:00
|
|
|
{
|
2015-06-15 15:29:16 -07:00
|
|
|
return SECCOMP_MODE_DISABLED;
|
2011-06-05 13:50:24 -04:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* CONFIG_SECCOMP */
|
|
|
|
|
|
2012-04-12 16:47:57 -05:00
|
|
|
#ifdef CONFIG_SECCOMP_FILTER
|
2020-05-31 13:50:29 +02:00
|
|
|
extern void seccomp_filter_release(struct task_struct *tsk);
|
2012-04-12 16:47:57 -05:00
|
|
|
extern void get_seccomp_filter(struct task_struct *tsk);
|
|
|
|
|
#else /* CONFIG_SECCOMP_FILTER */
|
2020-05-31 13:50:29 +02:00
|
|
|
static inline void seccomp_filter_release(struct task_struct *tsk)
|
2012-04-12 16:47:57 -05:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
static inline void get_seccomp_filter(struct task_struct *tsk)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif /* CONFIG_SECCOMP_FILTER */
|
2015-10-27 09:23:59 +09:00
|
|
|
|
|
|
|
|
#if defined(CONFIG_SECCOMP_FILTER) && defined(CONFIG_CHECKPOINT_RESTORE)
|
|
|
|
|
extern long seccomp_get_filter(struct task_struct *task,
|
|
|
|
|
unsigned long filter_off, void __user *data);
|
2017-10-11 09:39:21 -06:00
|
|
|
extern long seccomp_get_metadata(struct task_struct *task,
|
|
|
|
|
unsigned long filter_off, void __user *data);
|
2015-10-27 09:23:59 +09:00
|
|
|
#else
|
|
|
|
|
static inline long seccomp_get_filter(struct task_struct *task,
|
|
|
|
|
unsigned long n, void __user *data)
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
2017-10-11 09:39:21 -06:00
|
|
|
static inline long seccomp_get_metadata(struct task_struct *task,
|
|
|
|
|
unsigned long filter_off,
|
|
|
|
|
void __user *data)
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
2015-10-27 09:23:59 +09:00
|
|
|
#endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */
|
2020-11-11 07:33:54 -06:00
|
|
|
|
|
|
|
|
#ifdef CONFIG_SECCOMP_CACHE_DEBUG
|
|
|
|
|
struct seq_file;
|
|
|
|
|
|
|
|
|
|
int proc_pid_seccomp_cache(struct seq_file *m, struct pid_namespace *ns,
|
|
|
|
|
struct pid *pid, struct task_struct *task);
|
|
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* _LINUX_SECCOMP_H */
|