From: Andreas Gruenbacher <agruenba@redhat.com>
To: Paul Moore <paul@paul-moore.com>,
Stephen Smalley <sds@tycho.nsa.gov>,
Eric Paris <eparis@parisplace.org>
Cc: Andreas Gruenbacher <agruenba@redhat.com>, selinux@tycho.nsa.gov
Subject: [PATCH 3/4] selinux: Clean up initialization of isec->sclass
Date: Thu, 10 Nov 2016 22:18:29 +0100 [thread overview]
Message-ID: <1478812710-17190-4-git-send-email-agruenba@redhat.com> (raw)
In-Reply-To: <1478812710-17190-1-git-send-email-agruenba@redhat.com>
Now that isec->initialized == LABEL_INITIALIZED implies that
isec->sclass is valid, skip such inodes immediately in
inode_doinit_with_dentry.
For the remaining inodes, initialize isec->sclass at the beginning of
inode_doinit_with_dentry to simplify the code.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
security/selinux/hooks.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e4527d9..cf5067e 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1389,12 +1389,15 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
int rc = 0;
if (isec->initialized == LABEL_INITIALIZED)
- goto out;
+ return 0;
mutex_lock(&isec->lock);
if (isec->initialized == LABEL_INITIALIZED)
goto out_unlock;
+ if (isec->sclass == SECCLASS_FILE)
+ isec->sclass = inode_mode_to_security_class(inode->i_mode);
+
sbsec = inode->i_sb->s_security;
if (!(sbsec->flags & SE_SBINITIALIZED)) {
/* Defer initialization until selinux_complete_init,
@@ -1512,7 +1515,6 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
isec->sid = sbsec->sid;
/* Try to obtain a transition SID. */
- isec->sclass = inode_mode_to_security_class(inode->i_mode);
rc = security_transition_sid(isec->task_sid, sbsec->sid,
isec->sclass, NULL, &sid);
if (rc)
@@ -1548,7 +1550,6 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
*/
if (!dentry)
goto out_unlock;
- isec->sclass = inode_mode_to_security_class(inode->i_mode);
rc = selinux_genfs_get_sid(dentry, isec->sclass,
sbsec->flags, &sid);
dput(dentry);
@@ -1563,9 +1564,6 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
out_unlock:
mutex_unlock(&isec->lock);
-out:
- if (isec->sclass == SECCLASS_FILE)
- isec->sclass = inode_mode_to_security_class(inode->i_mode);
return rc;
}
--
2.7.4
next prev parent reply other threads:[~2016-11-10 21:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-10 21:18 [PATCH 0/4] selinux: Fix invalidate deadlock with GFS2 Andreas Gruenbacher
2016-11-10 21:18 ` [PATCH 1/4] selinux: Minor cleanups Andreas Gruenbacher
2016-11-14 20:28 ` Paul Moore
2016-11-10 21:18 ` [PATCH 2/4] proc: Pass file mode to proc_pid_make_inode Andreas Gruenbacher
2016-11-14 20:44 ` Paul Moore
2016-11-10 21:18 ` Andreas Gruenbacher [this message]
2016-11-14 20:56 ` [PATCH 3/4] selinux: Clean up initialization of isec->sclass Paul Moore
2016-11-10 21:18 ` [PATCH 4/4] selinux: Convert isec->lock into a spinlock Andreas Gruenbacher
2016-11-14 22:22 ` Paul Moore
2016-11-15 10:06 ` Andreas Gruenbacher
2016-11-22 23:00 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1478812710-17190-4-git-send-email-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=eparis@parisplace.org \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.