History

Merge branch 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security

Pull security subsystem updates from James Morris: - Extend LSM stacking to allow sharing of cred, file, ipc, inode, and task blobs. This paves the way for more full-featured LSMs to be merged, and is specifically aimed at LandLock and SARA LSMs. This work is from Casey and Kees. - There's a new LSM from Micah Morton: "SafeSetID gates the setid family of syscalls to restrict UID/GID transitions from a given UID/GID to only those approved by a system-wide whitelist." This feature is currently shipping in ChromeOS. * 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (62 commits) keys: fix missing __user in KEYCTL_PKEY_QUERY LSM: Update list of SECURITYFS users in Kconfig LSM: Ignore "security=" when "lsm=" is specified LSM: Update function documentation for cap_capable security: mark expected switch fall-throughs and add a missing break tomoyo: Bump version. LSM: fix return value check in safesetid_init_securityfs() LSM: SafeSetID: add selftest LSM: SafeSetID: remove unused include LSM: SafeSetID: 'depend' on CONFIG_SECURITY LSM: Add 'name' field for SafeSetID in DEFINE_LSM LSM: add SafeSetID module that gates setid calls LSM: add SafeSetID module that gates setid calls tomoyo: Allow multiple use_group lines. tomoyo: Coding style fix. tomoyo: Swicth from cred->security to task_struct->security. security: keys: annotate implicit fall throughs security: keys: annotate implicit fall throughs security: keys: annotate implicit fall through capabilities:: annotate implicit fall through ...

Linus Torvalds committed 7 years ago

Commit ae5906c2 parents 1fc1cd8 468e91c78 files · +2674 −1090Browse files

Showing the changes to include/linux (5 of 78 files). Show all

Unified · Split

5 files
  1. include/linux/capability.h +5 −0
  2. include/linux/cred.h +0 −1
  3. include/linux/lsm_hooks.h +30 −15
  4. include/linux/security.h +24 −19
  5. include/linux/selinux.h +0 −35
include/linux/capability.h+5−0
@@ -209,6 +209,7 @@ extern bool has_ns_capability_noaudit(struct task_struct *t, · 208 unmodified lines
209209 extern bool capable(int cap);
210210 extern bool ns_capable(struct user_namespace *ns, int cap);
211211 extern bool ns_capable_noaudit(struct user_namespace *ns, int cap);
212+extern bool ns_capable_setid(struct user_namespace *ns, int cap);
212213 #else
213214 static inline bool has_capability(struct task_struct *t, int cap)
214215 {
@@ -240,6 +241,10 @@ static inline bool ns_capable_noaudit(struct user_namespace *ns, int cap) · 25 unmodified lines
240241 {
241242 return true;
242243 }
244+static inline bool ns_capable_setid(struct user_namespace *ns, int cap)
245+{
246+ return true;
247+}
243248 #endif /* CONFIG_MULTIUSER */
244249 extern bool privileged_wrt_inode_uidgid(struct user_namespace *ns, const struct inode *inode);
245250 extern bool capable_wrt_inode_uidgid(const struct inode *inode, int cap);
include/linux/cred.h+0−1
@@ -15,7 +15,6 @@ · 14 unmodified lines
1515 #include <linux/capability.h>
1616 #include <linux/init.h>
1717 #include <linux/key.h>
18−#include <linux/selinux.h>
1918 #include <linux/atomic.h>
2019 #include <linux/uidgid.h>
2120 #include <linux/sched.h>
include/linux/lsm_hooks.h+30−15
@@ -1270,7 +1270,7 @@ · 1269 unmodified lines
12701270 * @cred contains the credentials to use.
12711271 * @ns contains the user namespace we want the capability in
12721272 * @cap contains the capability <include/linux/capability.h>.
1273− * @audit contains whether to write an audit message or not
1273+ * @opts contains options for the capable check <include/linux/security.h>
12741274 * Return 0 if the capability is granted for @tsk.
12751275 * @syslog:
12761276 * Check permission before accessing the kernel message ring or changing
@@ -1446,8 +1446,10 @@ union security_list_options { · 169 unmodified lines
14461446 const kernel_cap_t *effective,
14471447 const kernel_cap_t *inheritable,
14481448 const kernel_cap_t *permitted);
1449− int (*capable)(const struct cred *cred, struct user_namespace *ns,
1450− int cap, int audit);
1449+ int (*capable)(const struct cred *cred,
1450+ struct user_namespace *ns,
1451+ int cap,
1452+ unsigned int opts);
14511453 int (*quotactl)(int cmds, int type, int id, struct super_block *sb);
14521454 int (*quota_on)(struct dentry *dentry);
14531455 int (*syslog)(int type);
@@ -2027,6 +2029,18 @@ struct security_hook_list { · 573 unmodified lines
20272029 char *lsm;
20282030 } __randomize_layout;
20292031
2032+/*
2033+ * Security blob size or offset data.
2034+ */
2035+struct lsm_blob_sizes {
2036+ int lbs_cred;
2037+ int lbs_file;
2038+ int lbs_inode;
2039+ int lbs_ipc;
2040+ int lbs_msg_msg;
2041+ int lbs_task;
2042+};
2043+
20302044 /*
20312045 * Initializing a security_hook_list structure takes
20322046 * up a lot of space in a source file. This macro takes
@@ -2042,9 +2056,21 @@ extern char *lsm_names; · 9 unmodified lines
20422056 extern void security_add_hooks(struct security_hook_list *hooks, int count,
20432057 char *lsm);
20442058
2059+#define LSM_FLAG_LEGACY_MAJOR BIT(0)
2060+#define LSM_FLAG_EXCLUSIVE BIT(1)
2061+
2062+enum lsm_order {
2063+ LSM_ORDER_FIRST = -1, /* This is only for capabilities. */
2064+ LSM_ORDER_MUTABLE = 0,
2065+};
2066+
20452067 struct lsm_info {
20462068 const char *name; /* Required. */
2069+ enum lsm_order order; /* Optional: default is LSM_ORDER_MUTABLE */
2070+ unsigned long flags; /* Optional: flags describing LSM */
2071+ int *enabled; /* Optional: controlled by CONFIG_LSM */
20472072 int (*init)(void); /* Required. */
2073+ struct lsm_blob_sizes *blobs; /* Optional: for blob sharing. */
20482074 };
20492075
20502076 extern struct lsm_info __start_lsm_info[], __end_lsm_info[];
@@ -2084,17 +2110,6 @@ static inline void security_delete_hooks(struct security_hook_list *hooks, · 33 unmodified lines
20842110 #define __lsm_ro_after_init __ro_after_init
20852111 #endif /* CONFIG_SECURITY_WRITABLE_HOOKS */
20862112
2087−extern int __init security_module_enable(const char *module);
2088−extern void __init capability_add_hooks(void);
2089−#ifdef CONFIG_SECURITY_YAMA
2090−extern void __init yama_add_hooks(void);
2091−#else
2092−static inline void __init yama_add_hooks(void) { }
2093−#endif
2094−#ifdef CONFIG_SECURITY_LOADPIN
2095−void __init loadpin_add_hooks(void);
2096−#else
2097−static inline void loadpin_add_hooks(void) { };
2098−#endif
2113+extern int lsm_inode_alloc(struct inode *inode);
20992114
21002115 #endif /* ! __LINUX_LSM_HOOKS_H */
include/linux/security.h+24−19
@@ -54,9 +54,12 @@ struct xattr; · 53 unmodified lines
5454 struct xfrm_sec_ctx;
5555 struct mm_struct;
5656
57+/* Default (no) options for the capable function */
58+#define CAP_OPT_NONE 0x0
5759 /* If capable should audit the security request */
58−#define SECURITY_CAP_NOAUDIT 0
59−#define SECURITY_CAP_AUDIT 1
60+#define CAP_OPT_NOAUDIT BIT(1)
61+/* If capable is being called by a setid function */
62+#define CAP_OPT_INSETID BIT(2)
6063
6164 /* LSM Agnostic defines for sb_set_mnt_opts */
6265 #define SECURITY_LSM_NATIVE_LABELS 1
@@ -72,7 +75,7 @@ enum lsm_event { · 9 unmodified lines
7275
7376 /* These functions are in security/commoncap.c */
7477 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
75− int cap, int audit);
78+ int cap, unsigned int opts);
7679 extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
7780 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
7881 extern int cap_ptrace_traceme(struct task_struct *parent);
@@ -207,10 +210,10 @@ int security_capset(struct cred *new, const struct cred *old, · 128 unmodified lines
207210 const kernel_cap_t *effective,
208211 const kernel_cap_t *inheritable,
209212 const kernel_cap_t *permitted);
210−int security_capable(const struct cred *cred, struct user_namespace *ns,
211− int cap);
212−int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
213− int cap);
213+int security_capable(const struct cred *cred,
214+ struct user_namespace *ns,
215+ int cap,
216+ unsigned int opts);
214217 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
215218 int security_quota_on(struct dentry *dentry);
216219 int security_syslog(int type);
@@ -366,8 +369,10 @@ int security_sem_semctl(struct kern_ipc_perm *sma, int cmd); · 149 unmodified lines
366369 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
367370 unsigned nsops, int alter);
368371 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
369−int security_getprocattr(struct task_struct *p, char *name, char **value);
370−int security_setprocattr(const char *name, void *value, size_t size);
372+int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
373+ char **value);
374+int security_setprocattr(const char *lsm, const char *name, void *value,
375+ size_t size);
371376 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
372377 int security_ismaclabel(const char *name);
373378 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
@@ -462,14 +467,11 @@ static inline int security_capset(struct cred *new, · 88 unmodified lines
462467 }
463468
464469 static inline int security_capable(const struct cred *cred,
465− struct user_namespace *ns, int cap)
470+ struct user_namespace *ns,
471+ int cap,
472+ unsigned int opts)
466473 {
467− return cap_capable(cred, ns, cap, SECURITY_CAP_AUDIT);
468−}
469−
470−static inline int security_capable_noaudit(const struct cred *cred,
471− struct user_namespace *ns, int cap) {
472− return cap_capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
474+ return cap_capable(cred, ns, cap, opts);
473475 }
474476
475477 static inline int security_quotactl(int cmds, int type, int id,
@@ -1112,15 +1114,18 @@ static inline int security_sem_semop(struct kern_ipc_perm *sma, · 636 unmodified lines
11121114 return 0;
11131115 }
11141116
1115−static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
1117+static inline void security_d_instantiate(struct dentry *dentry,
1118+ struct inode *inode)
11161119 { }
11171120
1118−static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
1121+static inline int security_getprocattr(struct task_struct *p, const char *lsm,
1122+ char *name, char **value)
11191123 {
11201124 return -EINVAL;
11211125 }
11221126
1123−static inline int security_setprocattr(char *name, void *value, size_t size)
1127+static inline int security_setprocattr(const char *lsm, char *name,
1128+ void *value, size_t size)
11241129 {
11251130 return -EINVAL;
11261131 }
include/linux/selinux.h+0−35
@@ -1,35 +0,0 @@
1−/*
2− * SELinux services exported to the rest of the kernel.
3− *
4− * Author: James Morris <jmorris@redhat.com>
5− *
6− * Copyright (C) 2005 Red Hat, Inc., James Morris <jmorris@redhat.com>
7− * Copyright (C) 2006 Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
8− * Copyright (C) 2006 IBM Corporation, Timothy R. Chavez <tinytim@us.ibm.com>
9− *
10− * This program is free software; you can redistribute it and/or modify
11− * it under the terms of the GNU General Public License version 2,
12− * as published by the Free Software Foundation.
13− */
14−#ifndef _LINUX_SELINUX_H
15−#define _LINUX_SELINUX_H
16−
17−struct selinux_audit_rule;
18−struct audit_context;
19−struct kern_ipc_perm;
20−
21−#ifdef CONFIG_SECURITY_SELINUX
22−
23−/**
24− * selinux_is_enabled - is SELinux enabled?
25− */
26−bool selinux_is_enabled(void);
27−#else
28−
29−static inline bool selinux_is_enabled(void)
30−{
31− return false;
32−}
33−#endif /* CONFIG_SECURITY_SELINUX */
34−
35−#endif /* _LINUX_SELINUX_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t