Skip to content

Commit b127125

Browse files
author
Al Viro
committed
fix breakage caused by d_find_alias() semantics change
"VFS: don't keep disconnected dentries on d_anon" had a non-trivial side-effect - d_unhashed() now returns true for those dentries, making d_find_alias() skip them altogether. For most of its callers that's fine - we really want a connected alias there. However, there is a codepath where we relied upon picking such aliases if nothing else could be found - selinux delayed initialization of contexts for inodes on already mounted filesystems used to rely upon that. Cc: [email protected] # f1ee616 "VFS: don't keep disconnected dentries on d_anon" Signed-off-by: Al Viro <[email protected]>
1 parent 79f546a commit b127125

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

security/selinux/hooks.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,8 +1568,15 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
15681568
/* Called from d_instantiate or d_splice_alias. */
15691569
dentry = dget(opt_dentry);
15701570
} else {
1571-
/* Called from selinux_complete_init, try to find a dentry. */
1571+
/*
1572+
* Called from selinux_complete_init, try to find a dentry.
1573+
* Some filesystems really want a connected one, so try
1574+
* that first. We could split SECURITY_FS_USE_XATTR in
1575+
* two, depending upon that...
1576+
*/
15721577
dentry = d_find_alias(inode);
1578+
if (!dentry)
1579+
dentry = d_find_any_alias(inode);
15731580
}
15741581
if (!dentry) {
15751582
/*
@@ -1674,14 +1681,19 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
16741681
if ((sbsec->flags & SE_SBGENFS) && !S_ISLNK(inode->i_mode)) {
16751682
/* We must have a dentry to determine the label on
16761683
* procfs inodes */
1677-
if (opt_dentry)
1684+
if (opt_dentry) {
16781685
/* Called from d_instantiate or
16791686
* d_splice_alias. */
16801687
dentry = dget(opt_dentry);
1681-
else
1688+
} else {
16821689
/* Called from selinux_complete_init, try to
1683-
* find a dentry. */
1690+
* find a dentry. Some filesystems really want
1691+
* a connected one, so try that first.
1692+
*/
16841693
dentry = d_find_alias(inode);
1694+
if (!dentry)
1695+
dentry = d_find_any_alias(inode);
1696+
}
16851697
/*
16861698
* This can be hit on boot when a file is accessed
16871699
* before the policy is loaded. When we load policy we

0 commit comments

Comments
 (0)