smack: fix possible use after frees in task_security() callers
[linux-2.6-block.git] / security / smack / smack.h
index b828a379377c9cd1c2dee54bc2ddab5b3bde920a..67ccb7b2b89bdd6606934f8f216e368244b32171 100644 (file)
@@ -248,6 +248,7 @@ struct smack_known *smk_find_entry(const char *);
 /*
  * Shared data.
  */
+extern int smack_enabled;
 extern int smack_cipso_direct;
 extern int smack_cipso_mapped;
 extern struct smack_known *smack_net_ambient;
@@ -298,6 +299,16 @@ 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)
+{
+       struct smack_known *skp;
+
+       rcu_read_lock();
+       skp = smk_of_task(__task_cred(t)->security);
+       rcu_read_unlock();
+       return skp;
+}
+
 /*
  * Present a pointer to the forked smack label entry in an task blob.
  */