Files
kernel/include/linux/seccomp.h
T

132 lines
3.5 KiB
C
Raw Normal View History

/* 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
#define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \
SECCOMP_FILTER_FLAG_LOG | \
SECCOMP_FILTER_FLAG_SPEC_ALLOW | \
SECCOMP_FILTER_FLAG_NEW_LISTENER | \
SECCOMP_FILTER_FLAG_TSYNC_ESRCH)
/* 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>
#include <linux/atomic.h>
2005-04-16 15:20:36 -07:00
#include <asm/seccomp.h>
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.
*
* @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:54 -05:00
struct seccomp {
int mode;
atomic_t filter_count;
struct seccomp_filter *filter;
2012-04-12 16:47:54 -05:00
};
2005-04-16 15:20:36 -07:00
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
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
}
#else
extern void secure_computing_strict(int this_syscall);
#endif
2007-07-15 23:41:32 -07:00
extern long prctl_get_seccomp(void);
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 */
#include <linux/errno.h>
2012-04-12 16:47:54 -05:00
struct seccomp { };
struct seccomp_filter { };
2020-07-26 18:14:43 +02:00
struct seccomp_data;
2005-04-16 15:20:36 -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; }
#else
static inline void secure_computing_strict(int this_syscall) { return; }
#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;
}
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
{
return SECCOMP_MODE_DISABLED;
2011-06-05 13:50:24 -04:00
}
2005-04-16 15:20:36 -07:00
#endif /* CONFIG_SECCOMP */
#ifdef CONFIG_SECCOMP_FILTER
extern void seccomp_filter_release(struct task_struct *tsk);
extern void get_seccomp_filter(struct task_struct *tsk);
#else /* CONFIG_SECCOMP_FILTER */
static inline void seccomp_filter_release(struct task_struct *tsk)
{
return;
}
static inline void get_seccomp_filter(struct task_struct *tsk)
{
return;
}
#endif /* CONFIG_SECCOMP_FILTER */
#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);
extern long seccomp_get_metadata(struct task_struct *task,
unsigned long filter_off, void __user *data);
#else
static inline long seccomp_get_filter(struct task_struct *task,
unsigned long n, void __user *data)
{
return -EINVAL;
}
static inline long seccomp_get_metadata(struct task_struct *task,
unsigned long filter_off,
void __user *data)
{
return -EINVAL;
}
#endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */
#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 */