Escape and validate special characters in mount option values - #712
Merged
Conversation
Mount option values are passed to the kernel, libfuse, and the fusermount helpers
inside a comma separated list, so a comma in a value was read as the start of
another option: MountOption::FSName("foo,ro") mounted a read-only filesystem named
"foo". A NUL in a value panicked instead of returning an error.
fsname is now escaped for the consumers that decode backslash escapes, and passed
verbatim as the mount(2) source, which needs no escaping. Values that cannot be
escaped consistently across those consumers are rejected: comma and backslash in
subtype and custom options, in fsname too on platforms whose mount helpers decode
no escapes, and NUL everywhere.
Fixes #424
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NjYWzn3mu8Sc2y2eACtJM9
cberner
force-pushed
the
claude/fuser-issues-triage-7tz8v9
branch
from
July 31, 2026 16:03
8aca968 to
bbddd3a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #424
Mount option values are passed to the kernel, libfuse, and the fusermount helpers inside a comma separated list, so a comma in a value was read as the start of another option:
MountOption::FSName("foo,ro")mounted a read-only filesystem namedfoo. A NUL in a value panicked instead of returning an error.Following the analysis in the issue:
fsnameis escaped (,->\,,\->\\) for the consumers that decode backslash escapes, and passed verbatim as themount(2)source, which needs no escaping.InvalidInputfromSession::new(): comma and backslash inSubtypeandCUSTOM(libfuse does not re-escape them when forwarding to fusermount), and infsnametoo on platforms whose mount helpers decode no escapes.The check lives in
Mount::new()rather thanSession::new()so that every formatting of an option value can rely on it, including the directMount::new()calls in tests.The deprecated escaping question for
fuser::mount/spawn_mountraised at the end of the issue is left alone, as suggested there.Testing
Unit tests cover the escaping and the per-platform validation rules. A new mount test asserts that the comma in
FSName("fuser,ro")reaches/proc/self/mountsas part of the source name and does not appear among the mount options.Ran green on all three mount backends (pure-rust, libfuse2, libfuse3), both as root (direct
mount(2)) and as an unprivileged user going through a realfusermount3, whose argv I logged to confirm it receives-o fsname=fuser\,ro. Reverting just the escaping call makes the new test fail withleft: "fuser", right: "fuser,ro", so it does catch the reported bug.Also clean locally:
cargo fmt --check, clippy with--deny warnings(default and--no-default-features),cargo test --allwith and withoutlibfuse,cargo doc, the musl target,cargo check --target x86_64-apple-darwin --features=macos-no-mount, and bothtest_passthroughscripts. The Docker suites (mount_tests,pjdfs_tests,xfstests) could not run in my environment (no Docker daemon), so they are covered only by CI here.Generated by Claude Code