diff options
author | 2017-10-08 00:43:02 -0700 | |
---|---|---|
committer | 2018-02-09 11:30:01 -0800 | |
commit | de62de59c27881c59c7df2e535cb9e1275cd52cc (patch) | |
tree | 931811ad47bc7d33aac279fbc3a438543d9011e6 /security/apparmor/task.c | |
parent | apparmor: cleanup, drop unused fn __aa_task_is_confined() (diff) | |
download | wireguard-linux-de62de59c27881c59c7df2e535cb9e1275cd52cc.tar.xz wireguard-linux-de62de59c27881c59c7df2e535cb9e1275cd52cc.zip |
apparmor: move task related defines and fns to task.X files
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to '')
-rw-r--r-- | security/apparmor/task.c (renamed from security/apparmor/context.c) | 61 |
1 files changed, 8 insertions, 53 deletions
diff --git a/security/apparmor/context.c b/security/apparmor/task.c index d95a3d47cb92..36eb8707ad89 100644 --- a/security/apparmor/context.c +++ b/security/apparmor/task.c @@ -1,32 +1,23 @@ /* * AppArmor security module * - * This file contains AppArmor functions used to manipulate object security - * contexts. + * This file contains AppArmor task related definitions and mediation * - * Copyright (C) 1998-2008 Novell/SUSE - * Copyright 2009-2010 Canonical Ltd. + * Copyright 2017 Canonical Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, version 2 of the * License. * - * - * AppArmor sets confinement on every task, via the cred_label() which - * is required and are not allowed to be NULL. The cred_label is - * reference counted. - * * TODO * If a task uses change_hat it currently does not return to the old * cred or task context but instead creates a new one. Ideally the task * should return to the previous cred if it has not been modified. - * */ #include "include/context.h" -#include "include/policy.h" - +#include "include/task.h" /** * aa_get_task_label - Get another task's label @@ -46,43 +37,6 @@ struct aa_label *aa_get_task_label(struct task_struct *task) } /** - * aa_alloc_task_ctx - allocate a new task_ctx - * @flags: gfp flags for allocation - * - * Returns: allocated buffer or NULL on failure - */ -struct aa_task_ctx *aa_alloc_task_ctx(gfp_t flags) -{ - return kzalloc(sizeof(struct aa_task_ctx), flags); -} - -/** - * aa_free_task_ctx - free a task_ctx - * @ctx: task_ctx to free (MAYBE NULL) - */ -void aa_free_task_ctx(struct aa_task_ctx *ctx) -{ - if (ctx) { - aa_put_label(ctx->previous); - aa_put_label(ctx->onexec); - - kzfree(ctx); - } -} - -/** - * aa_dup_task_ctx - duplicate a task context, incrementing reference counts - * @new: a blank task context (NOT NULL) - * @old: the task context to copy (NOT NULL) - */ -void aa_dup_task_ctx(struct aa_task_ctx *new, const struct aa_task_ctx *old) -{ - *new = *old; - aa_get_label(new->previous); - aa_get_label(new->onexec); -} - -/** * aa_replace_current_label - replace the current tasks label * @label: new label (NOT NULL) * @@ -110,7 +64,7 @@ int aa_replace_current_label(struct aa_label *label) * if switching to unconfined or a different label namespace * clear out context state */ - aa_clear_task_ctx_trans(current_task_ctx()); + aa_clear_task_ctx_trans(task_ctx(current)); /* * be careful switching cred label, when racing replacement it @@ -126,6 +80,7 @@ int aa_replace_current_label(struct aa_label *label) return 0; } + /** * aa_set_current_onexec - set the tasks change_profile to happen onexec * @label: system label to set at exec (MAYBE NULL to clear value) @@ -134,7 +89,7 @@ int aa_replace_current_label(struct aa_label *label) */ int aa_set_current_onexec(struct aa_label *label, bool stack) { - struct aa_task_ctx *ctx = current_task_ctx(); + struct aa_task_ctx *ctx = task_ctx(current); aa_get_label(label); aa_put_label(ctx->onexec); @@ -156,7 +111,7 @@ int aa_set_current_onexec(struct aa_label *label, bool stack) */ int aa_set_current_hat(struct aa_label *label, u64 token) { - struct aa_task_ctx *ctx = current_task_ctx(); + struct aa_task_ctx *ctx = task_ctx(current); struct cred *new; new = prepare_creds(); @@ -196,7 +151,7 @@ int aa_set_current_hat(struct aa_label *label, u64 token) */ int aa_restore_previous_label(u64 token) { - struct aa_task_ctx *ctx = current_task_ctx(); + struct aa_task_ctx *ctx = task_ctx(current); struct cred *new; if (ctx->token != token) |