diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2018-10-05 05:05:41 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2018-10-05 05:05:41 -0400 |
commit | 7debbf015f580693680f3d2a3cef0cf99dcef688 (patch) | |
tree | 2eb677c3e75003c186aeb04b3d02017db1139117 /fs/xfs | |
parent | 410fdc72b05afabef3afb51167085799dcc7b3cf (diff) |
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: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_reflink.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index f135748d8282..59da9708e9c1 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c | |||
@@ -1264,6 +1264,7 @@ xfs_reflink_zero_posteof( | |||
1264 | * Prepare two files for range cloning. Upon a successful return both inodes | 1264 | * Prepare two files for range cloning. Upon a successful return both inodes |
1265 | * will have the iolock and mmaplock held, the page cache of the out file | 1265 | * will have the iolock and mmaplock held, the page cache of the out file |
1266 | * will be truncated, and any leases on the out file will have been broken. | 1266 | * will be truncated, and any leases on the out file will have been broken. |
1267 | * This function borrows heavily from xfs_file_aio_write_checks. | ||
1267 | */ | 1268 | */ |
1268 | STATIC int | 1269 | STATIC int |
1269 | xfs_reflink_remap_prep( | 1270 | xfs_reflink_remap_prep( |
@@ -1327,6 +1328,30 @@ xfs_reflink_remap_prep( | |||
1327 | /* Zap any page cache for the destination file's range. */ | 1328 | /* Zap any page cache for the destination file's range. */ |
1328 | truncate_inode_pages_range(&inode_out->i_data, pos_out, | 1329 | truncate_inode_pages_range(&inode_out->i_data, pos_out, |
1329 | PAGE_ALIGN(pos_out + *len) - 1); | 1330 | PAGE_ALIGN(pos_out + *len) - 1); |
1331 | |||
1332 | /* If we're altering the file contents... */ | ||
1333 | if (!is_dedupe) { | ||
1334 | /* | ||
1335 | * ...update the timestamps (which will grab the ilock again | ||
1336 | * from xfs_fs_dirty_inode, so we have to call it before we | ||
1337 | * take the ilock). | ||
1338 | */ | ||
1339 | if (!(file_out->f_mode & FMODE_NOCMTIME)) { | ||
1340 | ret = file_update_time(file_out); | ||
1341 | if (ret) | ||
1342 | goto out_unlock; | ||
1343 | } | ||
1344 | |||
1345 | /* | ||
1346 | * ...clear the security bits if the process is not being run | ||
1347 | * by root. This keeps people from modifying setuid and setgid | ||
1348 | * binaries. | ||
1349 | */ | ||
1350 | ret = file_remove_privs(file_out); | ||
1351 | if (ret) | ||
1352 | goto out_unlock; | ||
1353 | } | ||
1354 | |||
1330 | return 1; | 1355 | return 1; |
1331 | out_unlock: | 1356 | out_unlock: |
1332 | xfs_reflink_remap_unlock(file_in, file_out); | 1357 | xfs_reflink_remap_unlock(file_in, file_out); |