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

UhyveFileMap: Canonicalize guest paths #815

Open
n0toose opened this issue Nov 29, 2024 · 2 comments · May be fixed by #844
Open

UhyveFileMap: Canonicalize guest paths #815

n0toose opened this issue Nov 29, 2024 · 2 comments · May be fixed by #844
Assignees
Labels
enhancement New feature or request

Comments

@n0toose
Copy link
Member

n0toose commented Nov 29, 2024

Currently, entering --file-mapping host.txt:.. as a parameter leads to behavior that is not... exactly how it should be (opening the parent directory would result in opening a text file), and --file-mapping host.txt:guest.txt != --file-mapping host.txt:/root/guest.txt (guest.txt and /root/guest.txt are seen as two separate files, as we only look up a mapping against a "string" provided in the form of a char* in OpenParams).

The first case isn't as severe, because the actual problem at hand can only be caused by a user trying to break things. However, the second case is a problem - both could be solved by "canonicalizing" the paths provided by the guest, same as on the host. An idea is to make Hermit and Uhyve "chdir-aware" or "force" Hermit to provide full paths when running an open call.

@n0toose
Copy link
Member Author

n0toose commented Dec 1, 2024

Possibly related to hermit-os/kernel#1477. We should emulate Hermit's behavior and pass on an environment variable instead of exclusively hard-coding /root and leaving it up to the application to change the directory.

@n0toose
Copy link
Member Author

n0toose commented Dec 1, 2024

Mild dependency on #814.

@n0toose n0toose added the enhancement New feature or request label Dec 16, 2024
n0toose added a commit to n0toose/uhyve that referenced this issue Dec 17, 2024
Until now, guest paths were not canonicalized.

This would mean that Uhyve would not be able to see that, for example,
"/root" and "/root/directory/.." are both locations referring to the
same directory. This requires a new dependency for now, although we
should remove it once Path::normalize_lexically is implemented and
part of Rust.

This also "removes" support for empty, mapped guest paths.

Fixes hermit-os#815.
@n0toose n0toose linked a pull request Dec 17, 2024 that will close this issue
n0toose added a commit to n0toose/uhyve that referenced this issue Dec 17, 2024
Until now, guest paths were not canonicalized.

This would mean that Uhyve would not be able to see that, for example,
"/root" and "/root/directory/.." are both locations referring to the
same directory. This requires a new dependency for now, although we
should remove it once Path::normalize_lexically is implemented and
part of Rust.

This also "removes" support for empty, mapped guest paths.

Fixes hermit-os#815.
n0toose added a commit to n0toose/uhyve that referenced this issue Dec 17, 2024
Until now, guest paths were not canonicalized.

This would mean that Uhyve would not be able to see that, for example,
"/root" and "/root/directory/.." are both locations referring to the
same directory. This requires a new dependency for now, although we
should remove it once Path::normalize_lexically is implemented and
part of Rust.

This also "removes" support for empty, mapped guest paths.

Fixes hermit-os#815.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant