diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-07 14:44:01 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-07 14:44:01 -0500 |
| commit | ae5906ceee038ea29ff5162d1bcd18fb50af8b94 (patch) | |
| tree | 841a11c6d3c3afcf7e4d57be370ebcf57aab214a /security/apparmor/include | |
| parent | 1fc1cd8399ab5541a488a7e47b2f21537dd76c2d (diff) | |
| parent | 468e91cecb3218afd684b8c422490dfebe0691bb (diff) | |
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
...
Diffstat (limited to 'security/apparmor/include')
| -rw-r--r-- | security/apparmor/include/capability.h | 2 | ||||
| -rw-r--r-- | security/apparmor/include/cred.h | 16 | ||||
| -rw-r--r-- | security/apparmor/include/file.h | 5 | ||||
| -rw-r--r-- | security/apparmor/include/lib.h | 4 | ||||
| -rw-r--r-- | security/apparmor/include/task.h | 18 |
5 files changed, 28 insertions, 17 deletions
diff --git a/security/apparmor/include/capability.h b/security/apparmor/include/capability.h index e0304e2aeb7f..1b3663b6ab12 100644 --- a/security/apparmor/include/capability.h +++ b/security/apparmor/include/capability.h | |||
| @@ -40,7 +40,7 @@ struct aa_caps { | |||
| 40 | 40 | ||
| 41 | extern struct aa_sfs_entry aa_sfs_entry_caps[]; | 41 | extern struct aa_sfs_entry aa_sfs_entry_caps[]; |
| 42 | 42 | ||
| 43 | int aa_capable(struct aa_label *label, int cap, int audit); | 43 | int aa_capable(struct aa_label *label, int cap, unsigned int opts); |
| 44 | 44 | ||
| 45 | static inline void aa_free_cap_rules(struct aa_caps *caps) | 45 | static inline void aa_free_cap_rules(struct aa_caps *caps) |
| 46 | { | 46 | { |
diff --git a/security/apparmor/include/cred.h b/security/apparmor/include/cred.h index 265ae6641a06..b9504a05fddc 100644 --- a/security/apparmor/include/cred.h +++ b/security/apparmor/include/cred.h | |||
| @@ -23,8 +23,22 @@ | |||
| 23 | #include "policy_ns.h" | 23 | #include "policy_ns.h" |
| 24 | #include "task.h" | 24 | #include "task.h" |
| 25 | 25 | ||
| 26 | #define cred_label(X) ((X)->security) | 26 | static inline struct aa_label *cred_label(const struct cred *cred) |
| 27 | { | ||
| 28 | struct aa_label **blob = cred->security + apparmor_blob_sizes.lbs_cred; | ||
| 29 | |||
| 30 | AA_BUG(!blob); | ||
| 31 | return *blob; | ||
| 32 | } | ||
| 27 | 33 | ||
| 34 | static inline void set_cred_label(const struct cred *cred, | ||
| 35 | struct aa_label *label) | ||
| 36 | { | ||
| 37 | struct aa_label **blob = cred->security + apparmor_blob_sizes.lbs_cred; | ||
| 38 | |||
| 39 | AA_BUG(!blob); | ||
| 40 | *blob = label; | ||
| 41 | } | ||
| 28 | 42 | ||
| 29 | /** | 43 | /** |
| 30 | * aa_cred_raw_label - obtain cred's label | 44 | * aa_cred_raw_label - obtain cred's label |
diff --git a/security/apparmor/include/file.h b/security/apparmor/include/file.h index 4c2c8ac8842f..8be09208cf7c 100644 --- a/security/apparmor/include/file.h +++ b/security/apparmor/include/file.h | |||
| @@ -32,7 +32,10 @@ struct path; | |||
| 32 | AA_MAY_CHMOD | AA_MAY_CHOWN | AA_MAY_LOCK | \ | 32 | AA_MAY_CHMOD | AA_MAY_CHOWN | AA_MAY_LOCK | \ |
| 33 | AA_EXEC_MMAP | AA_MAY_LINK) | 33 | AA_EXEC_MMAP | AA_MAY_LINK) |
| 34 | 34 | ||
| 35 | #define file_ctx(X) ((struct aa_file_ctx *)(X)->f_security) | 35 | static inline struct aa_file_ctx *file_ctx(struct file *file) |
| 36 | { | ||
| 37 | return file->f_security + apparmor_blob_sizes.lbs_file; | ||
| 38 | } | ||
| 36 | 39 | ||
| 37 | /* struct aa_file_ctx - the AppArmor context the file was opened in | 40 | /* struct aa_file_ctx - the AppArmor context the file was opened in |
| 38 | * @lock: lock to update the ctx | 41 | * @lock: lock to update the ctx |
diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h index 6505e1ad9e23..bbe9b384d71d 100644 --- a/security/apparmor/include/lib.h +++ b/security/apparmor/include/lib.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
| 18 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
| 19 | #include <linux/lsm_hooks.h> | ||
| 19 | 20 | ||
| 20 | #include "match.h" | 21 | #include "match.h" |
| 21 | 22 | ||
| @@ -55,6 +56,9 @@ const char *aa_splitn_fqname(const char *fqname, size_t n, const char **ns_name, | |||
| 55 | size_t *ns_len); | 56 | size_t *ns_len); |
| 56 | void aa_info_message(const char *str); | 57 | void aa_info_message(const char *str); |
| 57 | 58 | ||
| 59 | /* Security blob offsets */ | ||
| 60 | extern struct lsm_blob_sizes apparmor_blob_sizes; | ||
| 61 | |||
| 58 | /** | 62 | /** |
| 59 | * aa_strneq - compare null terminated @str to a non null terminated substring | 63 | * aa_strneq - compare null terminated @str to a non null terminated substring |
| 60 | * @str: a null terminated string | 64 | * @str: a null terminated string |
diff --git a/security/apparmor/include/task.h b/security/apparmor/include/task.h index 55edaa1d83f8..311e652324e3 100644 --- a/security/apparmor/include/task.h +++ b/security/apparmor/include/task.h | |||
| @@ -14,7 +14,10 @@ | |||
| 14 | #ifndef __AA_TASK_H | 14 | #ifndef __AA_TASK_H |
| 15 | #define __AA_TASK_H | 15 | #define __AA_TASK_H |
| 16 | 16 | ||
| 17 | #define task_ctx(X) ((X)->security) | 17 | static inline struct aa_task_ctx *task_ctx(struct task_struct *task) |
| 18 | { | ||
| 19 | return task->security + apparmor_blob_sizes.lbs_task; | ||
| 20 | } | ||
| 18 | 21 | ||
| 19 | /* | 22 | /* |
| 20 | * struct aa_task_ctx - information for current task label change | 23 | * struct aa_task_ctx - information for current task label change |
| @@ -37,17 +40,6 @@ int aa_restore_previous_label(u64 cookie); | |||
| 37 | struct aa_label *aa_get_task_label(struct task_struct *task); | 40 | struct aa_label *aa_get_task_label(struct task_struct *task); |
| 38 | 41 | ||
| 39 | /** | 42 | /** |
| 40 | * aa_alloc_task_ctx - allocate a new task_ctx | ||
| 41 | * @flags: gfp flags for allocation | ||
| 42 | * | ||
| 43 | * Returns: allocated buffer or NULL on failure | ||
| 44 | */ | ||
| 45 | static inline struct aa_task_ctx *aa_alloc_task_ctx(gfp_t flags) | ||
| 46 | { | ||
| 47 | return kzalloc(sizeof(struct aa_task_ctx), flags); | ||
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 51 | * aa_free_task_ctx - free a task_ctx | 43 | * aa_free_task_ctx - free a task_ctx |
| 52 | * @ctx: task_ctx to free (MAYBE NULL) | 44 | * @ctx: task_ctx to free (MAYBE NULL) |
| 53 | */ | 45 | */ |
| @@ -57,8 +49,6 @@ static inline void aa_free_task_ctx(struct aa_task_ctx *ctx) | |||
| 57 | aa_put_label(ctx->nnp); | 49 | aa_put_label(ctx->nnp); |
| 58 | aa_put_label(ctx->previous); | 50 | aa_put_label(ctx->previous); |
| 59 | aa_put_label(ctx->onexec); | 51 | aa_put_label(ctx->onexec); |
| 60 | |||
| 61 | kzfree(ctx); | ||
| 62 | } | 52 | } |
| 63 | } | 53 | } |
| 64 | 54 | ||
