aboutsummaryrefslogtreecommitdiff
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c38
1 files changed, 10 insertions, 28 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index bf54f68c169..b582c7d39ae 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -437,7 +437,6 @@ next_inode:
list_entry(sbsec->isec_head.next,
struct inode_security_struct, list);
struct inode *inode = isec->inode;
- list_del_init(&isec->list);
spin_unlock(&sbsec->isec_lock);
inode = igrab(inode);
if (inode) {
@@ -446,6 +445,7 @@ next_inode:
iput(inode);
}
spin_lock(&sbsec->isec_lock);
+ list_del_init(&isec->list);
goto next_inode;
}
spin_unlock(&sbsec->isec_lock);
@@ -1361,33 +1361,15 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
isec->sid = sbsec->sid;
if ((sbsec->flags & SE_SBPROC) && !S_ISLNK(inode->i_mode)) {
- /* We must have a dentry to determine the label on
- * procfs inodes */
- if (opt_dentry)
- /* Called from d_instantiate or
- * d_splice_alias. */
- dentry = dget(opt_dentry);
- else
- /* Called from selinux_complete_init, try to
- * find a dentry. */
- dentry = d_find_alias(inode);
- /*
- * This can be hit on boot when a file is accessed
- * before the policy is loaded. When we load policy we
- * may find inodes that have no dentry on the
- * sbsec->isec_head list. No reason to complain as
- * these will get fixed up the next time we go through
- * inode_doinit() with a dentry, before these inodes
- * could be used again by userspace.
- */
- if (!dentry)
- goto out_unlock;
- isec->sclass = inode_mode_to_security_class(inode->i_mode);
- rc = selinux_proc_get_sid(dentry, isec->sclass, &sid);
- dput(dentry);
- if (rc)
- goto out_unlock;
- isec->sid = sid;
+ if (opt_dentry) {
+ isec->sclass = inode_mode_to_security_class(inode->i_mode);
+ rc = selinux_proc_get_sid(opt_dentry,
+ isec->sclass,
+ &sid);
+ if (rc)
+ goto out_unlock;
+ isec->sid = sid;
+ }
}
break;
}