diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-21 23:27:36 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-21 23:27:36 -0400 |
| commit | cb60e3e65c1b96a4d6444a7a13dc7dd48bc15a2b (patch) | |
| tree | 4322be35db678f6299348a76ad60a2023954af7d /include/linux | |
| parent | 99262a3dafa3290866512ddfb32609198f8973e9 (diff) | |
| parent | ff2bb047c4bce9742e94911eeb44b4d6ff4734ab (diff) | |
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security subsystem updates from James Morris:
"New notable features:
- The seccomp work from Will Drewry
- PR_{GET,SET}_NO_NEW_PRIVS from Andy Lutomirski
- Longer security labels for Smack from Casey Schaufler
- Additional ptrace restriction modes for Yama by Kees Cook"
Fix up trivial context conflicts in arch/x86/Kconfig and include/linux/filter.h
* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (65 commits)
apparmor: fix long path failure due to disconnected path
apparmor: fix profile lookup for unconfined
ima: fix filename hint to reflect script interpreter name
KEYS: Don't check for NULL key pointer in key_validate()
Smack: allow for significantly longer Smack labels v4
gfp flags for security_inode_alloc()?
Smack: recursive tramsmute
Yama: replace capable() with ns_capable()
TOMOYO: Accept manager programs which do not start with / .
KEYS: Add invalidation support
KEYS: Do LRU discard in full keyrings
KEYS: Permit in-place link replacement in keyring list
KEYS: Perform RCU synchronisation on keys prior to key destruction
KEYS: Announce key type (un)registration
KEYS: Reorganise keys Makefile
KEYS: Move the key config into security/keys/Kconfig
KEYS: Use the compat keyctl() syscall wrapper on Sparc64 for Sparc32 compat
Yama: remove an unused variable
samples/seccomp: fix dependencies on arch macros
Yama: add additional ptrace scopes
...
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/Kbuild | 1 | ||||
| -rw-r--r-- | include/linux/audit.h | 8 | ||||
| -rw-r--r-- | include/linux/filter.h | 12 | ||||
| -rw-r--r-- | include/linux/key.h | 11 | ||||
| -rw-r--r-- | include/linux/keyctl.h | 1 | ||||
| -rw-r--r-- | include/linux/lsm_audit.h | 6 | ||||
| -rw-r--r-- | include/linux/prctl.h | 15 | ||||
| -rw-r--r-- | include/linux/ptrace.h | 5 | ||||
| -rw-r--r-- | include/linux/sched.h | 4 | ||||
| -rw-r--r-- | include/linux/seccomp.h | 107 | ||||
| -rw-r--r-- | include/linux/security.h | 14 |
11 files changed, 149 insertions, 35 deletions
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 | |||
| 330 | header-y += sched.h | 330 | header-y += sched.h |
| 331 | header-y += screen_info.h | 331 | header-y += screen_info.h |
| 332 | header-y += sdla.h | 332 | header-y += sdla.h |
| 333 | header-y += seccomp.h | ||
| 333 | header-y += securebits.h | 334 | header-y += securebits.h |
| 334 | header-y += selinux_netlink.h | 335 | header-y += selinux_netlink.h |
| 335 | header-y += sem.h | 336 | header-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); | |||
| 463 | extern void __audit_inode(const char *name, const struct dentry *dentry); | 463 | extern void __audit_inode(const char *name, const struct dentry *dentry); |
| 464 | extern void __audit_inode_child(const struct dentry *dentry, | 464 | extern void __audit_inode_child(const struct dentry *dentry, |
| 465 | const struct inode *parent); | 465 | const struct inode *parent); |
| 466 | extern void __audit_seccomp(unsigned long syscall); | 466 | extern void __audit_seccomp(unsigned long syscall, long signr, int code); |
| 467 | extern void __audit_ptrace(struct task_struct *t); | 467 | extern void __audit_ptrace(struct task_struct *t); |
| 468 | 468 | ||
| 469 | static inline int audit_dummy_context(void) | 469 | static inline int audit_dummy_context(void) |
| @@ -508,10 +508,10 @@ static inline void audit_inode_child(const struct dentry *dentry, | |||
| 508 | } | 508 | } |
| 509 | void audit_core_dumps(long signr); | 509 | void audit_core_dumps(long signr); |
| 510 | 510 | ||
| 511 | static inline void audit_seccomp(unsigned long syscall) | 511 | static 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 | ||
| 517 | static inline void audit_ptrace(struct task_struct *t) | 517 | static 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 | */ | ||
| 141 | struct compat_sock_fprog { | ||
| 142 | u16 len; | ||
| 143 | compat_uptr_t filter; /* struct sock_filter * */ | ||
| 144 | }; | ||
| 145 | #endif | ||
| 146 | |||
| 136 | struct sk_buff; | 147 | struct sk_buff; |
| 137 | struct sock; | 148 | struct 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) | |||
| 124 | struct key { | 124 | struct 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 | ||
| 201 | extern void key_revoke(struct key *key); | 206 | extern void key_revoke(struct key *key); |
| 207 | extern void key_invalidate(struct key *key); | ||
| 202 | extern void key_put(struct key *key); | 208 | extern void key_put(struct key *key); |
| 203 | 209 | ||
| 204 | static inline struct key *key_get(struct key *key) | 210 | static 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 | ||
| 237 | extern int wait_for_key_construction(struct key *key, bool intr); | 243 | extern int wait_for_key_construction(struct key *key, bool intr); |
| 238 | 244 | ||
| 239 | extern int key_validate(struct key *key); | 245 | extern int key_validate(const struct key *key); |
| 240 | 246 | ||
| 241 | extern key_ref_t key_create_or_update(key_ref_t keyring, | 247 | extern 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, | |||
| 93 | int ipv6_skb_to_auditdata(struct sk_buff *skb, | 92 | int 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 | |||
| 101 | void common_lsm_audit(struct common_audit_data *a, | 95 | void 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 | */ | ||
| 40 | struct 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 | ||
| 10 | typedef struct { int mode; } seccomp_t; | 53 | struct seccomp_filter; |
| 11 | 54 | /** | |
| 12 | extern void __secure_computing(int); | 55 | * struct seccomp - the state of a seccomp'ed process |
| 13 | static 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 | */ | ||
| 65 | struct seccomp { | ||
| 66 | int mode; | ||
| 67 | struct seccomp_filter *filter; | ||
| 68 | }; | ||
| 69 | |||
| 70 | extern int __secure_computing(int); | ||
| 71 | static 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. */ | ||
| 79 | static inline void secure_computing_strict(int this_syscall) | ||
| 80 | { | ||
| 81 | BUG_ON(secure_computing(this_syscall) != 0); | ||
| 17 | } | 82 | } |
| 18 | 83 | ||
| 19 | extern long prctl_get_seccomp(void); | 84 | extern long prctl_get_seccomp(void); |
| 20 | extern long prctl_set_seccomp(unsigned long); | 85 | extern long prctl_set_seccomp(unsigned long, char __user *); |
| 21 | 86 | ||
| 22 | static inline int seccomp_mode(seccomp_t *s) | 87 | static 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 | ||
| 31 | typedef struct { } seccomp_t; | 96 | struct seccomp { }; |
| 97 | struct seccomp_filter { }; | ||
| 32 | 98 | ||
| 33 | #define secure_computing(x) do { } while (0) | 99 | static inline int secure_computing(int this_syscall) { return 0; } |
| 100 | static inline void secure_computing_strict(int this_syscall) { return; } | ||
| 34 | 101 | ||
| 35 | static inline long prctl_get_seccomp(void) | 102 | static inline long prctl_get_seccomp(void) |
| 36 | { | 103 | { |
| 37 | return -EINVAL; | 104 | return -EINVAL; |
| 38 | } | 105 | } |
| 39 | 106 | ||
| 40 | static inline long prctl_set_seccomp(unsigned long arg2) | 107 | static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3) |
| 41 | { | 108 | { |
| 42 | return -EINVAL; | 109 | return -EINVAL; |
| 43 | } | 110 | } |
| 44 | 111 | ||
| 45 | static inline int seccomp_mode(seccomp_t *s) | 112 | static 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 | ||
| 119 | extern void put_seccomp_filter(struct task_struct *tsk); | ||
| 120 | extern void get_seccomp_filter(struct task_struct *tsk); | ||
| 121 | extern u32 seccomp_bpf_load(int off); | ||
| 122 | #else /* CONFIG_SECCOMP_FILTER */ | ||
| 123 | static inline void put_seccomp_filter(struct task_struct *tsk) | ||
| 124 | { | ||
| 125 | return; | ||
| 126 | } | ||
| 127 | static 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 |
| 149 | extern int mmap_min_addr_handler(struct ctl_table *table, int write, | 150 | extern 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); | |||
| 1756 | int security_file_send_sigiotask(struct task_struct *tsk, | 1754 | int security_file_send_sigiotask(struct task_struct *tsk, |
| 1757 | struct fown_struct *fown, int sig); | 1755 | struct fown_struct *fown, int sig); |
| 1758 | int security_file_receive(struct file *file); | 1756 | int security_file_receive(struct file *file); |
| 1759 | int security_dentry_open(struct file *file, const struct cred *cred); | 1757 | int security_file_open(struct file *file, const struct cred *cred); |
| 1760 | int security_task_create(unsigned long clone_flags); | 1758 | int security_task_create(unsigned long clone_flags); |
| 1761 | void security_task_free(struct task_struct *task); | 1759 | void security_task_free(struct task_struct *task); |
| 1762 | int security_cred_alloc_blank(struct cred *cred, gfp_t gfp); | 1760 | int 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 | ||
| 2230 | static inline int security_dentry_open(struct file *file, | 2228 | static 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 | } |
