Skip to content

Commit 14d35fd

Browse files
committed
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>
1 parent ca0c657 commit 14d35fd

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

fs/overlayfs/file.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in,
529529
{
530530
struct inode *inode_out = file_inode(file_out);
531531
struct file *realfile_in, *realfile_out;
532-
const struct cred *old_cred;
533532
loff_t ret;
534533

535534
inode_lock(inode_out);
@@ -551,25 +550,25 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in,
551550
if (IS_ERR(realfile_in))
552551
goto out_unlock;
553552

554-
old_cred = ovl_override_creds(file_inode(file_out)->i_sb);
555-
switch (op) {
556-
case OVL_COPY:
557-
ret = vfs_copy_file_range(realfile_in, pos_in,
558-
realfile_out, pos_out, len, flags);
559-
break;
560-
561-
case OVL_CLONE:
562-
ret = vfs_clone_file_range(realfile_in, pos_in,
563-
realfile_out, pos_out, len, flags);
564-
break;
565-
566-
case OVL_DEDUPE:
567-
ret = vfs_dedupe_file_range_one(realfile_in, pos_in,
568-
realfile_out, pos_out, len,
569-
flags);
570-
break;
553+
with_ovl_creds(file_inode(file_out)->i_sb) {
554+
switch (op) {
555+
case OVL_COPY:
556+
ret = vfs_copy_file_range(realfile_in, pos_in,
557+
realfile_out, pos_out, len, flags);
558+
break;
559+
560+
case OVL_CLONE:
561+
ret = vfs_clone_file_range(realfile_in, pos_in,
562+
realfile_out, pos_out, len, flags);
563+
break;
564+
565+
case OVL_DEDUPE:
566+
ret = vfs_dedupe_file_range_one(realfile_in, pos_in,
567+
realfile_out, pos_out, len,
568+
flags);
569+
break;
570+
}
571571
}
572-
ovl_revert_creds(old_cred);
573572

574573
/* Update size */
575574
ovl_file_modified(file_out);

0 commit comments

Comments
 (0)