diff options
author | Paul Moore <paul.moore@hp.com> | 2010-04-22 14:46:19 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2010-08-02 01:34:39 -0400 |
commit | 5fb49870e6d48d81d8ca0e1ef979073dc9a820f7 (patch) | |
tree | 136fdf4f4181907b89916f24a8e828c00ba3e6bd /security/selinux/hooks.c | |
parent | 253bfae6e0ad97554799affa0266052968a45808 (diff) |
selinux: Use current_security() when possible
There were a number of places using the following code pattern:
struct cred *cred = current_cred();
struct task_security_struct *tsec = cred->security;
... which were simplified to the following:
struct task_security_struct *tsec = current_security();
Signed-off-by: Paul Moore <paul.moore@hp.com>
Acked-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index e95004010c8b..0f524b7d102e 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -188,7 +188,7 @@ static inline u32 task_sid(const struct task_struct *task) | |||
188 | */ | 188 | */ |
189 | static inline u32 current_sid(void) | 189 | static inline u32 current_sid(void) |
190 | { | 190 | { |
191 | const struct task_security_struct *tsec = current_cred()->security; | 191 | const struct task_security_struct *tsec = current_security(); |
192 | 192 | ||
193 | return tsec->sid; | 193 | return tsec->sid; |
194 | } | 194 | } |
@@ -1558,8 +1558,7 @@ static int may_create(struct inode *dir, | |||
1558 | struct dentry *dentry, | 1558 | struct dentry *dentry, |
1559 | u16 tclass) | 1559 | u16 tclass) |
1560 | { | 1560 | { |
1561 | const struct cred *cred = current_cred(); | 1561 | const struct task_security_struct *tsec = current_security(); |
1562 | const struct task_security_struct *tsec = cred->security; | ||
1563 | struct inode_security_struct *dsec; | 1562 | struct inode_security_struct *dsec; |
1564 | struct superblock_security_struct *sbsec; | 1563 | struct superblock_security_struct *sbsec; |
1565 | u32 sid, newsid; | 1564 | u32 sid, newsid; |
@@ -2157,8 +2156,7 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm) | |||
2157 | 2156 | ||
2158 | static int selinux_bprm_secureexec(struct linux_binprm *bprm) | 2157 | static int selinux_bprm_secureexec(struct linux_binprm *bprm) |
2159 | { | 2158 | { |
2160 | const struct cred *cred = current_cred(); | 2159 | const struct task_security_struct *tsec = current_security(); |
2161 | const struct task_security_struct *tsec = cred->security; | ||
2162 | u32 sid, osid; | 2160 | u32 sid, osid; |
2163 | int atsecure = 0; | 2161 | int atsecure = 0; |
2164 | 2162 | ||
@@ -2533,8 +2531,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, | |||
2533 | char **name, void **value, | 2531 | char **name, void **value, |
2534 | size_t *len) | 2532 | size_t *len) |
2535 | { | 2533 | { |
2536 | const struct cred *cred = current_cred(); | 2534 | const struct task_security_struct *tsec = current_security(); |
2537 | const struct task_security_struct *tsec = cred->security; | ||
2538 | struct inode_security_struct *dsec; | 2535 | struct inode_security_struct *dsec; |
2539 | struct superblock_security_struct *sbsec; | 2536 | struct superblock_security_struct *sbsec; |
2540 | u32 sid, newsid, clen; | 2537 | u32 sid, newsid, clen; |
@@ -3669,8 +3666,7 @@ static int sock_has_perm(struct task_struct *task, struct sock *sk, u32 perms) | |||
3669 | static int selinux_socket_create(int family, int type, | 3666 | static int selinux_socket_create(int family, int type, |
3670 | int protocol, int kern) | 3667 | int protocol, int kern) |
3671 | { | 3668 | { |
3672 | const struct cred *cred = current_cred(); | 3669 | const struct task_security_struct *tsec = current_security(); |
3673 | const struct task_security_struct *tsec = cred->security; | ||
3674 | u32 newsid; | 3670 | u32 newsid; |
3675 | u16 secclass; | 3671 | u16 secclass; |
3676 | 3672 | ||
@@ -3685,8 +3681,7 @@ static int selinux_socket_create(int family, int type, | |||
3685 | static int selinux_socket_post_create(struct socket *sock, int family, | 3681 | static int selinux_socket_post_create(struct socket *sock, int family, |
3686 | int type, int protocol, int kern) | 3682 | int type, int protocol, int kern) |
3687 | { | 3683 | { |
3688 | const struct cred *cred = current_cred(); | 3684 | const struct task_security_struct *tsec = current_security(); |
3689 | const struct task_security_struct *tsec = cred->security; | ||
3690 | struct inode_security_struct *isec = SOCK_INODE(sock)->i_security; | 3685 | struct inode_security_struct *isec = SOCK_INODE(sock)->i_security; |
3691 | struct sk_security_struct *sksec; | 3686 | struct sk_security_struct *sksec; |
3692 | int err = 0; | 3687 | int err = 0; |