]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ovl: port ovl_rename() to cred guard
authorChristian Brauner <brauner@kernel.org>
Wed, 19 Nov 2025 19:53:17 +0000 (20:53 +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-35-b31603935724@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/overlayfs/dir.c

index ab1fdd7ccb2eb7d4656eb48483e9b40bf67871ac..8e8ede6a1217ff8df4d9ea6b97237adecafdff59 100644 (file)
@@ -1319,7 +1319,6 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
                      struct dentry *old, struct inode *newdir,
                      struct dentry *new, unsigned int flags)
 {
-       const struct cred *old_cred = NULL;
        struct ovl_renamedata ovlrd = {
                .old_parent             = old->d_parent,
                .old_dentry             = old,
@@ -1332,17 +1331,13 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
        int err;
 
        err = ovl_rename_start(&ovlrd, &list);
-       if (err)
-               goto out;
-
-       old_cred = ovl_override_creds(old->d_sb);
-
-       err = ovl_rename_upper(&ovlrd, &list);
+       if (!err) {
+               with_ovl_creds(old->d_sb)
+                       err = ovl_rename_upper(&ovlrd, &list);
+               ovl_rename_end(&ovlrd);
+       }
 
-       ovl_revert_creds(old_cred);
-       ovl_rename_end(&ovlrd);
-out:
-       dput(ovlrd->opaquedir);
+       dput(ovlrd.opaquedir);
        ovl_cache_free(&list);
        return err;
 }