Repository navigation
Ignore mount options libfuse 3 removed, and guard against null paths - #576
Conversation
Two things at the boundary to libfuse.
First: libfuse 3 dropped a set of mount options libfuse 2 accepted, and an
option it doesn't know makes it refuse the mount. 'cryfs -o' forwards
whatever the user passes, so the libfuse 2 spellings now abort the mount
with a message from libfuse and nothing from us. The ones that are gone are
removed with a warning instead:
$ cryfs base mnt -o hard_remove,big_writes,allow_other
[cryfs] [warning] Ignoring mount option 'hard_remove'. It doesn't exist
anymore in libfuse 3: libfuse 3 decides this itself and hides unlinked
but still open files.
[cryfs] [warning] Ignoring mount option 'big_writes'. It doesn't exist
anymore in libfuse 3: libfuse 3 always allows large writes.
# mounted, with allow_other still applied
Each of hard_remove, use_ino, readdir_ino, direct_io, nopath, intr,
intr_signal, big_writes, large_read and max_write was verified against
libfuse 3.14.0 and 3.17.2 to make libfuse print "unknown option(s)" and
refuse the mount. Options libfuse 3 still knows, including kernel_cache,
auto_cache, umask, uid, gid and the timeout options, are left alone; that
was checked the same way. The man page lists the removed ones.
The walk over the '-o' values moves into fspp/fuse/MountOptions, and the
atime extraction now shares it. That also fixes a latent bug in the old
walk: after erasing the '-o' and its value it kept using a reference into
the vector it had just erased from, which is undefined behaviour. It
happened to work because the freed slot never compared equal to "-o".
Second: the operations that take a fuse_file_info can be called with a null
path, when the node has left its tree and the file system told libfuse it
can work from the handle alone. CryFS never asks for that, but constructing
a boost::filesystem::path from a null pointer is undefined behaviour, so the
wrappers now refuse the request with EIO instead. The same shape existed in
the FUSE 2 wrappers; the new fi-taking chmod, chown and utimens widen it.
Tests: MountOptionsTest covers the walk (comma separated lists, several '-o'
arguments, arguments that aren't mount options, and dropping a '-o' that
ends up without a value, which libfuse also rejects) and the filter, with
the removed and the kept options listed as the versions above answered them,
plus guards for similarly named options.
The null path guard has no test: CryFS cannot reach the case, which is
exactly why it was only a latent problem.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP
|
The failing They fail at build on The fix is open as #578 for Windows and #577 for macOS. I have not ported either into this PR: both rewrite The Linux jobs are the ones that exercise this change, and they pass. I have not re-run the Windows jobs, because they fail with a deterministic compile error rather than intermittently. Generated by Claude Code |
…tion-and-nullpath-guards Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP
The gcc 14 CI jobs fail to build this file:
MountOptionsTest.cpp:16:35: error: no matching function for call to
'find(vector<string>::const_iterator, vector<string>::const_iterator,
const string&)'
return keep.end() != std::find(keep.begin(), keep.end(), option);
The test helper calls std::find but only includes <gtest/gtest.h> and
MountOptions.h. With libstdc++ 14 the only std::find in scope is the
istreambuf_iterator overload that <bits/streambuf_iterator.h> pulls in through
gtest, so the call doesn't resolve, the lambda's return type can't be deduced,
and it no longer converts to the std::function the walker takes. libstdc++ 13
happens to make <algorithm> visible transitively, which is why this built
locally and on the clang libc++ jobs.
Include <algorithm> explicitly, plus <string> and <vector> for the two types the
file names directly.
Reproduced with g++-14 before the change and verified after: the file compiles
clean, a full g++-14 Release build of fspp-test, cryfs-test and cryfs-cli-test
succeeds with no errors, fspp-test passes all 1033 tests and the 14 mount option
tests pass.
Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP
6022c9e to
073f4e6
Compare
…-and-nullpath-guards Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP
…s-fuse2-path #576 added the is_null_path() helper at the top of the anonymous namespace in Fuse.cpp, which is exactly where this branch opens its #if FUSE_MAJOR_VERSION >= 3 for the getattr/fgetattr split, so the two collided. Resolved by nesting rather than choosing: is_null_path() stays before the guard. It has to, because seven of its fifteen call sites (open, read, write, flush, release, fsync, readdir and friends) are in operations that are compiled on both the FUSE 2 and the FUSE 3 path, so defining it inside the guard would not compile on Windows. The FUSE 2 branches deliberately do not get the null-path guard. libfuse only passes a null path when the file system sets nullpath_ok, and Dokany's wrapper - FUSE_MAJOR_VERSION 2, FUSE_MINOR_VERSION 7 - has no such member: grepping its headers for nullpath_ok and flag_nullpath_ok finds nothing, while upstream libfuse 2.9.9 has flag_nullpath_ok and 3.9.0 has nullpath_ok. There is no way for a null path to arrive on the Dokany path, so guarding there would add dead code. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP
…576) * Ignore mount options libfuse 3 removed, and guard against null paths Two things at the boundary to libfuse. First: libfuse 3 dropped a set of mount options libfuse 2 accepted, and an option it doesn't know makes it refuse the mount. 'cryfs -o' forwards whatever the user passes, so the libfuse 2 spellings now abort the mount with a message from libfuse and nothing from us. The ones that are gone are removed with a warning instead: $ cryfs base mnt -o hard_remove,big_writes,allow_other [cryfs] [warning] Ignoring mount option 'hard_remove'. It doesn't exist anymore in libfuse 3: libfuse 3 decides this itself and hides unlinked but still open files. [cryfs] [warning] Ignoring mount option 'big_writes'. It doesn't exist anymore in libfuse 3: libfuse 3 always allows large writes. # mounted, with allow_other still applied Each of hard_remove, use_ino, readdir_ino, direct_io, nopath, intr, intr_signal, big_writes, large_read and max_write was verified against libfuse 3.14.0 and 3.17.2 to make libfuse print "unknown option(s)" and refuse the mount. Options libfuse 3 still knows, including kernel_cache, auto_cache, umask, uid, gid and the timeout options, are left alone; that was checked the same way. The man page lists the removed ones. The walk over the '-o' values moves into fspp/fuse/MountOptions, and the atime extraction now shares it. That also fixes a latent bug in the old walk: after erasing the '-o' and its value it kept using a reference into the vector it had just erased from, which is undefined behaviour. It happened to work because the freed slot never compared equal to "-o". Second: the operations that take a fuse_file_info can be called with a null path, when the node has left its tree and the file system told libfuse it can work from the handle alone. CryFS never asks for that, but constructing a boost::filesystem::path from a null pointer is undefined behaviour, so the wrappers now refuse the request with EIO instead. The same shape existed in the FUSE 2 wrappers; the new fi-taking chmod, chown and utimens widen it. Tests: MountOptionsTest covers the walk (comma separated lists, several '-o' arguments, arguments that aren't mount options, and dropping a '-o' that ends up without a value, which libfuse also rejects) and the filter, with the removed and the kept options listed as the versions above answered them, plus guards for similarly named options. The null path guard has no test: CryFS cannot reach the case, which is exactly why it was only a latent problem. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP * Include <algorithm> in MountOptionsTest The gcc 14 CI jobs fail to build this file: MountOptionsTest.cpp:16:35: error: no matching function for call to 'find(vector<string>::const_iterator, vector<string>::const_iterator, const string&)' return keep.end() != std::find(keep.begin(), keep.end(), option); The test helper calls std::find but only includes <gtest/gtest.h> and MountOptions.h. With libstdc++ 14 the only std::find in scope is the istreambuf_iterator overload that <bits/streambuf_iterator.h> pulls in through gtest, so the call doesn't resolve, the lambda's return type can't be deduced, and it no longer converts to the std::function the walker takes. libstdc++ 13 happens to make <algorithm> visible transitively, which is why this built locally and on the clang libc++ jobs. Include <algorithm> explicitly, plus <string> and <vector> for the two types the file names directly. Reproduced with g++-14 before the change and verified after: the file compiles clean, a full g++-14 Release build of fspp-test, cryfs-test and cryfs-cli-test succeeds with no errors, fspp-test passes all 1033 tests and the 14 mount option tests pass. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP --------- Co-authored-by: Claude <[email protected]>
Part of the review of the libfuse 3 migration. Two small findings at the same boundary, the mount options we hand libfuse and the arguments libfuse hands us.
Mount options libfuse 3 removed
libfuse 3 dropped a set of mount options libfuse 2 accepted, and an option it does not know makes it refuse the mount. The migration correctly dropped the hard-coded
-o big_writes, butcryfs -oforwards whatever the user passes, so the libfuse 2 spellings now abort the mount with a message from libfuse and nothing from us.They are removed with a warning instead:
The filesystem then mounts, with
allow_otherstill applied, confirmed in/proc/mounts. Before this, the same command printedfuse: unknown option(s)and mounted nothing.The list is not guesswork. Every option was run against a real CryFS on both libfuse 3.14.0 and 3.17.2:
hard_remove,use_ino,readdir_ino,direct_ionopath,intr,intr_signal=,big_writeslarge_read,max_write=kernel_cache,auto_cache,noauto_cacheumask=,uid=,gid=entry_timeout=,negative_timeout=,attr_timeout=,ac_attr_timeout=allow_other,default_permissions,noatimeThe options that still work are left alone.
max_read=is deliberately not in the list: it fails on both versions but not with an unknown-option error, and I did not pin down why.The man page lists what is ignored.
A latent bug in the option walk
The walk over the
-ovalues moves intofspp/fuse/MountOptionsso the atime extraction and this new filter share it. That also fixes something in the old walk: after erasing the-oand its value it kept using a reference into the vector it had just erased from, which is undefined behaviour. It happened to work because the freed slot never compared equal to"-o". The shared version indexes instead of holding a reference.Null paths
The operations that take a
fuse_file_infocan be called with a null path, when the node has left its tree and the filesystem told libfuse it can work from the handle alone (get_path_nullokin libfuse'slib/fuse.c). CryFS never asks for that, so it is unreachable today, but constructing aboost::filesystem::pathfrom a null pointer is undefined behaviour. The fifteen wrappers that receive afuse_file_infonow refuse the request withEIOinstead of walking into it.The same shape existed in the FUSE 2 wrappers. What is new is that
chmod,chown,truncateandutimensnow take afuse_file_infotoo, which widens the surface.This one has no test. CryFS cannot reach the case, which is exactly why it was only a latent problem, and forcing it would mean enabling
nullpath_ok, which is the thing we do not want.Tests
MountOptionsTestcovers the walk (comma-separated lists, several-oarguments, arguments that are not mount options, and dropping a-othat ends up without a value, which libfuse also rejects) and the filter, with the removed and the kept options exactly as the two libfuse versions answered them, plus guards so thatbig_writes_but_not_really,intrepidand a baremax_writeare not touched.fspp-testcryfs-cli-testThe
cryfs-cli-testrun excludes the permission tests, which cannot pass as root. CI runs them unprivileged.🤖 Generated with Claude Code
https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP
Generated by Claude Code