Commit 7debbf01 authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Dave Chinner

xfs: update ctime and remove suid before cloning files

Before cloning into a file, update the ctime and remove sensitive
attributes like suid, just like we'd do for a regular file write.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 410fdc72
...@@ -1264,6 +1264,7 @@ xfs_reflink_zero_posteof( ...@@ -1264,6 +1264,7 @@ xfs_reflink_zero_posteof(
* Prepare two files for range cloning. Upon a successful return both inodes * Prepare two files for range cloning. Upon a successful return both inodes
* will have the iolock and mmaplock held, the page cache of the out file * will have the iolock and mmaplock held, the page cache of the out file
* will be truncated, and any leases on the out file will have been broken. * will be truncated, and any leases on the out file will have been broken.
* This function borrows heavily from xfs_file_aio_write_checks.
*/ */
STATIC int STATIC int
xfs_reflink_remap_prep( xfs_reflink_remap_prep(
...@@ -1327,6 +1328,30 @@ xfs_reflink_remap_prep( ...@@ -1327,6 +1328,30 @@ xfs_reflink_remap_prep(
/* Zap any page cache for the destination file's range. */ /* Zap any page cache for the destination file's range. */
truncate_inode_pages_range(&inode_out->i_data, pos_out, truncate_inode_pages_range(&inode_out->i_data, pos_out,
PAGE_ALIGN(pos_out + *len) - 1); PAGE_ALIGN(pos_out + *len) - 1);
/* If we're altering the file contents... */
if (!is_dedupe) {
/*
* ...update the timestamps (which will grab the ilock again
* from xfs_fs_dirty_inode, so we have to call it before we
* take the ilock).
*/
if (!(file_out->f_mode & FMODE_NOCMTIME)) {
ret = file_update_time(file_out);
if (ret)
goto out_unlock;
}
/*
* ...clear the security bits if the process is not being run
* by root. This keeps people from modifying setuid and setgid
* binaries.
*/
ret = file_remove_privs(file_out);
if (ret)
goto out_unlock;
}
return 1; return 1;
out_unlock: out_unlock:
xfs_reflink_remap_unlock(file_in, file_out); xfs_reflink_remap_unlock(file_in, file_out);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment