Smack: Abstract use of cred security blob

Don't use the cred->security pointer directly.
Provide a helper function that provides 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>
This commit is contained in:
Casey Schaufler
2018-11-09 16:12:56 -08:00
committed by Kees Cook
parent 6d9c939dbe
commit b17103a8b8
4 changed files with 53 additions and 43 deletions

View File

@@ -356,6 +356,11 @@ extern struct list_head smack_onlycap_list;
#define SMACK_HASH_SLOTS 16
extern struct hlist_head smack_known_hash[SMACK_HASH_SLOTS];
static inline struct task_smack *smack_cred(const struct cred *cred)
{
return cred->security;
}
/*
* Is the directory transmuting?
*/
@@ -382,13 +387,19 @@ static inline struct smack_known *smk_of_task(const struct task_smack *tsp)
return tsp->smk_task;
}
static inline struct smack_known *smk_of_task_struct(const struct task_struct *t)
static inline struct smack_known *smk_of_task_struct(
const struct task_struct *t)
{
struct smack_known *skp;
const struct cred *cred;
rcu_read_lock();
skp = smk_of_task(__task_cred(t)->security);
cred = __task_cred(t);
skp = smk_of_task(smack_cred(cred));
rcu_read_unlock();
return skp;
}
@@ -405,7 +416,7 @@ static inline struct smack_known *smk_of_forked(const struct task_smack *tsp)
*/
static inline struct smack_known *smk_of_current(void)
{
return smk_of_task(current_security());
return smk_of_task(smack_cred(current_cred()));
}
/*