Skip to content

Commit cac36f7

Browse files
jeffmahoneytorvalds
authored andcommitted
reiserfs: fix permissions on .reiserfs_priv
Commit 677c9b2 ("reiserfs: remove privroot hiding in lookup") removed the magic from the lookup code to hide the .reiserfs_priv directory since it was getting loaded at mount-time instead. The intent was that the entry would be hidden from the user via a poisoned d_compare, but this was faulty. This introduced a security issue where unprivileged users could access and modify extended attributes or ACLs belonging to other users, including root. This patch resolves the issue by properly hiding .reiserfs_priv. This was the intent of the xattr poisoning code, but it appears to have never worked as expected. This is fixed by using d_revalidate instead of d_compare. This patch makes -oexpose_privroot a no-op. I'm fine leaving it this way. The effort involved in working out the corner cases wrt permissions and caching outweigh the benefit of the feature. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Acked-by: Edward Shishkin <edward.shishkin@gmail.com> Reported-by: Matt McCutchen <matt@mattmccutchen.net> Tested-by: Matt McCutchen <matt@mattmccutchen.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 33eaf78 commit cac36f7

2 files changed

Lines changed: 4 additions & 15 deletions

File tree

‎fs/reiserfs/dir.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ static inline bool is_privroot_deh(struct dentry *dir,
4646
struct reiserfs_de_head *deh)
4747
{
4848
struct dentry *privroot = REISERFS_SB(dir->d_sb)->priv_root;
49-
if (reiserfs_expose_privroot(dir->d_sb))
50-
return 0;
5149
return (dir == dir->d_parent && privroot->d_inode &&
5250
deh->deh_objectid == INODE_PKEY(privroot->d_inode)->k_objectid);
5351
}

‎fs/reiserfs/xattr.c‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -973,21 +973,13 @@ int reiserfs_permission(struct inode *inode, int mask)
973973
return generic_permission(inode, mask, NULL);
974974
}
975975

976-
/* This will catch lookups from the fs root to .reiserfs_priv */
977-
static int
978-
xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name)
976+
static int xattr_hide_revalidate(struct dentry *dentry, struct nameidata *nd)
979977
{
980-
struct dentry *priv_root = REISERFS_SB(dentry->d_sb)->priv_root;
981-
if (container_of(q1, struct dentry, d_name) == priv_root)
982-
return -ENOENT;
983-
if (q1->len == name->len &&
984-
!memcmp(q1->name, name->name, name->len))
985-
return 0;
986-
return 1;
978+
return -EPERM;
987979
}
988980

989981
static const struct dentry_operations xattr_lookup_poison_ops = {
990-
.d_compare = xattr_lookup_poison,
982+
.d_revalidate = xattr_hide_revalidate,
991983
};
992984

993985
int reiserfs_lookup_privroot(struct super_block *s)
@@ -1001,8 +993,7 @@ int reiserfs_lookup_privroot(struct super_block *s)
1001993
strlen(PRIVROOT_NAME));
1002994
if (!IS_ERR(dentry)) {
1003995
REISERFS_SB(s)->priv_root = dentry;
1004-
if (!reiserfs_expose_privroot(s))
1005-
s->s_root->d_op = &xattr_lookup_poison_ops;
996+
dentry->d_op = &xattr_lookup_poison_ops;
1006997
if (dentry->d_inode)
1007998
dentry->d_inode->i_flags |= S_PRIVATE;
1008999
} else

0 commit comments

Comments
 (0)