]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ovl: Switch to generic_removexattr
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 22 Aug 2016 15:22:11 +0000 (17:22 +0200)
committerShan Hai <shan.hai@oracle.com>
Fri, 4 Aug 2017 05:53:47 +0000 (13:53 +0800)
Commit d837a49bd57f ("ovl: fix POSIX ACL setting") switches from
iop->setxattr from ovl_setxattr to generic_setxattr, so switch from
ovl_removexattr to generic_removexattr as well.  As far as permission
checking goes, the same rules should apply in either case.

While doing that, rename ovl_setxattr to ovl_xattr_set to indicate that
this is not an iop->setxattr implementation and remove the unused inode
argument.

Move ovl_other_xattr_set above ovl_own_xattr_set so that they match the
order of handlers in ovl_xattr_handlers.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Fixes: d837a49bd57f ("ovl: fix POSIX ACL setting")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Shan Hai <shan.hai@oracle.com>
Orabug: 26401569

(backport upstream commit 0e585ccc13b3edbb187fb4f1b7cc9397f17d64a9)

Signed-off-by: Shan Hai <shan.hai@oracle.com>
Reviewed-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
fs/overlayfs/dir.c
fs/overlayfs/inode.c
fs/overlayfs/overlayfs.h
fs/overlayfs/super.c

index f4acef9dc1da13372f4fc29e99370d3cb2d3bd7c..0149221bba43073908c165851eec1123a2e3cebc 100644 (file)
@@ -960,7 +960,7 @@ const struct inode_operations ovl_dir_inode_operations = {
        .setxattr       = generic_setxattr,
        .getxattr       = ovl_getxattr,
        .listxattr      = ovl_listxattr,
-       .removexattr    = ovl_removexattr,
+       .removexattr    = generic_removexattr,
        .get_acl        = ovl_get_acl,
        .update_time    = ovl_update_time,
 };
index 23a6f2f30b39e7a31349933eb0f0dcfca7abec56..7907411d23a6faa6cadb12ae8bf9f9a58829b85e 100644 (file)
@@ -217,24 +217,38 @@ static bool ovl_is_private_xattr(const char *name)
                       sizeof(OVL_XATTR_PREFIX) - 1) == 0;
 }
 
-int ovl_setxattr(struct dentry *dentry, const char *name,
-                const void *value, size_t size, int flags)
+int ovl_xattr_set(struct dentry *dentry, const char *name, const void *value,
+                 size_t size, int flags)
 {
        int err;
-       struct dentry *upperdentry;
+       struct path realpath;
+       enum ovl_path_type type = ovl_path_real(dentry, &realpath);
        const struct cred *old_cred;
 
        err = ovl_want_write(dentry);
        if (err)
                goto out;
 
+       if (!value && !OVL_TYPE_UPPER(type)) {
+               err = vfs_getxattr(realpath.dentry, name, NULL, 0);
+               if (err < 0)
+                       goto out_drop_write;
+       }
+
        err = ovl_copy_up(dentry);
        if (err)
                goto out_drop_write;
 
-       upperdentry = ovl_dentry_upper(dentry);
+       if (!OVL_TYPE_UPPER(type))
+               ovl_path_upper(dentry, &realpath);
+
        old_cred = ovl_override_creds(dentry->d_sb);
-       err = vfs_setxattr(upperdentry, name, value, size, flags);
+       if (value)
+               err = vfs_setxattr(realpath.dentry, name, value, size, flags);
+       else {
+               WARN_ON(flags != XATTR_REPLACE);
+               err = vfs_removexattr(realpath.dentry, name);
+       }
        revert_creds(old_cred);
 
 out_drop_write:
@@ -290,44 +304,6 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
        return res;
 }
 
