mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-17 01:34:00 +08:00
reiserfs: fix extended attributes on the root directory
Since commitd0a5b995a3
(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:d0a5b995a3
("vfs: Add IOP_XATTR inode operations flag") Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
acd1f04679
commit
60e4cf67a5
@ -2097,6 +2097,15 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
|
||||
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)) {
|
||||
reiserfs_write_unlock(inode->i_sb);
|
||||
retval = reiserfs_inherit_default_acl(th, dir, dentry, inode);
|
||||
@ -2111,8 +2120,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
|
||||
reiserfs_warning(inode->i_sb, "jdm-13090",
|
||||
"ACLs aren't enabled in the fs, "
|
||||
"but vfs thinks they are!");
|
||||
} else if (IS_PRIVATE(dir))
|
||||
inode->i_flags |= S_PRIVATE;
|
||||
}
|
||||
|
||||
if (security->name) {
|
||||
reiserfs_write_unlock(inode->i_sb);
|
||||
|
@ -377,10 +377,13 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
|
||||
|
||||
/*
|
||||
* 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_opflags &= ~IOP_XATTR;
|
||||
}
|
||||
}
|
||||
reiserfs_write_unlock(dir->i_sb);
|
||||
if (retval == IO_ERROR) {
|
||||
|
@ -1168,6 +1168,8 @@ static inline int bmap_would_wrap(unsigned bmap_nr)
|
||||
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
|
||||
* object consists of
|
||||
|
@ -2049,6 +2049,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
|
||||
if (replay_only(s))
|
||||
goto error_unlocked;
|
||||
|
||||
s->s_xattr = reiserfs_xattr_handlers;
|
||||
|
||||
if (bdev_read_only(s->s_bdev) && !sb_rdonly(s)) {
|
||||
SWARN(silent, s, "clm-7000",
|
||||
"Detected readonly device, marking FS readonly");
|
||||
|
@ -122,13 +122,13 @@ static struct dentry *open_xa_root(struct super_block *sb, int flags)
|
||||
struct dentry *xaroot;
|
||||
|
||||
if (d_really_is_negative(privroot))
|
||||
return ERR_PTR(-ENODATA);
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
inode_lock_nested(d_inode(privroot), I_MUTEX_XATTR);
|
||||
|
||||
xaroot = dget(REISERFS_SB(sb)->xattr_root);
|
||||
if (!xaroot)
|
||||
xaroot = ERR_PTR(-ENODATA);
|
||||
xaroot = ERR_PTR(-EOPNOTSUPP);
|
||||
else if (d_really_is_negative(xaroot)) {
|
||||
int err = -ENODATA;
|
||||
|
||||
@ -619,6 +619,10 @@ int reiserfs_xattr_set(struct inode *inode, const char *name,
|
||||
int error, error2;
|
||||
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))
|
||||
jbegin_count += reiserfs_xattr_jcreate_nblocks(inode);
|
||||
|
||||
@ -841,8 +845,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
|
||||
if (d_really_is_negative(dentry))
|
||||
return -EINVAL;
|
||||
|
||||
if (!dentry->d_sb->s_xattr ||
|
||||
get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
|
||||
if (get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
dir = open_xa_dir(d_inode(dentry), XATTR_REPLACE);
|
||||
@ -882,6 +885,7 @@ static int create_privroot(struct dentry *dentry)
|
||||
}
|
||||
|
||||
d_inode(dentry)->i_flags |= S_PRIVATE;
|
||||
d_inode(dentry)->i_opflags &= ~IOP_XATTR;
|
||||
reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
|
||||
"storage.\n", PRIVROOT_NAME);
|
||||
|
||||
@ -895,7 +899,7 @@ static int create_privroot(struct dentry *dentry) { return 0; }
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
&reiserfs_xattr_user_handler,
|
||||
&reiserfs_xattr_trusted_handler,
|
||||
@ -966,8 +970,10 @@ int reiserfs_lookup_privroot(struct super_block *s)
|
||||
if (!IS_ERR(dentry)) {
|
||||
REISERFS_SB(s)->priv_root = dentry;
|
||||
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_opflags &= ~IOP_XATTR;
|
||||
}
|
||||
} else
|
||||
err = PTR_ERR(dentry);
|
||||
inode_unlock(d_inode(s->s_root));
|
||||
@ -996,7 +1002,6 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
|
||||
}
|
||||
|
||||
if (d_really_is_positive(privroot)) {
|
||||
s->s_xattr = reiserfs_xattr_handlers;
|
||||
inode_lock(d_inode(privroot));
|
||||
if (!REISERFS_SB(s)->xattr_root) {
|
||||
struct dentry *dentry;
|
||||
|
@ -320,10 +320,8 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
|
||||
* would be useless since permissions are ignored, and a pain because
|
||||
* it introduces locking cycles
|
||||
*/
|
||||
if (IS_PRIVATE(dir)) {
|
||||
inode->i_flags |= S_PRIVATE;
|
||||
if (IS_PRIVATE(inode))
|
||||
goto apply_umask;
|
||||
}
|
||||
|
||||
err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
|
||||
if (err)
|
||||
|
Loading…
Reference in New Issue
Block a user