]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ovl: port ovl_copy_up_tmpfile() to cred guard
authorChristian Brauner <brauner@kernel.org>
Fri, 14 Nov 2025 22:45:25 +0000 (23:45 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 19 Nov 2025 20:58:27 +0000 (21:58 +0100)
Remove the complicated struct ovl_cu_creds dance and use our new copy up
cred guard.

Link: https://patch.msgid.link/20251114-work-ovl-cred-guard-copyup-v1-4-ea3fb15cf427@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/overlayfs/copy_up.c

index 2ec7d3ce1f0cc063503b9fb396406ccd3d56000a..71e222e5044d28ceee158a92931b4d0294d318ba 100644 (file)
@@ -883,17 +883,17 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c)
        struct inode *udir = d_inode(c->destdir);
        struct dentry *temp, *upper;
        struct file *tmpfile;
-       struct ovl_cu_creds cc;
        int err;
 
-       err = ovl_prep_cu_creds(c->dentry, &cc);
-       if (err)
-               return err;
+       scoped_class(copy_up_creds, copy_up_creds, c->dentry) {
+               if (IS_ERR(copy_up_creds))
+                       return PTR_ERR(copy_up_creds);
+
+               ovl_start_write(c->dentry);
+               tmpfile = ovl_do_tmpfile(ofs, c->workdir, c->stat.mode);
+               ovl_end_write(c->dentry);
+       }
 
-       ovl_start_write(c->dentry);
-       tmpfile = ovl_do_tmpfile(ofs, c->workdir, c->stat.mode);
-       ovl_end_write(c->dentry);
-       ovl_revert_cu_creds(&cc);
        if (IS_ERR(tmpfile))
                return PTR_ERR(tmpfile);