diff options
| author | David Howells <dhowells@redhat.com> | 2008-11-14 10:39:19 +1100 | 
|---|---|---|
| committer | James Morris <jmorris@namei.org> | 2008-11-14 10:39:19 +1100 | 
| commit | c69e8d9c01db2adc503464993c358901c9af9de4 (patch) | |
| tree | bed94aaa9aeb7a7834d1c880f72b62a11a752c78 /security/selinux/selinuxfs.c | |
| parent | 86a264abe542cfececb4df129bc45a0338d8cdb9 (diff) | |
| download | olio-linux-3.10-c69e8d9c01db2adc503464993c358901c9af9de4.tar.xz olio-linux-3.10-c69e8d9c01db2adc503464993c358901c9af9de4.zip  | |
CRED: Use RCU to access another task's creds and to release a task's own creds
Use RCU to access another task's creds and to release a task's own creds.
This means that it will be possible for the credentials of a task to be
replaced without another task (a) requiring a full lock to read them, and (b)
seeing deallocated memory.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/selinux/selinuxfs.c')
| -rw-r--r-- | security/selinux/selinuxfs.c | 11 | 
1 files changed, 8 insertions, 3 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index 10715d1330b..c8630363823 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -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; +	const struct task_security_struct *tsec; +	u32 sid = 0; -	tsec = tsk->cred->security; +	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);  }  |