aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/siginfo.h22
-rw-r--r--include/asm-generic/syscall.h14
-rw-r--r--include/keys/keyring-type.h2
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/audit.h8
-rw-r--r--include/linux/filter.h12
-rw-r--r--include/linux/key.h11
-rw-r--r--include/linux/keyctl.h1
-rw-r--r--include/linux/lsm_audit.h6
-rw-r--r--include/linux/prctl.h15
-rw-r--r--include/linux/ptrace.h5
-rw-r--r--include/linux/sched.h4
-rw-r--r--include/linux/seccomp.h107
-rw-r--r--include/linux/security.h14
14 files changed, 186 insertions, 36 deletions
diff --git a/include/asm-generic/siginfo.h b/include/asm-generic/siginfo.h
index 5e5e3865f1ed..8ed67779fc09 100644
--- a/include/asm-generic/siginfo.h
+++ b/include/asm-generic/siginfo.h
@@ -98,9 +98,18 @@ typedef struct siginfo {
98 __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 98 __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
99 int _fd; 99 int _fd;
100 } _sigpoll; 100 } _sigpoll;
101
102 /* SIGSYS */
103 struct {
104 void __user *_call_addr; /* calling user insn */
105 int _syscall; /* triggering system call number */
106 unsigned int _arch; /* AUDIT_ARCH_* of syscall */
107 } _sigsys;
101 } _sifields; 108 } _sifields;
102} __ARCH_SI_ATTRIBUTES siginfo_t; 109} __ARCH_SI_ATTRIBUTES siginfo_t;
103 110
111/* If the arch shares siginfo, then it has SIGSYS. */
112#define __ARCH_SIGSYS
104#endif 113#endif
105 114
106/* 115/*
@@ -124,6 +133,11 @@ typedef struct siginfo {
124#define si_addr_lsb _sifields._sigfault._addr_lsb 133#define si_addr_lsb _sifields._sigfault._addr_lsb
125#define si_band _sifields._sigpoll._band 134#define si_band _sifields._sigpoll._band
126#define si_fd _sifields._sigpoll._fd 135#define si_fd _sifields._sigpoll._fd
136#ifdef __ARCH_SIGSYS
137#define si_call_addr _sifields._sigsys._call_addr
138#define si_syscall _sifields._sigsys._syscall
139#define si_arch _sifields._sigsys._arch
140#endif
127 141
128#ifdef __KERNEL__ 142#ifdef __KERNEL__
129#define __SI_MASK 0xffff0000u 143#define __SI_MASK 0xffff0000u
@@ -134,6 +148,7 @@ typedef struct siginfo {
134#define __SI_CHLD (4 << 16) 148#define __SI_CHLD (4 << 16)
135#define __SI_RT (5 << 16) 149#define __SI_RT (5 << 16)
136#define __SI_MESGQ (6 << 16) 150#define __SI_MESGQ (6 << 16)
151#define __SI_SYS (7 << 16)
137#define __SI_CODE(T,N) ((T) | ((N) & 0xffff)) 152#define __SI_CODE(T,N) ((T) | ((N) & 0xffff))
138#else 153#else
139#define __SI_KILL 0 154#define __SI_KILL 0
@@ -143,6 +158,7 @@ typedef struct siginfo {
143#define __SI_CHLD 0 158#define __SI_CHLD 0
144#define __SI_RT 0 159#define __SI_RT 0
145#define __SI_MESGQ 0 160#define __SI_MESGQ 0
161#define __SI_SYS 0
146#define __SI_CODE(T,N) (N) 162#define __SI_CODE(T,N) (N)
147#endif 163#endif
148 164
@@ -240,6 +256,12 @@ typedef struct siginfo {
240#define NSIGPOLL 6 256#define NSIGPOLL 6
241 257
242/* 258/*
259 * SIGSYS si_codes
260 */
261#define SYS_SECCOMP (__SI_SYS|1) /* seccomp triggered */
262#define NSIGSYS 1
263
264/*
243 * sigevent definitions 265 * sigevent definitions
244 * 266 *
245 * It seems likely that SIGEV_THREAD will have to be handled from 267 * It seems likely that SIGEV_THREAD will have to be handled from
diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h
index 5c122ae6bfa6..5b09392db673 100644
--- a/include/asm-generic/syscall.h
+++ b/include/asm-generic/syscall.h
@@ -142,4 +142,18 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
142 unsigned int i, unsigned int n, 142 unsigned int i, unsigned int n,
143 const unsigned long *args); 143 const unsigned long *args);
144 144
145/**
146 * syscall_get_arch - return the AUDIT_ARCH for the current system call
147 * @task: task of interest, must be in system call entry tracing
148 * @regs: task_pt_regs() of @task
149 *
150 * Returns the AUDIT_ARCH_* based on the system call convention in use.
151 *
152 * It's only valid to call this when @task is stopped on entry to a system
153 * call, due to %TIF_SYSCALL_TRACE, %TIF_SYSCALL_AUDIT, or %TIF_SECCOMP.
154 *
155 * Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must
156 * provide an implementation of this.
157 */
158int syscall_get_arch(struct task_struct *task, struct pt_regs *regs);
145#endif /* _ASM_SYSCALL_H */ 159#endif /* _ASM_SYSCALL_H */
diff --git a/include/keys/keyring-type.h b/include/keys/keyring-type.h
index 843f872a4b63..cf49159b0e3a 100644
--- a/include/keys/keyring-type.h
+++ b/include/keys/keyring-type.h
@@ -24,7 +24,7 @@ struct keyring_list {
24 unsigned short maxkeys; /* max keys this list can hold */ 24 unsigned short maxkeys; /* max keys this list can hold */
25 unsigned short nkeys; /* number of keys currently held */ 25 unsigned short nkeys; /* number of keys currently held */
26 unsigned short delkey; /* key to be unlinked by RCU */ 26 unsigned short delkey; /* key to be unlinked by RCU */
27 struct key *keys[0]; 27 struct key __rcu *keys[0];
28}; 28};
29 29
30 30
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index b5d568fa19e8..0237b84ba541 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -330,6 +330,7 @@ header-y += scc.h
330header-y += sched.h 330header-y += sched.h
331header-y += screen_info.h 331header-y += screen_info.h
332header-y += sdla.h 332header-y += sdla.h
333header-y += seccomp.h
333header-y += securebits.h 334header-y += securebits.h
334header-y += selinux_netlink.h 335header-y += selinux_netlink.h
335header-y += sem.h 336header-y += sem.h
diff --git a/include/linux/audit.h b/include/linux/audit.h
index ed3ef1972496..22f292a917a3 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -463,7 +463,7 @@ extern void audit_putname(const char *name);
463extern void __audit_inode(const char *name, const struct dentry *dentry); 463extern void __audit_inode(const char *name, const struct dentry *dentry);
464extern void __audit_inode_child(const struct dentry *dentry, 464extern void __audit_inode_child(const struct dentry *dentry,
465 const struct inode *parent); 465 const struct inode *parent);
466extern void __audit_seccomp(unsigned long syscall); 466extern void __audit_seccomp(unsigned long syscall, long signr, int code);
467extern void __audit_ptrace(struct task_struct *t); 467extern void __audit_ptrace(struct task_struct *t);
468 468
469static inline int audit_dummy_context(void) 469static inline int audit_dummy_context(void)
@@ -508,10 +508,10 @@ static inline void audit_inode_child(const struct dentry *dentry,
508} 508}
509void audit_core_dumps(long signr); 509void audit_core_dumps(long signr);
510 510
511static inline void audit_seccomp(unsigned long syscall) 511static inline void audit_seccomp(unsigned long syscall, long signr, int code)
512{ 512{
513 if (unlikely(!audit_dummy_context())) 513 if (unlikely(!audit_dummy_context()))
514 __audit_seccomp(syscall); 514 __audit_seccomp(syscall, signr, code);
515} 515}
516 516
517static inline void audit_ptrace(struct task_struct *t) 517static inline void audit_ptrace(struct task_struct *t)
@@ -634,7 +634,7 @@ extern int audit_signals;
634#define audit_inode(n,d) do { (void)(d); } while (0) 634#define audit_inode(n,d) do { (void)(d); } while (0)
635#define audit_inode_child(i,p) do { ; } while (0) 635#define audit_inode_child(i,p) do { ; } while (0)
636#define audit_core_dumps(i) do { ; } while (0) 636#define audit_core_dumps(i) do { ; } while (0)
637#define audit_seccomp(i) do { ; } while (0) 637#define audit_seccomp(i,s,c) do { ; } while (0)
638#define auditsc_get_stamp(c,t,s) (0) 638#define auditsc_get_stamp(c,t,s) (0)
639#define audit_get_loginuid(t) (-1) 639#define audit_get_loginuid(t) (-1)
640#define audit_get_sessionid(t) (-1) 640#define audit_get_sessionid(t) (-1)
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 72090994d789..82b01357af8b 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -10,6 +10,7 @@
10 10
11#ifdef __KERNEL__ 11#ifdef __KERNEL__
12#include <linux/atomic.h> 12#include <linux/atomic.h>
13#include <linux/compat.h>
13#endif 14#endif
14 15
15/* 16/*
@@ -133,6 +134,16 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
133 134
134#ifdef __KERNEL__ 135#ifdef __KERNEL__
135 136
137#ifdef CONFIG_COMPAT
138/*
139 * A struct sock_filter is architecture independent.
140 */
141struct compat_sock_fprog {
142 u16 len;
143 compat_uptr_t filter; /* struct sock_filter * */
144};
145#endif
146
136struct sk_buff; 147struct sk_buff;
137struct sock; 148struct sock;
138 149
@@ -233,6 +244,7 @@ enum {
233 BPF_S_ANC_RXHASH, 244 BPF_S_ANC_RXHASH,
234 BPF_S_ANC_CPU, 245 BPF_S_ANC_CPU,
235 BPF_S_ANC_ALU_XOR_X, 246 BPF_S_ANC_ALU_XOR_X,
247 BPF_S_ANC_SECCOMP_LD_W,
236}; 248};
237 249
238#endif /* __KERNEL__ */ 250#endif /* __KERNEL__ */
diff --git a/include/linux/key.h b/include/linux/key.h
index 96933b1e5d24..5231800770e1 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -124,7 +124,10 @@ static inline unsigned long is_key_possessed(const key_ref_t key_ref)
124struct key { 124struct key {
125 atomic_t usage; /* number of references */ 125 atomic_t usage; /* number of references */
126 key_serial_t serial; /* key serial number */ 126 key_serial_t serial; /* key serial number */
127 struct rb_node serial_node; 127 union {
128 struct list_head graveyard_link;
129 struct rb_node serial_node;
130 };
128 struct key_type *type; /* type of key */ 131 struct key_type *type; /* type of key */
129 struct rw_semaphore sem; /* change vs change sem */ 132 struct rw_semaphore sem; /* change vs change sem */
130 struct key_user *user; /* owner of this key */ 133 struct key_user *user; /* owner of this key */
@@ -133,6 +136,7 @@ struct key {
133 time_t expiry; /* time at which key expires (or 0) */ 136 time_t expiry; /* time at which key expires (or 0) */
134 time_t revoked_at; /* time at which key was revoked */ 137 time_t revoked_at; /* time at which key was revoked */
135 }; 138 };
139 time_t last_used_at; /* last time used for LRU keyring discard */
136 uid_t uid; 140 uid_t uid;
137 gid_t gid; 141 gid_t gid;
138 key_perm_t perm; /* access permissions */ 142 key_perm_t perm; /* access permissions */
@@ -156,6 +160,7 @@ struct key {
156#define KEY_FLAG_USER_CONSTRUCT 4 /* set if key is being constructed in userspace */ 160#define KEY_FLAG_USER_CONSTRUCT 4 /* set if key is being constructed in userspace */
157#define KEY_FLAG_NEGATIVE 5 /* set if key is negative */ 161#define KEY_FLAG_NEGATIVE 5 /* set if key is negative */
158#define KEY_FLAG_ROOT_CAN_CLEAR 6 /* set if key can be cleared by root without permission */ 162#define KEY_FLAG_ROOT_CAN_CLEAR 6 /* set if key can be cleared by root without permission */
163#define KEY_FLAG_INVALIDATED 7 /* set if key has been invalidated */
159 164
160 /* the description string 165 /* the description string
161 * - this is used to match a key against search criteria 166 * - this is used to match a key against search criteria
@@ -199,6 +204,7 @@ extern struct key *key_alloc(struct key_type *type,
199#define KEY_ALLOC_NOT_IN_QUOTA 0x0002 /* not in quota */ 204#define KEY_ALLOC_NOT_IN_QUOTA 0x0002 /* not in quota */
200 205
201extern void key_revoke(struct key *key); 206extern void key_revoke(struct key *key);
207extern void key_invalidate(struct key *key);
202extern void key_put(struct key *key); 208extern void key_put(struct key *key);
203 209
204static inline struct key *key_get(struct key *key) 210static inline struct key *key_get(struct key *key)
@@ -236,7 +242,7 @@ extern struct key *request_key_async_with_auxdata(struct key_type *type,
236 242
237extern int wait_for_key_construction(struct key *key, bool intr); 243extern int wait_for_key_construction(struct key *key, bool intr);
238 244
239extern int key_validate(struct key *key); 245extern int key_validate(const struct key *key);
240 246
241extern key_ref_t key_create_or_update(key_ref_t keyring, 247extern key_ref_t key_create_or_update(key_ref_t keyring,
242 const char *type, 248 const char *type,
@@ -319,6 +325,7 @@ extern void key_init(void);
319#define key_serial(k) 0 325#define key_serial(k) 0
320#define key_get(k) ({ NULL; }) 326#define key_get(k) ({ NULL; })
321#define key_revoke(k) do { } while(0) 327#define key_revoke(k) do { } while(0)
328#define key_invalidate(k) do { } while(0)
322#define key_put(k) do { } while(0) 329#define key_put(k) do { } while(0)
323#define key_ref_put(k) do { } while(0) 330#define key_ref_put(k) do { } while(0)
324#define make_key_ref(k, p) NULL 331#define make_key_ref(k, p) NULL
diff --git a/include/linux/keyctl.h b/include/linux/keyctl.h
index 9b0b865ce622..c9b7f4faf97a 100644
--- a/include/linux/keyctl.h
+++ b/include/linux/keyctl.h
@@ -55,5 +55,6 @@
55#define KEYCTL_SESSION_TO_PARENT 18 /* apply session keyring to parent process */ 55#define KEYCTL_SESSION_TO_PARENT 18 /* apply session keyring to parent process */
56#define KEYCTL_REJECT 19 /* reject a partially constructed key */ 56#define KEYCTL_REJECT 19 /* reject a partially constructed key */
57#define KEYCTL_INSTANTIATE_IOV 20 /* instantiate a partially constructed key */ 57#define KEYCTL_INSTANTIATE_IOV 20 /* instantiate a partially constructed key */
58#define KEYCTL_INVALIDATE 21 /* invalidate a key */
58 59
59#endif /* _LINUX_KEYCTL_H */ 60#endif /* _LINUX_KEYCTL_H */
diff --git a/include/linux/lsm_audit.h b/include/linux/lsm_audit.h
index fad48aab893b..1cc89e9df480 100644
--- a/include/linux/lsm_audit.h
+++ b/include/linux/lsm_audit.h
@@ -53,7 +53,6 @@ struct common_audit_data {
53#define LSM_AUDIT_DATA_KMOD 8 53#define LSM_AUDIT_DATA_KMOD 8
54#define LSM_AUDIT_DATA_INODE 9 54#define LSM_AUDIT_DATA_INODE 9
55#define LSM_AUDIT_DATA_DENTRY 10 55#define LSM_AUDIT_DATA_DENTRY 10
56 struct task_struct *tsk;
57 union { 56 union {
58 struct path path; 57 struct path path;
59 struct dentry *dentry; 58 struct dentry *dentry;
@@ -93,11 +92,6 @@ int ipv4_skb_to_auditdata(struct sk_buff *skb,
93int ipv6_skb_to_auditdata(struct sk_buff *skb, 92int ipv6_skb_to_auditdata(struct sk_buff *skb,
94 struct common_audit_data *ad, u8 *proto); 93 struct common_audit_data *ad, u8 *proto);
95 94
96/* Initialize an LSM audit data structure. */
97#define COMMON_AUDIT_DATA_INIT(_d, _t) \
98 { memset((_d), 0, sizeof(struct common_audit_data)); \
99 (_d)->type = LSM_AUDIT_DATA_##_t; }
100
101void common_lsm_audit(struct common_audit_data *a, 95void common_lsm_audit(struct common_audit_data *a,
102 void (*pre_audit)(struct audit_buffer *, void *), 96 void (*pre_audit)(struct audit_buffer *, void *),
103 void (*post_audit)(struct audit_buffer *, void *)); 97 void (*post_audit)(struct audit_buffer *, void *));
diff --git a/include/linux/prctl.h b/include/linux/prctl.h
index e0cfec2490aa..78b76e24cc7e 100644
--- a/include/linux/prctl.h
+++ b/include/linux/prctl.h
@@ -124,4 +124,19 @@
124#define PR_SET_CHILD_SUBREAPER 36 124#define PR_SET_CHILD_SUBREAPER 36
125#define PR_GET_CHILD_SUBREAPER 37 125#define PR_GET_CHILD_SUBREAPER 37
126 126
127/*
128 * If no_new_privs is set, then operations that grant new privileges (i.e.
129 * execve) will either fail or not grant them. This affects suid/sgid,
130 * file capabilities, and LSMs.
131 *
132 * Operations that merely manipulate or drop existing privileges (setresuid,
133 * capset, etc.) will still work. Drop those privileges if you want them gone.
134 *
135 * Changing LSM security domain is considered a new privilege. So, for example,
136 * asking selinux for a specific new context (e.g. with runcon) will result
137 * in execve returning -EPERM.
138 */
139#define PR_SET_NO_NEW_PRIVS 38
140#define PR_GET_NO_NEW_PRIVS 39
141
127#endif /* _LINUX_PRCTL_H */ 142#endif /* _LINUX_PRCTL_H */
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index 5c719627c2aa..597e4fdb97fe 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -58,6 +58,7 @@
58#define PTRACE_EVENT_EXEC 4 58#define PTRACE_EVENT_EXEC 4
59#define PTRACE_EVENT_VFORK_DONE 5 59#define PTRACE_EVENT_VFORK_DONE 5
60#define PTRACE_EVENT_EXIT 6 60#define PTRACE_EVENT_EXIT 6
61#define PTRACE_EVENT_SECCOMP 7
61/* Extended result codes which enabled by means other than options. */ 62/* Extended result codes which enabled by means other than options. */
62#define PTRACE_EVENT_STOP 128 63#define PTRACE_EVENT_STOP 128
63 64
@@ -69,8 +70,9 @@
69#define PTRACE_O_TRACEEXEC (1 << PTRACE_EVENT_EXEC) 70#define PTRACE_O_TRACEEXEC (1 << PTRACE_EVENT_EXEC)
70#define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE) 71#define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE)
71#define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT) 72#define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT)
73#define PTRACE_O_TRACESECCOMP (1 << PTRACE_EVENT_SECCOMP)
72 74
73#define PTRACE_O_MASK 0x0000007f 75#define PTRACE_O_MASK 0x000000ff
74 76
75#include <asm/ptrace.h> 77#include <asm/ptrace.h>
76 78
@@ -98,6 +100,7 @@
98#define PT_TRACE_EXEC PT_EVENT_FLAG(PTRACE_EVENT_EXEC) 100#define PT_TRACE_EXEC PT_EVENT_FLAG(PTRACE_EVENT_EXEC)
99#define PT_TRACE_VFORK_DONE PT_EVENT_FLAG(PTRACE_EVENT_VFORK_DONE) 101#define PT_TRACE_VFORK_DONE PT_EVENT_FLAG(PTRACE_EVENT_VFORK_DONE)
100#define PT_TRACE_EXIT PT_EVENT_FLAG(PTRACE_EVENT_EXIT) 102#define PT_TRACE_EXIT PT_EVENT_FLAG(PTRACE_EVENT_EXIT)
103#define PT_TRACE_SECCOMP PT_EVENT_FLAG(PTRACE_EVENT_SECCOMP)
101 104
102/* single stepping state bits (used on ARM and PA-RISC) */ 105/* single stepping state bits (used on ARM and PA-RISC) */
103#define PT_SINGLESTEP_BIT 31 106#define PT_SINGLESTEP_BIT 31
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8f3fd945070f..f774d88cd0aa 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1341,6 +1341,8 @@ struct task_struct {
1341 * execve */ 1341 * execve */
1342 unsigned in_iowait:1; 1342 unsigned in_iowait:1;
1343 1343
1344 /* task may not gain privileges */
1345 unsigned no_new_privs:1;
1344 1346
1345 /* Revert to default priority/policy when forking */ 1347 /* Revert to default priority/policy when forking */
1346 unsigned sched_reset_on_fork:1; 1348 unsigned sched_reset_on_fork:1;
@@ -1450,7 +1452,7 @@ struct task_struct {
1450 uid_t loginuid; 1452 uid_t loginuid;
1451 unsigned int sessionid; 1453 unsigned int sessionid;
1452#endif 1454#endif
1453 seccomp_t seccomp; 1455 struct seccomp seccomp;
1454 1456
1455/* Thread group tracking */ 1457/* Thread group tracking */
1456 u32 parent_exec_id; 1458 u32 parent_exec_id;
diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h
index cc7a4e9cc7ad..84f6320da50f 100644
--- a/include/linux/seccomp.h
+++ b/include/linux/seccomp.h
@@ -1,25 +1,90 @@
1#ifndef _LINUX_SECCOMP_H 1#ifndef _LINUX_SECCOMP_H
2#define _LINUX_SECCOMP_H 2#define _LINUX_SECCOMP_H
3 3
4 4#include <linux/compiler.h>
5#include <linux/types.h>
6
7
8/* Valid values for seccomp.mode and prctl(PR_SET_SECCOMP, <mode>) */
9#define SECCOMP_MODE_DISABLED 0 /* seccomp is not in use. */
10#define SECCOMP_MODE_STRICT 1 /* uses hard-coded filter. */
11#define SECCOMP_MODE_FILTER 2 /* uses user-supplied filter. */
12
13/*
14 * All BPF programs must return a 32-bit value.
15 * The bottom 16-bits are for optional return data.
16 * The upper 16-bits are ordered from least permissive values to most.
17 *
18 * The ordering ensures that a min_t() over composed return values always
19 * selects the least permissive choice.
20 */
21#define SECCOMP_RET_KILL 0x00000000U /* kill the task immediately */
22#define SECCOMP_RET_TRAP 0x00030000U /* disallow and force a SIGSYS */
23#define SECCOMP_RET_ERRNO 0x00050000U /* returns an errno */
24#define SECCOMP_RET_TRACE 0x7ff00000U /* pass to a tracer or disallow */
25#define SECCOMP_RET_ALLOW 0x7fff0000U /* allow */
26
27/* Masks for the return value sections. */
28#define SECCOMP_RET_ACTION 0x7fff0000U
29#define SECCOMP_RET_DATA 0x0000ffffU
30
31/**
32 * struct seccomp_data - the format the BPF program executes over.
33 * @nr: the system call number
34 * @arch: indicates system call convention as an AUDIT_ARCH_* value
35 * as defined in <linux/audit.h>.
36 * @instruction_pointer: at the time of the system call.
37 * @args: up to 6 system call arguments always stored as 64-bit values
38 * regardless of the architecture.
39 */
40struct seccomp_data {
41 int nr;
42 __u32 arch;
43 __u64 instruction_pointer;
44 __u64 args[6];
45};
46
47#ifdef __KERNEL__
5#ifdef CONFIG_SECCOMP 48#ifdef CONFIG_SECCOMP
6 49
7#include <linux/thread_info.h> 50#include <linux/thread_info.h>
8#include <asm/seccomp.h> 51#include <asm/seccomp.h>
9 52
10typedef struct { int mode; } seccomp_t; 53struct seccomp_filter;
11 54/**
12extern void __secure_computing(int); 55 * struct seccomp - the state of a seccomp'ed process
13static inline void secure_computing(int this_syscall) 56 *
57 * @mode: indicates one of the valid values above for controlled
58 * system calls available to a process.
59 * @filter: The metadata and ruleset for determining what system calls
60 * are allowed for a task.
61 *
62 * @filter must only be accessed from the context of current as there
63 * is no locking.
64 */
65struct seccomp {
66 int mode;
67 struct seccomp_filter *filter;
68};
69
70extern int __secure_computing(int);
71static inline int secure_computing(int this_syscall)
14{ 72{
15 if (unlikely(test_thread_flag(TIF_SECCOMP))) 73 if (unlikely(test_thread_flag(TIF_SECCOMP)))
16 __secure_computing(this_syscall); 74 return __secure_computing(this_syscall);
75 return 0;
76}
77
78/* A wrapper for architectures supporting only SECCOMP_MODE_STRICT. */
79static inline void secure_computing_strict(int this_syscall)
80{
81 BUG_ON(secure_computing(this_syscall) != 0);
17} 82}
18 83
19extern long prctl_get_seccomp(void); 84extern long prctl_get_seccomp(void);
20extern long prctl_set_seccomp(unsigned long); 85extern long prctl_set_seccomp(unsigned long, char __user *);
21 86
22static inline int seccomp_mode(seccomp_t *s) 87static inline int seccomp_mode(struct seccomp *s)
23{ 88{
24 return s->mode; 89 return s->mode;
25} 90}
@@ -28,25 +93,41 @@ static inline int seccomp_mode(seccomp_t *s)
28 93
29#include <linux/errno.h> 94#include <linux/errno.h>
30 95
31typedef struct { } seccomp_t; 96struct seccomp { };
97struct seccomp_filter { };
32 98
33#define secure_computing(x) do { } while (0) 99static inline int secure_computing(int this_syscall) { return 0; }
100static inline void secure_computing_strict(int this_syscall) { return; }
34 101
35static inline long prctl_get_seccomp(void) 102static inline long prctl_get_seccomp(void)
36{ 103{
37 return -EINVAL; 104 return -EINVAL;
38} 105}
39 106
40static inline long prctl_set_seccomp(unsigned long arg2) 107static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3)
41{ 108{
42 return -EINVAL; 109 return -EINVAL;
43} 110}
44 111
45static inline int seccomp_mode(seccomp_t *s) 112static inline int seccomp_mode(struct seccomp *s)
46{ 113{
47 return 0; 114 return 0;
48} 115}
49
50#endif /* CONFIG_SECCOMP */ 116#endif /* CONFIG_SECCOMP */
51 117
118#ifdef CONFIG_SECCOMP_FILTER
119extern void put_seccomp_filter(struct task_struct *tsk);
120extern void get_seccomp_filter(struct task_struct *tsk);
121extern u32 seccomp_bpf_load(int off);
122#else /* CONFIG_SECCOMP_FILTER */
123static inline void put_seccomp_filter(struct task_struct *tsk)
124{
125 return;
126}
127static inline void get_seccomp_filter(struct task_struct *tsk)
128{
129 return;
130}
131#endif /* CONFIG_SECCOMP_FILTER */
132#endif /* __KERNEL__ */
52#endif /* _LINUX_SECCOMP_H */ 133#endif /* _LINUX_SECCOMP_H */
diff --git a/include/linux/security.h b/include/linux/security.h
index 673afbb8238a..ab0e091ce5fa 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -144,6 +144,7 @@ struct request_sock;
144#define LSM_UNSAFE_SHARE 1 144#define LSM_UNSAFE_SHARE 1
145#define LSM_UNSAFE_PTRACE 2 145#define LSM_UNSAFE_PTRACE 2
146#define LSM_UNSAFE_PTRACE_CAP 4 146#define LSM_UNSAFE_PTRACE_CAP 4
147#define LSM_UNSAFE_NO_NEW_PRIVS 8
147 148
148#ifdef CONFIG_MMU 149#ifdef CONFIG_MMU
149extern int mmap_min_addr_handler(struct ctl_table *table, int write, 150extern int mmap_min_addr_handler(struct ctl_table *table, int write,
@@ -639,10 +640,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
639 * to receive an open file descriptor via socket IPC. 640 * to receive an open file descriptor via socket IPC.
640 * @file contains the file structure being received. 641 * @file contains the file structure being received.
641 * Return 0 if permission is granted. 642 * Return 0 if permission is granted.
642 * 643 * @file_open
643 * Security hook for dentry
644 *
645 * @dentry_open
646 * Save open-time permission checking state for later use upon 644 * Save open-time permission checking state for later use upon
647 * file_permission, and recheck access if anything has changed 645 * file_permission, and recheck access if anything has changed
648 * since inode_permission. 646 * since inode_permission.
@@ -1497,7 +1495,7 @@ struct security_operations {
1497 int (*file_send_sigiotask) (struct task_struct *tsk, 1495 int (*file_send_sigiotask) (struct task_struct *tsk,
1498 struct fown_struct *fown, int sig); 1496 struct fown_struct *fown, int sig);
1499 int (*file_receive) (struct file *file); 1497 int (*file_receive) (struct file *file);
1500 int (*dentry_open) (struct file *file, const struct cred *cred); 1498 int (*file_open) (struct file *file, const struct cred *cred);
1501 1499
1502 int (*task_create) (unsigned long clone_flags); 1500 int (*task_create) (unsigned long clone_flags);
1503 void (*task_free) (struct task_struct *task); 1501 void (*task_free) (struct task_struct *task);
@@ -1756,7 +1754,7 @@ int security_file_set_fowner(struct file *file);
1756int security_file_send_sigiotask(struct task_struct *tsk, 1754int security_file_send_sigiotask(struct task_struct *tsk,
1757 struct fown_struct *fown, int sig); 1755 struct fown_struct *fown, int sig);
1758int security_file_receive(struct file *file); 1756int security_file_receive(struct file *file);
1759int security_dentry_open(struct file *file, const struct cred *cred); 1757int security_file_open(struct file *file, const struct cred *cred);
1760int security_task_create(unsigned long clone_flags); 1758int security_task_create(unsigned long clone_flags);
1761void security_task_free(struct task_struct *task); 1759void security_task_free(struct task_struct *task);
1762int security_cred_alloc_blank(struct cred *cred, gfp_t gfp); 1760int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
@@ -2227,8 +2225,8 @@ static inline int security_file_receive(struct file *file)
2227 return 0; 2225 return 0;
2228} 2226}
2229 2227
2230static inline int security_dentry_open(struct file *file, 2228static inline int security_file_open(struct file *file,
2231 const struct cred *cred) 2229 const struct cred *cred)
2232{ 2230{
2233 return 0; 2231 return 0;
2234} 2232}