Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fchdir at unmount when mounting read-only #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nigeltao
Copy link

@nigeltao nigeltao commented Aug 5, 2021

Prior to this commit, after the fuse_loop function returns (e.g. as a
result of "fusermount -u" or equivalent from a separate process), this
main function would call fchdir(oldpwd) unconditionally and then, if the
archive was modified (in memory), rewrite the archive on disk.

This commit changes the "unconditionally" part so that fchdir is only
called if we're about to rewrite the archive on disk. Walking backwards,
the original working directory (the oldpwd variable) is no longer read
if options.readonly is true, as it is not used anywhere else.

For a read-only mount, the fchdir would just be unnecessary work. More
importantly, when running archivemount (in read-only mode) in a
syscall-based sandbox (e.g. minijail), removing the unconditionality of
the fchdir call means fewer syscalls in our allow-list.

Prior to this commit, after the fuse_loop function returns (e.g. as a
result of "fusermount -u" or equivalent from a separate process), this
main function would call fchdir(oldpwd) unconditionally and then, if the
archive was modified (in memory), rewrite the archive on disk.

This commit changes the "unconditionally" part so that fchdir is only
called if we're about to rewrite the archive on disk. Walking backwards,
the original working directory (the oldpwd variable) is no longer read
if options.readonly is true, as it is not used anywhere else.

For a read-only mount, the fchdir would just be unnecessary work. More
importantly, when running archivemount (in read-only mode) in a
syscall-based sandbox (e.g. minijail), removing the unconditionality of
the fchdir call means fewer syscalls in our allow-list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant