xattr: constify value argument in vfs_setxattr()
authorChristian Brauner <brauner@kernel.org>
Mon, 29 Aug 2022 12:38:45 +0000 (14:38 +0200)
committerChristian Brauner (Microsoft) <brauner@kernel.org>
Wed, 31 Aug 2022 14:38:07 +0000 (16:38 +0200)
Now that we don't perform translations directly in vfs_setxattr()
anymore we can constify the @value argument in vfs_setxattr(). This also
allows us to remove the hack to cast from a const in ovl_do_setxattr().

Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Reviewed-by: Seth Forshee (DigitalOcean) <sforshee@kernel.org>
fs/overlayfs/overlayfs.h
fs/xattr.c
include/linux/xattr.h

index 87759165d32b6b912ae4223e913b020db57e6d51..ee93c825b06bfe084ffda0a9a65af386c3417712 100644 (file)
@@ -250,7 +250,7 @@ static inline int ovl_do_setxattr(struct ovl_fs *ofs, struct dentry *dentry,
                                  size_t size, int flags)
 {
        int err = vfs_setxattr(ovl_upper_mnt_userns(ofs), dentry, name,
-                              (void *)value, size, flags);
+                              value, size, flags);
 
        pr_debug("setxattr(%pd2, \"%s\", \"%*pE\", %zu, %d) = %i\n",
                 dentry, name, min((int)size, 48), value, size, flags, err);
index 3ac68ec0c0230de60b268d8753cdb5c85c777ec0..74fc8e021ebca1db5d3e9c8f752ce68a7faed35b 100644 (file)
@@ -290,7 +290,7 @@ static inline bool is_posix_acl_xattr(const char *name)
 
 int
 vfs_setxattr(struct user_namespace *mnt_userns, struct dentry *dentry,
-            const char *name, void *value, size_t size, int flags)
+            const char *name, const void *value, size_t size, int flags)
 {
        struct inode *inode = dentry->d_inode;
        struct inode *delegated_inode = NULL;
@@ -298,8 +298,7 @@ vfs_setxattr(struct user_namespace *mnt_userns, struct dentry *dentry,
        int error;
 
        if (size && strcmp(name, XATTR_NAME_CAPS) == 0) {
-               error = cap_convert_nscap(mnt_userns, dentry,
-                                         (const void **)&value, size);
+               error = cap_convert_nscap(mnt_userns, dentry, &value, size);
                if (error < 0)
                        return error;
                size = error;
index 979a9d3e5bfbfc32c8764a5186efb3f8b6968ee8..4c379d23ec6e73b9590fba7c16e1152fb79376fd 100644 (file)
@@ -61,7 +61,7 @@ int __vfs_setxattr_locked(struct user_namespace *, struct dentry *,
                          const char *, const void *, size_t, int,
                          struct inode **);
 int vfs_setxattr(struct user_namespace *, struct dentry *, const char *,
-                void *, size_t, int);
+                const void *, size_t, int);
 int __vfs_removexattr(struct user_namespace *, struct dentry *, const char *);
 int __vfs_removexattr_locked(struct user_namespace *, struct dentry *,
                             const char *, struct inode **);