Skip to content

Commit 60e4cf6

Browse files
jeffmahoneyjankara
authored andcommitted
reiserfs: fix extended attributes on the root directory
Since commit d0a5b99 (vfs: Add IOP_XATTR inode operations flag) extended attributes haven't worked on the root directory in reiserfs. This is due to reiserfs conditionally setting the sb->s_xattrs handler array depending on whether it located or create the internal privroot directory. It necessarily does this after the root inode is already read in. The IOP_XATTR flag is set during inode initialization, so it never gets set on the root directory. This commit unconditionally assigns sb->s_xattrs and clears IOP_XATTR on internal inodes. The old return values due to the conditional assignment are handled via open_xa_root, which now returns EOPNOTSUPP as the VFS would have done. Link: https://lore.kernel.org/r/20191024143127.17509-1-jeffm@suse.com CC: stable@vger.kernel.org Fixes: d0a5b99 ("vfs: Add IOP_XATTR inode operations flag") Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent acd1f04 commit 60e4cf6

6 files changed

Lines changed: 32 additions & 14 deletions

File tree

‎fs/reiserfs/inode.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,15 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
20972097
goto out_inserted_sd;
20982098
}
20992099

2100+
/*
2101+
* Mark it private if we're creating the privroot
2102+
* or something under it.
2103+
*/
2104+
if (IS_PRIVATE(dir) || dentry == REISERFS_SB(sb)->priv_root) {
2105+
inode->i_flags |= S_PRIVATE;
2106+
inode->i_opflags &= ~IOP_XATTR;
2107+
}
2108+
21002109
if (reiserfs_posixacl(inode->i_sb)) {
21012110
reiserfs_write_unlock(inode->i_sb);
21022111
retval = reiserfs_inherit_default_acl(th, dir, dentry, inode);
@@ -2111,8 +2120,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
21112120
reiserfs_warning(inode->i_sb, "jdm-13090",
21122121
"ACLs aren't enabled in the fs, "
21132122
"but vfs thinks they are!");
2114-
} else if (IS_PRIVATE(dir))
2115-
inode->i_flags |= S_PRIVATE;
2123+
}
21162124

21172125
if (security->name) {
21182126
reiserfs_write_unlock(inode->i_sb);

‎fs/reiserfs/namei.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,13 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
377377

378378
/*
379379
* Propagate the private flag so we know we're
380-
* in the priv tree
380+
* in the priv tree. Also clear IOP_XATTR
381+
* since we don't have xattrs on xattr files.
381382
*/
382-
if (IS_PRIVATE(dir))
383+
if (IS_PRIVATE(dir)) {
383384
inode->i_flags |= S_PRIVATE;
385+
inode->i_opflags &= ~IOP_XATTR;
386+
}
384387
}
385388
reiserfs_write_unlock(dir->i_sb);
386389
if (retval == IO_ERROR) {

‎fs/reiserfs/reiserfs.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,8 @@ static inline int bmap_would_wrap(unsigned bmap_nr)
11681168
return bmap_nr > ((1LL << 16) - 1);
11691169
}
11701170

1171+
extern const struct xattr_handler *reiserfs_xattr_handlers[];
1172+
11711173
/*
11721174
* this says about version of key of all items (but stat data) the
11731175
* object consists of

‎fs/reiserfs/super.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
20492049
if (replay_only(s))
20502050
goto error_unlocked;
20512051

2052+
s->s_xattr = reiserfs_xattr_handlers;
2053+
20522054
if (bdev_read_only(s->s_bdev) && !sb_rdonly(s)) {
20532055
SWARN(silent, s, "clm-7000",
20542056
"Detected readonly device, marking FS readonly");

‎fs/reiserfs/xattr.c‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ static struct dentry *open_xa_root(struct super_block *sb, int flags)
122122
struct dentry *xaroot;
123123

124124
if (d_really_is_negative(privroot))
125-
return ERR_PTR(-ENODATA);
125+
return ERR_PTR(-EOPNOTSUPP);
126126

127127
inode_lock_nested(d_inode(privroot), I_MUTEX_XATTR);
128128

129129
xaroot = dget(REISERFS_SB(sb)->xattr_root);
130130
if (!xaroot)
131-
xaroot = ERR_PTR(-ENODATA);
131+
xaroot = ERR_PTR(-EOPNOTSUPP);
132132
else if (d_really_is_negative(xaroot)) {
133133
int err = -ENODATA;
134134

@@ -619,6 +619,10 @@ int reiserfs_xattr_set(struct inode *inode, const char *name,
619619
int error, error2;
620620
size_t jbegin_count = reiserfs_xattr_nblocks(inode, buffer_size);
621621

622+
/* Check before we start a transaction and then do nothing. */
623+
if (!d_really_is_positive(REISERFS_SB(inode->i_sb)->priv_root))
624+
return -EOPNOTSUPP;
625+
622626
if (!(flags & XATTR_REPLACE))
623627
jbegin_count += reiserfs_xattr_jcreate_nblocks(inode);
624628

@@ -841,8 +845,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
841845
if (d_really_is_negative(dentry))
842846
return -EINVAL;
843847

844-
if (!dentry->d_sb->s_xattr ||
845-
get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
848+
if (get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
846849
return -EOPNOTSUPP;
847850

848851
dir = open_xa_dir(d_inode(dentry), XATTR_REPLACE);
@@ -882,6 +885,7 @@ static int create_privroot(struct dentry *dentry)
882885
}
883886

884887
d_inode(dentry)->i_flags |= S_PRIVATE;
888+
d_inode(dentry)->i_opflags &= ~IOP_XATTR;
885889
reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
886890
"storage.\n", PRIVROOT_NAME);
887891

@@ -895,7 +899,7 @@ static int create_privroot(struct dentry *dentry) { return 0; }
895899
#endif
896900

897901
/* Actual operations that are exported to VFS-land */
898-
static const struct xattr_handler *reiserfs_xattr_handlers[] = {
902+
const struct xattr_handler *reiserfs_xattr_handlers[] = {
899903
#ifdef CONFIG_REISERFS_FS_XATTR
900904
&reiserfs_xattr_user_handler,
901905
&reiserfs_xattr_trusted_handler,
@@ -966,8 +970,10 @@ int reiserfs_lookup_privroot(struct super_block *s)
966970
if (!IS_ERR(dentry)) {
967971
REISERFS_SB(s)->priv_root = dentry;
968972
d_set_d_op(dentry, &xattr_lookup_poison_ops);
969-
if (d_really_is_positive(dentry))
973+
if (d_really_is_positive(dentry)) {
970974
d_inode(dentry)->i_flags |= S_PRIVATE;
975+
d_inode(dentry)->i_opflags &= ~IOP_XATTR;
976+
}
971977
} else
972978
err = PTR_ERR(dentry);
973979
inode_unlock(d_inode(s->s_root));
@@ -996,7 +1002,6 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
9961002
}
9971003

9981004
if (d_really_is_positive(privroot)) {
999-
s->s_xattr = reiserfs_xattr_handlers;
10001005
inode_lock(d_inode(privroot));
10011006
if (!REISERFS_SB(s)->xattr_root) {
10021007
struct dentry *dentry;

‎fs/reiserfs/xattr_acl.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,8 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
320320
* would be useless since permissions are ignored, and a pain because
321321
* it introduces locking cycles
322322
*/
323-
if (IS_PRIVATE(dir)) {
324-
inode->i_flags |= S_PRIVATE;
323+
if (IS_PRIVATE(inode))
325324
goto apply_umask;
326-
}
327325

328326
err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
329327
if (err)

0 commit comments

Comments
 (0)