summaryrefslogtreecommitdiffstats
path: root/security/tomoyo/securityfs_if.c
diff options
context:
space:
mode:
authorCasey Schaufler2018-09-22 02:18:07 +0200
committerKees Cook2019-01-08 22:18:44 +0100
commit43fc460907dc56a3450654efc6ba1dfbcd4594eb (patch)
treedb944e38f3908e790d8d577e10d23a0f7bf02b68 /security/tomoyo/securityfs_if.c
parentAppArmor: Abstract use of cred security blob (diff)
downloadkernel-qcow2-linux-43fc460907dc56a3450654efc6ba1dfbcd4594eb.tar.gz
kernel-qcow2-linux-43fc460907dc56a3450654efc6ba1dfbcd4594eb.tar.xz
kernel-qcow2-linux-43fc460907dc56a3450654efc6ba1dfbcd4594eb.zip
TOMOYO: Abstract use of cred security blob
Don't use the cred->security pointer directly. Provide helper functions that provide the security blob pointer. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> Reviewed-by: Kees Cook <keescook@chromium.org> [kees: adjusted for ordered init series] Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'security/tomoyo/securityfs_if.c')
-rw-r--r--security/tomoyo/securityfs_if.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/security/tomoyo/securityfs_if.c b/security/tomoyo/securityfs_if.c
index 1d3d7e7a1f05..768dff9608b1 100644
--- a/security/tomoyo/securityfs_if.c
+++ b/security/tomoyo/securityfs_if.c
@@ -71,9 +71,12 @@ static ssize_t tomoyo_write_self(struct file *file, const char __user *buf,
if (!cred) {
error = -ENOMEM;
} else {
- struct tomoyo_domain_info *old_domain =
- cred->security;
- cred->security = new_domain;
+ struct tomoyo_domain_info **blob;
+ struct tomoyo_domain_info *old_domain;
+
+ blob = tomoyo_cred(cred);
+ old_domain = *blob;
+ *blob = new_domain;
atomic_inc(&new_domain->users);
atomic_dec(&old_domain->users);
commit_creds(cred);
@@ -234,10 +237,14 @@ static void __init tomoyo_create_entry(const char *name, const umode_t mode,
*/
static int __init tomoyo_initerface_init(void)
{
+ struct tomoyo_domain_info *domain;
struct dentry *tomoyo_dir;
+ if (!tomoyo_enabled)
+ return 0;
+ domain = tomoyo_domain();
/* Don't create securityfs entries unless registered. */
- if (current_cred()->security != &tomoyo_kernel_domain)
+ if (domain != &tomoyo_kernel_domain)
return 0;
tomoyo_dir = securityfs_create_dir("tomoyo", NULL);