]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ovl: port ovl_xattr_get() to cred guard
authorChristian Brauner <brauner@kernel.org>
Mon, 17 Nov 2025 09:34:02 +0000 (10:34 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 19 Nov 2025 20:58:24 +0000 (21:58 +0100)
Use the scoped ovl cred guard.

Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-31-b31603935724@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/overlayfs/xattrs.c

index 787df86acb266dad3a2d46780de68f3878f35d76..788182fff3e0eef5c3b809bbbaafc3975be0add4 100644 (file)
@@ -81,15 +81,11 @@ out:
 static int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name,
                         void *value, size_t size)
 {
-       ssize_t res;
-       const struct cred *old_cred;
        struct path realpath;
 
        ovl_i_path_real(inode, &realpath);
-       old_cred = ovl_override_creds(dentry->d_sb);
-       res = vfs_getxattr(mnt_idmap(realpath.mnt), realpath.dentry, name, value, size);
-       ovl_revert_creds(old_cred);
-       return res;
+       with_ovl_creds(dentry->d_sb)
+               return vfs_getxattr(mnt_idmap(realpath.mnt), realpath.dentry, name, value, size);
 }
 
 static bool ovl_can_list(struct super_block *sb, const char *s)