]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - security/selinux/selinuxfs.c
CRED: Use RCU to access another task's creds and to release a task's own creds
[net-next-2.6.git] / security / selinux / selinuxfs.c
index 10715d1330b94a65a6e67e41096a5f57831a7635..c86303638235f2633eaff9c5426eed950517f785 100644 (file)
@@ -95,13 +95,18 @@ extern void selnl_notify_setenforce(int val);
 static int task_has_security(struct task_struct *tsk,
                             u32 perms)
 {
-       struct task_security_struct *tsec;
-
-       tsec = tsk->cred->security;
+       const struct task_security_struct *tsec;
+       u32 sid = 0;
+
+       rcu_read_lock();
+       tsec = __task_cred(tsk)->security;
+       if (tsec)
+               sid = tsec->sid;
+       rcu_read_unlock();
        if (!tsec)
                return -EACCES;
 
-       return avc_has_perm(tsec->sid, SECINITSID_SECURITY,
+       return avc_has_perm(sid, SECINITSID_SECURITY,
                            SECCLASS_SECURITY, perms, NULL);
 }