xattr: always us is_posix_acl_xattr() helper
authorChristian Brauner <brauner@kernel.org>
Mon, 19 Sep 2022 09:49:14 +0000 (11:49 +0200)
committerChristian Brauner (Microsoft) <brauner@kernel.org>
Wed, 21 Sep 2022 10:01:29 +0000 (12:01 +0200)
The is_posix_acl_xattr() helper was added in 0c5fd887d2bb ("acl: move
idmapped mount fixup into vfs_{g,s}etxattr()") to remove the open-coded
checks for POSIX ACLs. We missed to update two locations. Switch them to
use the helper.

Cc: Seth Forshee (DigitalOcean) <sforshee@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Reviewed-by: Seth Forshee (DigitalOcean) <sforshee@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xattr.c

index 74fc8e021ebca1db5d3e9c8f752ce68a7faed35b..61107b6bbed29211786d2eda0318499d95f525fe 100644 (file)
@@ -583,9 +583,7 @@ int setxattr_copy(const char __user *name, struct xattr_ctx *ctx)
 static void setxattr_convert(struct user_namespace *mnt_userns,
                             struct dentry *d, struct xattr_ctx *ctx)
 {
-       if (ctx->size &&
-               ((strcmp(ctx->kname->name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
-               (strcmp(ctx->kname->name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0)))
+       if (ctx->size && is_posix_acl_xattr(ctx->kname->name))
                posix_acl_fix_xattr_from_user(ctx->kvalue, ctx->size);
 }
 
@@ -701,8 +699,7 @@ do_getxattr(struct user_namespace *mnt_userns, struct dentry *d,
 
        error = vfs_getxattr(mnt_userns, d, kname, ctx->kvalue, ctx->size);
        if (error > 0) {
-               if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
-                   (strcmp(kname, XATTR_NAME_POSIX_ACL_DEFAULT) == 0))
+               if (is_posix_acl_xattr(kname))
                        posix_acl_fix_xattr_to_user(ctx->kvalue, error);
                if (ctx->size && copy_to_user(ctx->value, ctx->kvalue, error))
                        error = -EFAULT;