OPNsense - FreeBSD source
Find a file
Alan Somers 36ba360558 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
Differential Revision: https://reviews.freebsd.org/D33158

(cherry picked from commit 13d593a5b0)
2022-01-17 17:59:03 -07:00
.cirrus-ci Cirrus-CI: retry pkg installation on failure 2021-06-10 08:54:52 -04:00
.github/workflows .github: Attempt to un-break Clang 9 action 2021-05-29 04:38:07 +01:00
bin echo(1): Replace errexit() with err(3) 2022-01-07 14:12:12 +01:00
cddl ctfconvert: Handle arrays of empty structs 2022-01-07 09:03:02 -05:00
contrib file: upgrade to 5.41. 2022-01-17 16:43:58 -08:00
crypto Add assembly optimized code for OpenSSL on powerpc, powerpc64 and powerpc64le 2021-12-29 14:45:29 +01:00
etc pkgbase: Create a FreeBSD-mtree package 2022-01-05 18:23:52 +01:00
gnu Bump shared library versions after ncurses bump in 13. 2021-02-04 17:51:45 -08:00
include sys/bitset.h: reduce visibility of BIT_* macros 2022-01-14 18:17:30 +02:00
kerberos5 pkgbase: Create a FreeBSD-kerberos package 2022-01-05 18:23:50 +01:00
lib file: upgrade to 5.41. 2022-01-17 16:43:58 -08:00
libexec Fix gssd rc.d installation 2022-01-14 14:43:40 +01:00
release pkgbase: Add a FreeBSD-pkg-bootstrap package 2022-01-05 18:23:53 +01:00
rescue Fix building rescue/rescue when sanitizers are enabled 2021-08-05 09:59:51 +01:00
sbin fsck(8): Fix typo 2022-01-15 20:34:18 +08:00
secure Add assembly optimized code for OpenSSL on powerpc, powerpc64 and powerpc64le 2021-12-29 14:45:29 +01:00
share Make CPU_SET macros compliant with other implementations 2022-01-14 18:17:30 +02:00
stand loader: Fix dtb loading 2022-01-14 14:44:36 +01:00
sys Fix a race in fusefs that can corrupt a file's size. 2022-01-17 17:59:03 -07:00
targets Fix bootstrapping to actually build lldb-tblgen for later use 2021-09-07 13:08:18 +01:00
tests Fix a race in fusefs that can corrupt a file's size. 2022-01-17 17:59:03 -07:00
tools depend-cleanup.sh: Make the output message more precise 2021-12-13 08:27:31 -05:00
usr.bin script(1): work around slow reading child 2022-01-15 14:55:32 +02:00
usr.sbin bhyve: dynamically register FwCtl ports 2022-01-17 13:53:28 +01:00
.arcconfig arcconfig: add callsign again 2020-11-23 04:39:29 +00:00
.arclint
.cirrus.yml Cirrus-CI: build with LLVM 13 package 2022-01-07 19:14:12 -05:00
.clang-format clang-format: Add bitset loop macros 2021-11-01 09:20:11 -04:00
.gitattributes Add a basic clang-format configuration file 2019-06-07 15:23:52 +00:00
.gitignore add exuberant ctags tags file to gitignore 2022-01-11 15:25:37 +02:00
COPYRIGHT copyrights: Happy New Year 2021 2020-12-31 10:29:44 -05:00
LOCKS
MAINTAINERS Add a pointer to csprng@ for the CSPRNG driver. This is enforced anyway by 2020-09-01 08:02:12 +00:00
Makefile Fix 'make bmake' top-level bootstrapping. 2021-12-21 14:44:51 +01:00
Makefile.inc1 pkgbase: Track pkg 1.17 2022-01-14 14:50:41 +01:00
Makefile.libcompat Prefer MK_SSP=no to SSP_CFLAGS= 2021-08-11 13:56:28 -03:00
Makefile.sys.inc
ObsoleteFiles.inc libefivar(3): efi_set_variables_supported.3 should be efi_variables_supported.3 2021-12-24 14:49:37 +08:00
README README.md: update gnu directory description 2021-12-19 21:01:53 -05:00
README.md README.md: update gnu directory description 2021-12-19 21:01:53 -05:00
RELNOTES RELNOTES: Add comment about WiFi 6 support 2021-11-22 10:42:11 -08:00
UPDATING Make CPU_SET macros compliant with other implementations 2022-01-14 18:17:30 +02:00

FreeBSD Source:

This is the top level of the FreeBSD source directory. This file was last revised on: FreeBSD

FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms. A large community has continually developed it for more than thirty years. Its advanced networking, security, and storage features have made FreeBSD the platform of choice for many of the busiest web sites and most pervasive embedded networking and storage devices.

For copyright information, please see the file COPYRIGHT in this directory. Additional copyright information also exists for some sources in this tree - please see the specific source directories for more information.

The Makefile in this directory supports a number of targets for building components (or all) of the FreeBSD source tree. See build(7), config(8), https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html, and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html for more information, including setting make(1) variables.

Source Roadmap:

bin		System/user commands.

cddl		Various commands and libraries under the Common Development
		and Distribution License.

contrib		Packages contributed by 3rd parties.

crypto		Cryptography stuff (see crypto/README).

etc		Template files for /etc.

gnu		Commands and libraries under the GNU General Public License
		(GPL) or Lesser General Public License (LGPL).  Please see
		gnu/COPYING* for more information.

include		System include files.

kerberos5	Kerberos5 (Heimdal) package.

lib		System libraries.

libexec		System daemons.

release		Release building Makefile & associated tools.

rescue		Build system for statically linked /rescue utilities.

sbin		System commands.

secure		Cryptographic libraries and commands.

share		Shared resources.

stand		Boot loader sources.

sys		Kernel sources.

sys/<arch>/conf Kernel configuration files. GENERIC is the configuration
		used in release builds. NOTES contains documentation of
		all possible entries.

tests		Regression tests which can be run by Kyua.  See tests/README
		for additional information.

tools		Utilities for regression testing and miscellaneous tasks.

usr.bin		User commands.

usr.sbin	System administration commands.

For information on synchronizing your source tree with one or more of the FreeBSD Project's development branches, please see:

https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html