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

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

index 170f8dbea4ad39a07e6dcc1d8740c5db2fdfb1f9..e51c53bbf1b893b94a7acc1490c5c4450173e81c 100644 (file)
@@ -907,7 +907,6 @@ static void ovl_drop_nlink(struct dentry *dentry)
 static int ovl_do_remove(struct dentry *dentry, bool is_dir)
 {
        int err;
-       const struct cred *old_cred;
        bool lower_positive = ovl_lower_positive(dentry);
        LIST_HEAD(list);
 
@@ -926,12 +925,12 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir)
        if (err)
                goto out;
 
-       old_cred = ovl_override_creds(dentry->d_sb);
-       if (!lower_positive)
-               err = ovl_remove_upper(dentry, is_dir, &list);
-       else
-               err = ovl_remove_and_whiteout(dentry, &list);
-       ovl_revert_creds(old_cred);
+       with_ovl_creds(dentry->d_sb) {
+               if (!lower_positive)
+                       err = ovl_remove_upper(dentry, is_dir, &list);
+               else
+                       err = ovl_remove_and_whiteout(dentry, &list);
+       }
        if (!err) {
                if (is_dir)
                        clear_nlink(dentry->d_inode);