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

feat(hypercall): introduce chdir and integrate it in UhyveFileMap #820

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

n0toose
Copy link
Member

@n0toose n0toose commented Dec 1, 2024

This is a form of preparation for the introduction of additional
security-related measures, which may be best to implement in separate
files.
@n0toose n0toose marked this pull request as draft December 1, 2024 18:00
@n0toose
Copy link
Member Author

n0toose commented Dec 1, 2024

This should allow the VM to change the guest "current working directory" stored in UhyveFileMap. This is an early concept, but this is what I'm going for:

  1. During UhyveFileMap::new (with /root or UHYVE_MOUNTPATH or another interface to be decided) by default, file.txt (user input) gets added to the file map as /root/file.txt.
  2. Hermit will be able to create /root/test_folder, chdir into it, then open a file called /root/test_folder/file.txt. In that case, OpenParams will contain file.txt, but we'll have stored /root/test_folder internally.
  3. By opening file.txt, a mapping with the guest path /root/test_folder/file.txt should be added.

The current design assumes that open in Hermit will continue to work as-is - by not providing Uhyve with an absolute path -, so Uhyve tries to prepend the chdir with every given opportunity itself. This has not been tested extensively yet.

Partially fixes #815.

@@ -75,6 +75,16 @@ pub struct UnlinkParams {
pub ret: i32,
}

/// Parameters for a [`FileUnlink`](crate::Hypercall::Chdir) hypercall.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Parameters for a [`FileUnlink`](crate::Hypercall::Chdir) hypercall.
/// Parameters for a [`ChangeDir`](crate::Hypercall::ChangeDir) hypercall.

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.

2 participants