-
Notifications
You must be signed in to change notification settings - Fork 29
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
Create sandbox for host file system access #783
Merged
Merged
Conversation
This file contains 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
This comment was marked as outdated.
This comment was marked as outdated.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #783 +/- ##
==========================================
+ Coverage 68.99% 71.51% +2.52%
==========================================
Files 20 21 +1
Lines 2761 3037 +276
==========================================
+ Hits 1905 2172 +267
- Misses 856 865 +9 ☔ View full report in Codecov by Sentry. |
n0toose
force-pushed
the
sandbox-uhyvefilemap
branch
from
November 5, 2024 19:52
a8ff49a
to
38e7e46
Compare
n0toose
commented
Nov 5, 2024
n0toose
changed the title
feat(sandbox): Add UhyveFileMap structure and sandbox
Create sandbox for host file system access
Nov 5, 2024
jounathaen
reviewed
Nov 6, 2024
jounathaen
reviewed
Nov 6, 2024
jounathaen
reviewed
Nov 6, 2024
jounathaen
reviewed
Nov 6, 2024
jounathaen
reviewed
Nov 6, 2024
jounathaen
reviewed
Nov 6, 2024
jounathaen
reviewed
Nov 6, 2024
jounathaen
reviewed
Nov 6, 2024
This comment was marked as outdated.
This comment was marked as outdated.
n0toose
force-pushed
the
sandbox-uhyvefilemap
branch
2 times, most recently
from
November 6, 2024 12:24
d14cb43
to
0b243c1
Compare
n0toose
commented
Nov 6, 2024
This comment was marked as outdated.
This comment was marked as outdated.
n0toose
force-pushed
the
sandbox-uhyvefilemap
branch
3 times, most recently
from
November 11, 2024 16:30
cf4b61a
to
6a11855
Compare
jounathaen
reviewed
Nov 12, 2024
n0toose
force-pushed
the
sandbox-uhyvefilemap
branch
from
November 12, 2024 15:37
678b672
to
2f5355f
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
n0toose
force-pushed
the
sandbox-uhyvefilemap
branch
2 times, most recently
from
November 23, 2024 23:48
677c06e
to
d9d750c
Compare
jounathaen
reviewed
Nov 28, 2024
jounathaen
reviewed
Nov 28, 2024
jounathaen
reviewed
Nov 28, 2024
jounathaen
reviewed
Nov 28, 2024
n0toose
force-pushed
the
sandbox-uhyvefilemap
branch
5 times, most recently
from
November 28, 2024 16:33
2a888f0
to
6e5b798
Compare
* Add --mount parameter for "whitelisting" guest_paths and defining their respective filesystem paths on the host FS * Add UhyveFileMap structure * Add sandbox support to open() syscall A few points that could be further worked are unit tests, handling more of the parsing using the clap library directly and performance optimizations. Helped-by: Çağatay Yiğit Şahin <[email protected]> Helped-by: Jonathan Klimt <[email protected]> Co-authored-by: Jonathan Klimt <[email protected]>
Introduces a test for UhyveFileMap and adjusts existing tests accordingly.
- Rename file_map to mount - Temporarily remove short parameter - Temporarily remove environment variable - Don't split file_map params with commas - Change documentation, remove references to file_map variable - Minor improvements to tests
This commit modifies existing tests to support this new feature. An additional measure of modifying sysopen.flags was also introduced. Co-authored-by: Jonathan Klimt <[email protected]>
Also removes the "Introduction" header, as the header takes more space than the text itself now. Originally introduced in e7869a9.
Co-authored-by: Jonathan Klimt <[email protected]>
... as it was deemed unnecessary and redundant. The tests were also modified accordingly.
Depending on the error, we return EINVAL (like in the kernel itself) when O_DIRECTORY is used together with O_CREAT, EIO when the kernel requests to open a file that does not have a UTF-8 filename, and -ENOENT when the file is not present in the file map. The sysopen flags were moved to uhyve-interface for now.
new_file_test now runs a kernel called open_close_file, which attempts to open foo.txt, write to it, then closes the file, and attempts to open it again so as to read from it. This is more of a workaround because of the fact that we cannot read the temporary file easily, but it should work just as well and expand the test's coverage to "reading the contents of a file that is a temporary file on the host filesystem".
If the guest path is part of a directory that is not mapped, we'll recursively look for the parent directories and check if the parent directories are mapped. If that's the case, we'll use the file in the mapped host directory instead. This feature also comes with a unit test. We partially rely on PathBuf to prevent any funny behavior from taking place. A current flaw of this approach is that the filename that can be found in the OpenParams struct is "relative" instead of absolute, and providing paths that are otherwise whitelisted (e.g. "/root/file.txt" instead of "file.txt") will result in the map not return a result.
Tests and documentation was also amended accordingly.
n0toose
force-pushed
the
sandbox-uhyvefilemap
branch
from
November 28, 2024 17:04
6e5b798
to
75fba18
Compare
Thank you for this big contribution! 👍 |
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
Nov 28, 2024
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.
uhyvelib::hypercall::open
anduhyvelib::hypercall:unlink
Fixes #767, #239