Skip to content

Commit fbe7e52

Browse files
Dave ChinnerDarrick J. Wong
authored andcommitted
xfs: fallocate() should call file_modified()
In XFS, we always update the inode change and modification time when any fallocate() operation succeeds. Furthermore, as various fallocate modes can change the file contents (extending EOF, punching holes, zeroing things, shifting extents), we should drop file privileges like suid just like we do for a regular write(). There's already a VFS helper that figures all this out for us, so use that. The net effect of this is that we no longer drop suid/sgid if the caller is root, but we also now drop file capabilities. We also move the xfs_update_prealloc_flags() function so that it now is only called by the scope that needs to set the the prealloc flag. Based on a patch from Darrick Wong. Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 472c6e4 commit fbe7e52

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fs/xfs/xfs_file.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,10 @@ xfs_file_fallocate(
953953
goto out_unlock;
954954
}
955955

956+
error = file_modified(file);
957+
if (error)
958+
goto out_unlock;
959+
956960
if (mode & FALLOC_FL_PUNCH_HOLE) {
957961
error = xfs_free_file_space(ip, offset, len);
958962
if (error)
@@ -1053,11 +1057,12 @@ xfs_file_fallocate(
10531057
if (error)
10541058
goto out_unlock;
10551059
}
1056-
}
10571060

1058-
error = xfs_update_prealloc_flags(ip, flags);
1059-
if (error)
1060-
goto out_unlock;
1061+
error = xfs_update_prealloc_flags(ip, XFS_PREALLOC_SET);
1062+
if (error)
1063+
goto out_unlock;
1064+
1065+
}
10611066

10621067
/* Change file size if needed */
10631068
if (new_size) {

0 commit comments

Comments
 (0)