-int ovl_removexattr(struct dentry *dentry, const char *name)
-{
-       int err;
-       struct path realpath;
-       enum ovl_path_type type = ovl_path_real(dentry, &realpath);
-       const struct cred *old_cred;
-
-       err = ovl_want_write(dentry);
-       if (err)
-               goto out;
-
-       err = -ENODATA;
-       if (ovl_is_private_xattr(name))
-               goto out_drop_write;
-
-       if (!OVL_TYPE_UPPER(type)) {
-               old_cred = ovl_override_creds(dentry->d_sb);
-               err = vfs_getxattr(realpath.dentry, name, NULL, 0);
-               revert_creds(old_cred);
-               if (err < 0)
-                       goto out_drop_write;
-
-               err = ovl_copy_up(dentry);
-               if (err)
-                       goto out_drop_write;
-
-               ovl_path_upper(dentry, &realpath);
-       }
-
-       old_cred = ovl_override_creds(dentry->d_sb);
-       err = vfs_removexattr(realpath.dentry, name);
-       revert_creds(old_cred);
-out_drop_write:
-       ovl_drop_write(dentry);
-out:
-       return err;
-}
-
 struct posix_acl *ovl_get_acl(struct inode *inode, int type)
 {
        struct inode *realinode = ovl_inode_real(inode, NULL);
@@ -424,7 +400,7 @@ static const struct inode_operations ovl_file_inode_operations = {
        .setxattr       = generic_setxattr,
        .getxattr       = ovl_getxattr,
        .listxattr      = ovl_listxattr,
-       .removexattr    = ovl_removexattr,
+       .removexattr    = generic_removexattr,
        .get_acl        = ovl_get_acl,
        .update_time    = ovl_update_time,
 };
@@ -438,7 +414,7 @@ static const struct inode_operations ovl_symlink_inode_operations = {
        .setxattr       = generic_setxattr,
        .getxattr       = ovl_getxattr,
        .listxattr      = ovl_listxattr,
-       .removexattr    = ovl_removexattr,
+       .removexattr    = generic_removexattr,
        .update_time    = ovl_update_time,
 };
 
index febcfb6b989e5cbbe1a9a32c857b5272db57a8c7..f4784b824bba6a61af62e33ef397093ee97d7043 100644 (file)
@@ -183,12 +183,11 @@ int ovl_check_d_type_supported(struct path *realpath);
 /* inode.c */
 int ovl_setattr(struct dentry *dentry, struct iattr *attr);
 int ovl_permission(struct inode *inode, int mask);
-int ovl_setxattr(struct dentry *dentry, const char *name,
-                const void *value, size_t size, int flags);
+int ovl_xattr_set(struct dentry *dentry, const char *name, const void *value,
+                 size_t size, int flags);
 ssize_t ovl_getxattr(struct dentry *dentry, const char *name,
                     void *value, size_t size);
 ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
-int ovl_removexattr(struct dentry *dentry, const char *name);
 struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags);
 struct posix_acl *ovl_get_acl(struct inode *inode, int type);
 int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags);
index 72ef31afbdfcb8d60437c8ea44da1e3a30dd29cc..82455d52f8fe90e2a09b218152460775f99f6277 100644 (file)
@@ -893,20 +893,13 @@ static int ovl_posix_acl_xattr_set(struct dentry *dentry, const char *name,
 
        posix_acl_release(acl);
 
-       return ovl_setxattr(dentry, name, value, size, flags);
+       return ovl_xattr_set(dentry, name, value, size, flags);
 
 out_acl_release:
        posix_acl_release(acl);
        return err;
 }
 
-static int ovl_other_xattr_set(struct dentry *dentry, const char *name,
-                              const void *value, size_t size, int flags,
-                              int handler_flags)
-{
-       return ovl_setxattr(dentry, name, value, size, flags);
-}
-
 static int ovl_own_xattr_set(struct dentry *dentry, const char *name,
                             const void *value, size_t size, int flags,
                             int handler_flags)
@@ -914,6 +907,13 @@ static int ovl_own_xattr_set(struct dentry *dentry, const char *name,
        return -EPERM;
 }
 
+static int ovl_other_xattr_set(struct dentry *dentry, const char *name,
+                              const void *value, size_t size, int flags,
+                              int handler_flags)
+{
+       return ovl_xattr_set(dentry, name, value, size, flags);
+}
+
 static const struct xattr_handler __maybe_unused
 ovl_posix_acl_access_xattr_handler = {
        .prefix = XATTR_NAME_POSIX_ACL_ACCESS,