Skip to content

Commit e027253

Browse files
lxbszidryomov
authored andcommitted
ceph: update the time stamps and try to drop the suid/sgid
The fallocate will try to clear the suid/sgid if a unprevileged user changed the file. There is no POSIX item requires that we should clear the suid/sgid in fallocate code path but this is the default behaviour for most of the filesystems and the VFS layer. And also the same for the write code path, which have already support it. And also we need to update the time stamps since the fallocate will change the file contents. Cc: [email protected] Link: https://tracker.ceph.com/issues/58054 Signed-off-by: Xiubo Li <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent c9c3395 commit e027253

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/ceph/file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,9 @@ static long ceph_fallocate(struct file *file, int mode,
21022102
loff_t endoff = 0;
21032103
loff_t size;
21042104

2105+
dout("%s %p %llx.%llx mode %x, offset %llu length %llu\n", __func__,
2106+
inode, ceph_vinop(inode), mode, offset, length);
2107+
21052108
if (mode != (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
21062109
return -EOPNOTSUPP;
21072110

@@ -2136,6 +2139,10 @@ static long ceph_fallocate(struct file *file, int mode,
21362139
if (ret < 0)
21372140
goto unlock;
21382141

2142+
ret = file_modified(file);
2143+
if (ret)
2144+
goto put_caps;
2145+
21392146
filemap_invalidate_lock(inode->i_mapping);
21402147
ceph_fscache_invalidate(inode, false);
21412148
ceph_zero_pagecache_range(inode, offset, length);
@@ -2151,6 +2158,7 @@ static long ceph_fallocate(struct file *file, int mode,
21512158
}
21522159
filemap_invalidate_unlock(inode->i_mapping);
21532160

2161+
put_caps:
21542162
ceph_put_cap_refs(ci, got);
21552163
unlock:
21562164
inode_unlock(inode);

0 commit comments

Comments
 (0)