[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211011190204.123934-1-dave@stgolabs.net>
Date: Mon, 11 Oct 2021 12:02:04 -0700
From: Davidlohr Bueso <dave@...olabs.net>
To: paul@...l-moore.com
Cc: stephen.smalley.work@...il.com, selinux@...r.kernel.org,
linux-kernel@...r.kernel.org, dave@...olabs.net,
Davidlohr Bueso <dbueso@...e.de>
Subject: [PATCH] selinux: consilidate comments from inode_doinit_with_dentry wrt !dentry
Instead of having the same big comment twice for the same scenario,
just have it in out_invalid.
Signed-off-by: Davidlohr Bueso <dbueso@...e.de>
---
security/selinux/hooks.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e7ebd45ca345..0e0013cc7ba8 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1502,18 +1502,8 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
if (!dentry)
dentry = d_find_any_alias(inode);
}
- if (!dentry) {
- /*
- * this is 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_invalid;
- }
rc = inode_doinit_use_xattr(inode, dentry, sbsec->def_sid,
&sid);
@@ -1559,15 +1549,6 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
if (!dentry)
dentry = d_find_any_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_invalid;
rc = selinux_genfs_get_sid(dentry, sclass,
@@ -1607,6 +1588,15 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
return rc;
out_invalid:
+ /*
+ * This is 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.
+ */
spin_lock(&isec->lock);
if (isec->initialized == LABEL_PENDING) {
isec->initialized = LABEL_INVALID;
--
2.26.2
Powered by blists - more mailing lists