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

How should .. paths be resolved? #26

Open
sunfishcode opened this issue Mar 10, 2021 · 5 comments
Open

How should .. paths be resolved? #26

sunfishcode opened this issue Mar 10, 2021 · 5 comments

Comments

@sunfishcode
Copy link
Member

On POSIX, path resolution is performed one component at a time, and .. is resolved only after resolving all components that came before it. Opening a path such as nonexistent/.. fails, because opening nonexistent first fails.

On Windows, path resolution has an up-front parsing step which resolves ... On nonexistent/.., it's resolved to . first, so opening it succeeds.

Should we require Windows implementations to emulate POSIX semantics here, or say that whether .. is resolved up front or on the fly is nondeterministic?

@MaulingMonkey
Copy link
Contributor

I'd lean towards allowing it to be nondeterministic.

Multiple syscalls to emulate POSIX semantics sounds slow - especially in the case of network attached storage - and perhaps inconsistently implemented as a result, even on supposedly POSIX systems (if, for example, they might be talking to non-POSIX systems over odd network mounts or similar.)

@pchickey
Copy link
Contributor

One way out of this is to put the burden of resolving . and .. in paths to userland, and not permitting either to be used in paths passed to WASI.

@MaulingMonkey
Copy link
Contributor

That would have the effect of allowing self-imposed unveil-lite like behavior, by simply closing all FDs to root/parent directories outside of the chroot.

@sunfishcode
Copy link
Member Author

sunfishcode commented Dec 15, 2021

WASI filesystem allows applications to voluntarily sandbox themselves by closing fds to directories they don't need, or even opening subdirectories and closing the parent fds.

My sense here is that this is similar to the issues with case sensitivity. We aren't going to achieve full filesystem determinism without drastic costs. And there systems which do both eager and on-demand .. resolution in wide use, and emulating either would add overhead for all use cases just to serve the very uncommon cases where the difference actually matters. So my sense is, we should just let host platforms resolve .. how they see fit.

@codefromthecrypt
Copy link

I don't think having the host resolve ".." will work. In current practice, the current working directory is tracked in guest code, not host code. Lacking any ability to hook on cd/chdir I think relative lookups must be out of scope from perspective of the host.

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

No branches or pull requests

4 participants