]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ceph: update the time stamps and try to drop the suid/sgid
authorXiubo Li <xiubli@redhat.com>
Mon, 13 Feb 2023 05:56:20 +0000 (13:56 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:34:25 +0000 (09:34 +0100)
commit e027253c4b77d395798600a90b6a96fe4adf4d5e upstream.

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: stable@vger.kernel.org
Link: https://tracker.ceph.com/issues/58054
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ceph/file.c

index 5895797f3104a6cb6bf0d54521f7c1d46bdf4a1a..02414437d8abf09319694c7e03dbe6ac5161e838 100644 (file)
@@ -2095,6 +2095,9 @@ static long ceph_fallocate(struct file *file, int mode,
        loff_t endoff = 0;
        loff_t size;
 
+       dout("%s %p %llx.%llx mode %x, offset %llu length %llu\n", __func__,
+            inode, ceph_vinop(inode), mode, offset, length);
+
        if (mode != (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
                return -EOPNOTSUPP;
 
@@ -2129,6 +2132,10 @@ static long ceph_fallocate(struct file *file, int mode,
        if (ret < 0)
                goto unlock;
 
+       ret = file_modified(file);
+       if (ret)
+               goto put_caps;
+
        filemap_invalidate_lock(inode->i_mapping);
        ceph_fscache_invalidate(inode, false);
        ceph_zero_pagecache_range(inode, offset, length);
@@ -2144,6 +2151,7 @@ static long ceph_fallocate(struct file *file, int mode,
        }
        filemap_invalidate_unlock(inode->i_mapping);
 
+put_caps:
        ceph_put_cap_refs(ci, got);
 unlock:
        inode_unlock(inode);