]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard
authorChristian Brauner <brauner@kernel.org>
Mon, 17 Nov 2025 09:34:42 +0000 (10:34 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 19 Nov 2025 20:58:26 +0000 (21:58 +0100)
This clearly indicates the double-credential override and makes the code
a lot easier to grasp with one glance.

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

index b21db1eb34bc255d1bb170f4638477e190f6ba65..6cfa7857b3524dd2aab4782e5955a4f6bbc44373 100644 (file)
@@ -664,10 +664,9 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
                              struct ovl_cattr *attr, bool origin)
 {
        int err;
-       const struct cred *new_cred __free(put_cred) = NULL;
        struct dentry *parent = dentry->d_parent;
 
-       scoped_class(override_creds_ovl, old_cred, dentry->d_sb) {
+       with_ovl_creds(dentry->d_sb) {
                /*
                 * When linking a file with copy up origin into a new parent, mark the
                 * new parent dir "impure".
@@ -695,11 +694,11 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
                if (attr->hardlink)
                        return ovl_create_handle_whiteouts(dentry, inode, attr);
 
-               new_cred = ovl_setup_cred_for_create(dentry, inode, attr->mode, old_cred);
-               if (IS_ERR(new_cred))
-                       return PTR_ERR(new_cred);
-
-               return ovl_create_handle_whiteouts(dentry, inode, attr);
+               scoped_class(ovl_override_creator_creds, cred, dentry, inode, attr->mode) {
+                       if (IS_ERR(cred))
+                               return PTR_ERR(cred);
+                       return ovl_create_handle_whiteouts(dentry, inode, attr);
+               }
        }
        return err;
 }