Commit 60e4cf67 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Jan Kara

reiserfs: fix extended attributes on the root directory

Since commit d0a5b995 (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: d0a5b995 ("vfs: Add IOP_XATTR inode operations flag")
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent acd1f046
...@@ -2097,6 +2097,15 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, ...@@ -2097,6 +2097,15 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
goto out_inserted_sd; goto out_inserted_sd;
} }
/*
* Mark it private if we're creating the privroot
* or something under it.
*/
if (IS_PRIVATE(dir) || dentry == REISERFS_SB(sb)->priv_root) {
inode->i_flags |= S_PRIVATE;
inode->i_opflags &= ~IOP_XATTR;
}
if (reiserfs_posixacl(inode->i_sb)) { if (reiserfs_posixacl(inode->i_sb)) {
reiserfs_write_unlock(inode->i_sb); reiserfs_write_unlock(inode->i_sb);
retval = reiserfs_inherit_default_acl(th, dir, dentry, inode); retval = reiserfs_inherit_default_acl(th, dir, dentry, inode);
...@@ -2111,8 +2120,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, ...@@ -2111,8 +2120,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
reiserfs_warning(inode->i_sb, "jdm-13090", reiserfs_warning(inode->i_sb, "jdm-13090",
"ACLs aren't enabled in the fs, " "ACLs aren't enabled in the fs, "
"but vfs thinks they are!"); "but vfs thinks they are!");
} else if (IS_PRIVATE(dir)) }
inode->i_flags |= S_PRIVATE;
if (security->name) { if (security->name) {
reiserfs_write_unlock(inode->i_sb); reiserfs_write_unlock(inode->i_sb);
......
...@@ -377,10 +377,13 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -377,10 +377,13 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
/* /*
* Propagate the private flag so we know we're * Propagate the private flag so we know we're
* in the priv tree * in the priv tree. Also clear IOP_XATTR
* since we don't have xattrs on xattr files.
*/ */
if (IS_PRIVATE(dir)) if (IS_PRIVATE(dir)) {
inode->i_flags |= S_PRIVATE; inode->i_flags |= S_PRIVATE;
inode->i_opflags &= ~IOP_XATTR;
}
} }
reiserfs_write_unlock(dir->i_sb); reiserfs_write_unlock(dir->i_sb);
if (retval == IO_ERROR) { if (retval == IO_ERROR) {
......
...@@ -1168,6 +1168,8 @@ static inline int bmap_would_wrap(unsigned bmap_nr) ...@@ -1168,6 +1168,8 @@ static inline int bmap_would_wrap(unsigned bmap_nr)
return bmap_nr > ((1LL << 16) - 1); return bmap_nr > ((1LL << 16) - 1);
} }
extern const struct xattr_handler *reiserfs_xattr_handlers[];
/* /*
* this says about version of key of all items (but stat data) the * this says about version of key of all items (but stat data) the
* object consists of * object consists of
......
...@@ -2049,6 +2049,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) ...@@ -2049,6 +2049,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
if (replay_only(s)) if (replay_only(s))
goto error_unlocked; goto error_unlocked;
s->s_xattr = reiserfs_xattr_handlers;
if (bdev_read_only(s->s_bdev) && !sb_rdonly(s)) { if (bdev_read_only(s->s_bdev) && !sb_rdonly(s)) {
SWARN(silent, s, "clm-7000", SWARN(silent, s, "clm-7000",
"Detected readonly device, marking FS readonly"); "Detected readonly device, marking FS readonly");
......
...@@ -122,13 +122,13 @@ static struct dentry *open_xa_root(struct super_block *sb, int flags) ...@@ -122,13 +122,13 @@ static struct dentry *open_xa_root(struct super_block *sb, int flags)
struct dentry *xaroot; struct dentry *xaroot;
if (d_really_is_negative(privroot)) if (d_really_is_negative(privroot))
return ERR_PTR(-ENODATA); return ERR_PTR(-EOPNOTSUPP);
inode_lock_nested(d_inode(privroot), I_MUTEX_XATTR); inode_lock_nested(d_inode(privroot), I_MUTEX_XATTR);
xaroot = dget(REISERFS_SB(sb)->xattr_root); xaroot = dget(REISERFS_SB(sb)->xattr_root);
if (!xaroot) if (!xaroot)
xaroot = ERR_PTR(-ENODATA); xaroot = ERR_PTR(-EOPNOTSUPP);
else if (d_really_is_negative(xaroot)) { else if (d_really_is_negative(xaroot)) {
int err = -ENODATA; int err = -ENODATA;
...@@ -619,6 +619,10 @@ int reiserfs_xattr_set(struct inode *inode, const char *name, ...@@ -619,6 +619,10 @@ int reiserfs_xattr_set(struct inode *inode, const char *name,
int error, error2; int error, error2;
size_t jbegin_count = reiserfs_xattr_nblocks(inode, buffer_size); size_t jbegin_count = reiserfs_xattr_nblocks(inode, buffer_size);
/* Check before we start a transaction and then do nothing. */
if (!d_really_is_positive(REISERFS_SB(inode->i_sb)->priv_root))
return -EOPNOTSUPP;
if (!(flags & XATTR_REPLACE)) if (!(flags & XATTR_REPLACE))
jbegin_count += reiserfs_xattr_jcreate_nblocks(inode); jbegin_count += reiserfs_xattr_jcreate_nblocks(inode);
...@@ -841,8 +845,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size) ...@@ -841,8 +845,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
if (d_really_is_negative(dentry)) if (d_really_is_negative(dentry))
return -EINVAL; return -EINVAL;
if (!dentry->d_sb->s_xattr || if (get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
return -EOPNOTSUPP; return -EOPNOTSUPP;
dir = open_xa_dir(d_inode(dentry), XATTR_REPLACE); dir = open_xa_dir(d_inode(dentry), XATTR_REPLACE);
...@@ -882,6 +885,7 @@ static int create_privroot(struct dentry *dentry) ...@@ -882,6 +885,7 @@ static int create_privroot(struct dentry *dentry)
} }
d_inode(dentry)->i_flags |= S_PRIVATE; d_inode(dentry)->i_flags |= S_PRIVATE;
d_inode(dentry)->i_opflags &= ~IOP_XATTR;
reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr " reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
"storage.\n", PRIVROOT_NAME); "storage.\n", PRIVROOT_NAME);
...@@ -895,7 +899,7 @@ static int create_privroot(struct dentry *dentry) { return 0; } ...@@ -895,7 +899,7 @@ static int create_privroot(struct dentry *dentry) { return 0; }
#endif #endif
/* Actual operations that are exported to VFS-land */ /* Actual operations that are exported to VFS-land */
static const struct xattr_handler *reiserfs_xattr_handlers[] = { const struct xattr_handler *reiserfs_xattr_handlers[] = {
#ifdef CONFIG_REISERFS_FS_XATTR #ifdef CONFIG_REISERFS_FS_XATTR
&reiserfs_xattr_user_handler, &reiserfs_xattr_user_handler,
&reiserfs_xattr_trusted_handler, &reiserfs_xattr_trusted_handler,
...@@ -966,8 +970,10 @@ int reiserfs_lookup_privroot(struct super_block *s) ...@@ -966,8 +970,10 @@ int reiserfs_lookup_privroot(struct super_block *s)
if (!IS_ERR(dentry)) { if (!IS_ERR(dentry)) {
REISERFS_SB(s)->priv_root = dentry; REISERFS_SB(s)->priv_root = dentry;
d_set_d_op(dentry, &xattr_lookup_poison_ops); d_set_d_op(dentry, &xattr_lookup_poison_ops);
if (d_really_is_positive(dentry)) if (d_really_is_positive(dentry)) {
d_inode(dentry)->i_flags |= S_PRIVATE; d_inode(dentry)->i_flags |= S_PRIVATE;
d_inode(dentry)->i_opflags &= ~IOP_XATTR;
}
} else } else
err = PTR_ERR(dentry); err = PTR_ERR(dentry);
inode_unlock(d_inode(s->s_root)); inode_unlock(d_inode(s->s_root));
...@@ -996,7 +1002,6 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags) ...@@ -996,7 +1002,6 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
} }
if (d_really_is_positive(privroot)) { if (d_really_is_positive(privroot)) {
s->s_xattr = reiserfs_xattr_handlers;
inode_lock(d_inode(privroot)); inode_lock(d_inode(privroot));
if (!REISERFS_SB(s)->xattr_root) { if (!REISERFS_SB(s)->xattr_root) {
struct dentry *dentry; struct dentry *dentry;
......
...@@ -320,10 +320,8 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, ...@@ -320,10 +320,8 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
* would be useless since permissions are ignored, and a pain because * would be useless since permissions are ignored, and a pain because
* it introduces locking cycles * it introduces locking cycles
*/ */
if (IS_PRIVATE(dir)) { if (IS_PRIVATE(inode))
inode->i_flags |= S_PRIVATE;
goto apply_umask; goto apply_umask;
}
err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment