aboutsummaryrefslogtreecommitdiffstats
path: root/security/apparmor/include/context.h
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2013-02-18 19:03:34 -0500
committerJohn Johansen <john.johansen@canonical.com>2013-04-28 03:35:53 -0400
commit3cfcc19e0b5390c04cb5bfa4e8fde39395410e61 (patch)
tree6ce52c3cc5166390814b9451d58badcfee9a3770 /security/apparmor/include/context.h
parente573cc30bb36df23fb49a29d96e6c6333d17f59c (diff)
apparmor: add utility function to get an arbitrary tasks profile.
Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Steve Beattie <sbeattie@ubuntu.com>
Diffstat (limited to 'security/apparmor/include/context.h')
-rw-r--r--security/apparmor/include/context.h41
1 files changed, 25 insertions, 16 deletions
diff --git a/security/apparmor/include/context.h b/security/apparmor/include/context.h
index a9cbee4d9e48..1e9443a58877 100644
--- a/security/apparmor/include/context.h
+++ b/security/apparmor/include/context.h
@@ -80,23 +80,8 @@ int aa_replace_current_profile(struct aa_profile *profile);
80int aa_set_current_onexec(struct aa_profile *profile); 80int aa_set_current_onexec(struct aa_profile *profile);
81int aa_set_current_hat(struct aa_profile *profile, u64 token); 81int aa_set_current_hat(struct aa_profile *profile, u64 token);
82int aa_restore_previous_profile(u64 cookie); 82int aa_restore_previous_profile(u64 cookie);
83struct aa_profile *aa_get_task_profile(struct task_struct *task);
83 84
84/**
85 * __aa_task_is_confined - determine if @task has any confinement
86 * @task: task to check confinement of (NOT NULL)
87 *
88 * If @task != current needs to be called in RCU safe critical section
89 */
90static inline bool __aa_task_is_confined(struct task_struct *task)
91{
92 struct aa_task_cxt *cxt = __task_cred(task)->security;
93
94 BUG_ON(!cxt || !cxt->profile);
95 if (unconfined(aa_newest_version(cxt->profile)))
96 return 0;
97
98 return 1;
99}
100 85
101/** 86/**
102 * aa_cred_profile - obtain cred's profiles 87 * aa_cred_profile - obtain cred's profiles
@@ -114,6 +99,30 @@ static inline struct aa_profile *aa_cred_profile(const struct cred *cred)
114} 99}
115 100
116/** 101/**
102 * __aa_task_profile - retrieve another task's profile
103 * @task: task to query (NOT NULL)
104 *
105 * Returns: @task's profile without incrementing its ref count
106 *
107 * If @task != current needs to be called in RCU safe critical section
108 */
109static inline struct aa_profile *__aa_task_profile(struct task_struct *task)
110{
111 return aa_cred_profile(__task_cred(task));
112}
113
114/**
115 * __aa_task_is_confined - determine if @task has any confinement
116 * @task: task to check confinement of (NOT NULL)
117 *
118 * If @task != current needs to be called in RCU safe critical section
119 */
120static inline bool __aa_task_is_confined(struct task_struct *task)
121{
122 return !unconfined(__aa_task_profile(task));
123}
124
125/**
117 * __aa_current_profile - find the current tasks confining profile 126 * __aa_current_profile - find the current tasks confining profile
118 * 127 *
119 * Returns: up to date confining profile or the ns unconfined profile (NOT NULL) 128 * Returns: up to date confining profile or the ns unconfined profile (NOT NULL)