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

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

index 27c9c3bc77c68de90f1961c35595076fd1af9aef..efc0ff84b59bdf35ba9f5b35c8e3bbf181e9750b 100644 (file)
@@ -472,7 +472,6 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
        int err;
        struct path realpath;
        const char *acl_name;
-       const struct cred *old_cred;
        struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
        struct dentry *upperdentry = ovl_dentry_upper(dentry);
        struct dentry *realdentry = upperdentry ?: ovl_dentry_lower(dentry);
@@ -486,10 +485,8 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
                struct posix_acl *real_acl;
 
                ovl_path_lower(dentry, &realpath);
-               old_cred = ovl_override_creds(dentry->d_sb);
-               real_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry,
-                                      acl_name);
-               ovl_revert_creds(old_cred);
+               with_ovl_creds(dentry->d_sb)
+                       real_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry, acl_name);
                if (IS_ERR(real_acl)) {
                        err = PTR_ERR(real_acl);
                        goto out;
@@ -509,12 +506,12 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
        if (err)
                goto out;
 
-       old_cred = ovl_override_creds(dentry->d_sb);
-       if (acl)
-               err = ovl_do_set_acl(ofs, realdentry, acl_name, acl);
-       else
-               err = ovl_do_remove_acl(ofs, realdentry, acl_name);
-       ovl_revert_creds(old_cred);
+       with_ovl_creds(dentry->d_sb) {
+               if (acl)
+                       err = ovl_do_set_acl(ofs, realdentry, acl_name, acl);
+               else
+                       err = ovl_do_remove_acl(ofs, realdentry, acl_name);
+       }
        ovl_drop_write(dentry);
 
        /* copy c/mtime */