Skip to content

Commit ca0c657

Browse files
committed
ovl: port ovl_rename() to cred guard
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>
1 parent a1da840 commit ca0c657

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

fs/overlayfs/dir.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,6 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
13191319
struct dentry *old, struct inode *newdir,
13201320
struct dentry *new, unsigned int flags)
13211321
{
1322-
const struct cred *old_cred = NULL;
13231322
struct ovl_renamedata ovlrd = {
13241323
.old_parent = old->d_parent,
13251324
.old_dentry = old,
@@ -1332,17 +1331,13 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
13321331
int err;
13331332

13341333
err = ovl_rename_start(&ovlrd, &list);
1335-
if (err)
1336-
goto out;
1337-
1338-
old_cred = ovl_override_creds(old->d_sb);
1339-
1340-
err = ovl_rename_upper(&ovlrd, &list);
1334+
if (!err) {
1335+
with_ovl_creds(old->d_sb)
1336+
err = ovl_rename_upper(&ovlrd, &list);
1337+
ovl_rename_end(&ovlrd);
1338+
}
13411339

1342-
ovl_revert_creds(old_cred);
1343-
ovl_rename_end(&ovlrd);
1344-
out:
1345-
dput(ovlrd->opaquedir);
1340+
dput(ovlrd.opaquedir);
13461341
ovl_cache_free(&list);
13471342
return err;
13481343
}

0 commit comments

Comments
 (0)