feat(session): add from_fds for externally pre-cloned fds#679
Open
XciD wants to merge 1 commit intocberner:masterfrom
Open
feat(session): add from_fds for externally pre-cloned fds#679XciD wants to merge 1 commit intocberner:masterfrom
XciD wants to merge 1 commit intocberner:masterfrom
Conversation
Add Session::from_fds(filesystem, primary_fd, extra_fds, acl, config) for callers that receive /dev/fuse fds cloned by a privileged helper (e.g. a CSI driver sending fds over SCM_RIGHTS). When extra_fds is non-empty: - Worker count = 1 + extra_fds.len() (config.n_threads ignored). - Workers use the supplied fds directly; config.clone_fd and the internal clone_fd() path (which opens /dev/fuse and so requires CAP_SYS_ADMIN) are skipped. Each extra fd must already be bound to the same FUSE connection as the primary (FUSE_DEV_IOC_CLONE ioctl); FUSE_INIT still happens on the primary during handshake(). from_fd is preserved as a thin wrapper over from_fds with no extras.
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.
Summary
Adds
Session::from_fds(filesystem, primary_fd, extra_fds, acl, config)for callers that receive/dev/fusefds cloned by a privileged helper (e.g. a CSI driver sending fds overSCM_RIGHTS).When
extra_fdsis non-empty:1 + extra_fds.len()(config.n_threadsis ignored).config.clone_fdand the internalclone_fd()path (which opens/dev/fuseand so requiresCAP_SYS_ADMIN) are skipped.Each extra fd must already be bound to the same FUSE connection as the primary (
FUSE_DEV_IOC_CLONEioctl);FUSE_INITstill happens on the primary duringhandshake().from_fdis preserved as a thin wrapper overfrom_fdswith no extras.Motivation
In some deployments (e.g. Kubernetes CSI drivers), an unprivileged process should not hold
CAP_SYS_ADMINand so cannot itself open/dev/fuseto clone the session fd. A privileged sidecar opens/dev/fuse, performsFUSE_DEV_IOC_CLONE, and passes the resulting fds to the worker over a Unix socket. This API lets the worker drive a multi-threaded session over those externally-cloned fds without ever opening/dev/fuseitself.