ovl: port ovl_copyfile() to cred guard

Use the scoped ovl cred guard.

Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-36-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-17 10:34:07 +01:00
parent ca0c657f25
commit 14d35fda5b
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
1 changed files with 16 additions and 17 deletions

View File

@ -529,7 +529,6 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in,
{
struct inode *inode_out = file_inode(file_out);
struct file *realfile_in, *realfile_out;
const struct cred *old_cred;
loff_t ret;
inode_lock(inode_out);
@ -551,7 +550,7 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in,
if (IS_ERR(realfile_in))
goto out_unlock;
old_cred = ovl_override_creds(file_inode(file_out)->i_sb);
with_ovl_creds(file_inode(file_out)->i_sb) {
switch (op) {
case OVL_COPY:
ret = vfs_copy_file_range(realfile_in, pos_in,
@ -569,7 +568,7 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in,
flags);
break;
}
ovl_revert_creds(old_cred);
}
/* Update size */
ovl_file_modified(file_out);