11/*
22 * AppArmor security module
33 *
4- * This file contains AppArmor functions used to manipulate object security
5- * contexts.
4+ * This file contains AppArmor task related definitions and mediation
65 *
7- * Copyright (C) 1998-2008 Novell/SUSE
8- * Copyright 2009-2010 Canonical Ltd.
6+ * Copyright 2017 Canonical Ltd.
97 *
108 * This program is free software; you can redistribute it and/or
119 * modify it under the terms of the GNU General Public License as
1210 * published by the Free Software Foundation, version 2 of the
1311 * License.
1412 *
15- *
16- * AppArmor sets confinement on every task, via the cred_label() which
17- * is required and are not allowed to be NULL. The cred_label is
18- * reference counted.
19- *
2013 * TODO
2114 * If a task uses change_hat it currently does not return to the old
2215 * cred or task context but instead creates a new one. Ideally the task
2316 * should return to the previous cred if it has not been modified.
24- *
2517 */
2618
2719#include "include/context.h"
28- #include "include/policy.h"
29-
20+ #include "include/task.h"
3021
3122/**
3223 * aa_get_task_label - Get another task's label
@@ -45,43 +36,6 @@ struct aa_label *aa_get_task_label(struct task_struct *task)
4536 return p ;
4637}
4738
48- /**
49- * aa_alloc_task_ctx - allocate a new task_ctx
50- * @flags: gfp flags for allocation
51- *
52- * Returns: allocated buffer or NULL on failure
53- */
54- struct aa_task_ctx * aa_alloc_task_ctx (gfp_t flags )
55- {
56- return kzalloc (sizeof (struct aa_task_ctx ), flags );
57- }
58-
59- /**
60- * aa_free_task_ctx - free a task_ctx
61- * @ctx: task_ctx to free (MAYBE NULL)
62- */
63- void aa_free_task_ctx (struct aa_task_ctx * ctx )
64- {
65- if (ctx ) {
66- aa_put_label (ctx -> previous );
67- aa_put_label (ctx -> onexec );
68-
69- kzfree (ctx );
70- }
71- }
72-
73- /**
74- * aa_dup_task_ctx - duplicate a task context, incrementing reference counts
75- * @new: a blank task context (NOT NULL)
76- * @old: the task context to copy (NOT NULL)
77- */
78- void aa_dup_task_ctx (struct aa_task_ctx * new , const struct aa_task_ctx * old )
79- {
80- * new = * old ;
81- aa_get_label (new -> previous );
82- aa_get_label (new -> onexec );
83- }
84-
8539/**
8640 * aa_replace_current_label - replace the current tasks label
8741 * @label: new label (NOT NULL)
@@ -110,7 +64,7 @@ int aa_replace_current_label(struct aa_label *label)
11064 * if switching to unconfined or a different label namespace
11165 * clear out context state
11266 */
113- aa_clear_task_ctx_trans (current_task_ctx ( ));
67+ aa_clear_task_ctx_trans (task_ctx ( current ));
11468
11569 /*
11670 * be careful switching cred label, when racing replacement it
@@ -126,6 +80,7 @@ int aa_replace_current_label(struct aa_label *label)
12680 return 0 ;
12781}
12882
83+
12984/**
13085 * aa_set_current_onexec - set the tasks change_profile to happen onexec
13186 * @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)
13489 */
13590int aa_set_current_onexec (struct aa_label * label , bool stack )
13691{
137- struct aa_task_ctx * ctx = current_task_ctx ( );
92+ struct aa_task_ctx * ctx = task_ctx ( current );
13893
13994 aa_get_label (label );
14095 aa_put_label (ctx -> onexec );
@@ -156,7 +111,7 @@ int aa_set_current_onexec(struct aa_label *label, bool stack)
156111 */
157112int aa_set_current_hat (struct aa_label * label , u64 token )
158113{
159- struct aa_task_ctx * ctx = current_task_ctx ( );
114+ struct aa_task_ctx * ctx = task_ctx ( current );
160115 struct cred * new ;
161116
162117 new = prepare_creds ();
@@ -196,7 +151,7 @@ int aa_set_current_hat(struct aa_label *label, u64 token)
196151 */
197152int aa_restore_previous_label (u64 token )
198153{
199- struct aa_task_ctx * ctx = current_task_ctx ( );
154+ struct aa_task_ctx * ctx = task_ctx ( current );
200155 struct cred * new ;
201156
202157 if (ctx -> token != token )
0 commit comments