Skip to content

Commit

Permalink
ovl: remove privs in ovl_copyfile()
Browse files Browse the repository at this point in the history
[ Upstream commit b306e90 ]

Underlying fs doesn't remove privs because copy_range/remap_range are
called with privileged mounter credentials.

This fixes some failures in fstest generic/673.

Fixes: 8ede205 ("ovl: add reflink/copyfile/dedup support")
Acked-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
amir73il authored and gregkh committed Dec 31, 2022
1 parent 9636e70 commit 5dc34f9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions fs/overlayfs/file.c
Expand Up @@ -566,14 +566,23 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in,
const struct cred *old_cred;
loff_t ret;

inode_lock(inode_out);
if (op != OVL_DEDUPE) {
/* Update mode */
ovl_copyattr(inode_out);
ret = file_remove_privs(file_out);
if (ret)
goto out_unlock;
}

ret = ovl_real_fdget(file_out, &real_out);
if (ret)
return ret;
goto out_unlock;

ret = ovl_real_fdget(file_in, &real_in);
if (ret) {
fdput(real_out);
return ret;
goto out_unlock;
}

old_cred = ovl_override_creds(file_inode(file_out)->i_sb);
Expand Down Expand Up @@ -602,6 +611,9 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in,
fdput(real_in);
fdput(real_out);

out_unlock:
inode_unlock(inode_out);

return ret;
}

Expand Down

0 comments on commit 5dc34f9

Please sign in to comment.