freebsd-dev/sys/fs/fuse
Alan Somers 13d593a5b0 Fix a race in fusefs that can corrupt a file's size.
VOPs like VOP_SETATTR can change a file's size, with the vnode
exclusively locked.  But VOPs like VOP_LOOKUP look up the file size from
the server without the vnode locked.  So a race is possible.  For
example:

1) One thread calls VOP_SETATTR to truncate a file.  It locks the vnode
   and sends FUSE_SETATTR to the server.
2) A second thread calls VOP_LOOKUP and fetches the file's attributes from
   the server.  Then it blocks trying to acquire the vnode lock.
3) FUSE_SETATTR returns and the first thread releases the vnode lock.
4) The second thread acquires the vnode lock and caches the file's
   attributes, which are now out-of-date.

Fix this race by recording a timestamp in the vnode of the last time
that its filesize was modified.  Check that timestamp during VOP_LOOKUP
and VFS_VGET.  If it's newer than the time at which FUSE_LOOKUP was
issued to the server, ignore the attributes returned by FUSE_LOOKUP.

PR:		259071
Reported by:	Agata <chogata@moosefs.pro>
Reviewed by:	pfg
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D33158
2021-12-31 17:38:42 -07:00
..
fuse_device.c modules: increase MAXMODNAME and provide backward compat 2021-12-09 18:09:53 +00:00
fuse_file.c fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT 2021-09-26 21:57:29 -06:00
fuse_file.h fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT 2021-09-26 21:57:29 -06:00
fuse_internal.c Fix a race in fusefs that can corrupt a file's size. 2021-12-31 17:38:42 -07:00
fuse_internal.h Change VOP_READDIR's cookies argument to a **uint64_t 2021-12-15 20:54:57 -07:00
fuse_io.c Fix a race in fusefs that can corrupt a file's size. 2021-12-31 17:38:42 -07:00
fuse_io.h fusefs: inline fuse_io_dispatch 2021-12-06 21:41:50 -07:00
fuse_ipc.c fusefs: ensure that FUSE ops' headers' unique values are actually unique 2021-06-19 14:45:29 -06:00
fuse_ipc.h fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT 2021-09-26 21:57:29 -06:00
fuse_kernel.h fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT 2021-09-26 21:57:29 -06:00
fuse_main.c modules: increase MAXMODNAME and provide backward compat 2021-12-09 18:09:53 +00:00
fuse_node.c Fix a race in fusefs that can corrupt a file's size. 2021-12-31 17:38:42 -07:00
fuse_node.h Fix a race in fusefs that can corrupt a file's size. 2021-12-31 17:38:42 -07:00
fuse_vfsops.c Fix a race in fusefs that can corrupt a file's size. 2021-12-31 17:38:42 -07:00
fuse_vnops.c Fix a race in fusefs that can corrupt a file's size. 2021-12-31 17:38:42 -07:00
fuse.h