Skip to content

Commit 7b3ea9b

Browse files
jeffmahoneygregkh
authored andcommitted
reiserfs: fix extended attributes on the root directory
commit 60e4cf6 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 595a92a commit 7b3ea9b

File tree

6 files changed

+32
-14
lines changed

6 files changed

+32
-14
lines changed

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
@@ -2052,6 +2052,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
20522052
if (replay_only(s))
20532053
goto error_unlocked;
20542054

2055+
s->s_xattr = reiserfs_xattr_handlers;
2056+
20552057
if (bdev_read_only(s->s_bdev) && !sb_rdonly(s)) {
20562058
SWARN(silent, s, "clm-7000",
20572059
"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

@@ -610,6 +610,10 @@ int reiserfs_xattr_set(struct inode *inode, const char *name,
610610
int error, error2;
611611
size_t jbegin_count = reiserfs_xattr_nblocks(inode, buffer_size);
612612

613+
/* Check before we start a transaction and then do nothing. */
614+
if (!d_really_is_positive(REISERFS_SB(inode->i_sb)->priv_root))
615+
return -EOPNOTSUPP;
616+
613617
if (!(flags & XATTR_REPLACE))
614618
jbegin_count += reiserfs_xattr_jcreate_nblocks(inode);
615619

@@ -832,8 +836,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
832836
if (d_really_is_negative(dentry))
833837
return -EINVAL;
834838

835-
if (!dentry->d_sb->s_xattr ||
836-
get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
839+
if (get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
837840
return -EOPNOTSUPP;
838841

839842
dir = open_xa_dir(d_inode(dentry), XATTR_REPLACE);
@@ -873,6 +876,7 @@ static int create_privroot(struct dentry *dentry)
873876
}
874877

875878
d_inode(dentry)->i_flags |= S_PRIVATE;
879+
d_inode(dentry)->i_opflags &= ~IOP_XATTR;
876880
reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
877881
"storage.\n", PRIVROOT_NAME);
878882

@@ -886,7 +890,7 @@ static int create_privroot(struct dentry *dentry) { return 0; }
886890
#endif
887891

888892
/* Actual operations that are exported to VFS-land */
889-
static const struct xattr_handler *reiserfs_xattr_handlers[] = {
893+
const struct xattr_handler *reiserfs_xattr_handlers[] = {
890894
#ifdef CONFIG_REISERFS_FS_XATTR
891895
&reiserfs_xattr_user_handler,
892896
&reiserfs_xattr_trusted_handler,
@@ -957,8 +961,10 @@ int reiserfs_lookup_privroot(struct super_block *s)
957961
if (!IS_ERR(dentry)) {
958962
REISERFS_SB(s)->priv_root = dentry;
959963
d_set_d_op(dentry, &xattr_lookup_poison_ops);
960-
if (d_really_is_positive(dentry))
964+
if (d_really_is_positive(dentry)) {
961965
d_inode(dentry)->i_flags |= S_PRIVATE;
966+
d_inode(dentry)->i_opflags &= ~IOP_XATTR;
967+
}
962968
} else
963969
err = PTR_ERR(dentry);
964970
inode_unlock(d_inode(s->s_root));
@@ -987,7 +993,6 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
987993
}
988994

989995
if (d_really_is_positive(privroot)) {
990-
s->s_xattr = reiserfs_xattr_handlers;
991996
inode_lock(d_inode(privroot));
992997
if (!REISERFS_SB(s)->xattr_root) {
993998
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)