mirror of https://github.com/torvalds/linux.git
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:
parent
ca0c657f25
commit
14d35fda5b
|
|
@ -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 inode *inode_out = file_inode(file_out);
|
||||||
struct file *realfile_in, *realfile_out;
|
struct file *realfile_in, *realfile_out;
|
||||||
const struct cred *old_cred;
|
|
||||||
loff_t ret;
|
loff_t ret;
|
||||||
|
|
||||||
inode_lock(inode_out);
|
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))
|
if (IS_ERR(realfile_in))
|
||||||
goto out_unlock;
|
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) {
|
switch (op) {
|
||||||
case OVL_COPY:
|
case OVL_COPY:
|
||||||
ret = vfs_copy_file_range(realfile_in, pos_in,
|
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);
|
flags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ovl_revert_creds(old_cred);
|
}
|
||||||
|
|
||||||
/* Update size */
|
/* Update size */
|
||||||
ovl_file_modified(file_out);
|
ovl_file_modified(file_out);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue