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>
This commit is contained in:
Christian Brauner 2025-11-19 20:53:17 +01:00
parent a1da840198
commit ca0c657f25
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
1 changed files with 6 additions and 11 deletions

View 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;
if (!err) {
with_ovl_creds(old->d_sb)
err = ovl_rename_upper(&ovlrd, &list);
ovl_rename_end(&ovlrd);
}
old_cred = ovl_override_creds(old->d_sb);
err = ovl_rename_upper(&ovlrd, &list);
ovl_revert_creds(old_cred);
ovl_rename_end(&ovlrd);
out:
dput(ovlrd->opaquedir);
dput(ovlrd.opaquedir);
ovl_cache_free(&list);
return err;
}