fix: harden fs and net handlers - #68
Merged
Merged
Conversation
…-root guard Signed-off-by: danbugs <danilochiarlone@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR hardens host-side filesystem and networking RPC handlers to reduce guest-driven resource exhaustion and prevent host-thread stalls during socket I/O. It fits into the host crate’s tool/handler layer where guest calls are translated into constrained host operations.
Changes:
- Set read/write timeouts on sockets returned by
accept()so accepted connections can’t block host threads indefinitely. - Add caps/guards in filesystem handlers: limit
fs_listdirectory enumeration size, reject oversizedfs_write_bytesoffsets, and preventfs_unlinkfrom removing the mount root.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Contributor
There was a problem hiding this comment.
Linux Benchmarks
Details
| Benchmark suite | Current: 0dcbe53 | Previous: 4c053f6 | Ratio |
|---|---|---|---|
hello_world (median) |
20 ms |
20 ms |
1 |
pandas (median) |
110 ms |
90 ms |
1.22 |
density (per VM) |
7 MB |
7 MB |
1 |
snapshot (disk) |
385 MiB |
385 MiB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
danbugs
enabled auto-merge
May 17, 2026 08:16
Contributor
There was a problem hiding this comment.
Windows Benchmarks
Details
| Benchmark suite | Current: 0dcbe53 | Previous: 4c053f6 | Ratio |
|---|---|---|---|
hello_world (median) |
272 ms |
181 ms |
1.50 |
pandas (median) |
876 ms |
557 ms |
1.57 |
density (per VM) |
6 MB |
6 MB |
1 |
snapshot (disk) |
392 MiB |
392 MiB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
This file contains hidden or 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
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.
Summary
accept()returns a new socket that doesn't inherit parent timeouts, leavingnet_recvon accepted connections able to block the host thread indefinitelyfs_write_bytesoffset toMAX_TRUNCATE_LEN(1 GiB) — previously a guest could pass multi-TB offsets to create sparse files, circumventing the truncate capMAX_DIR_ENTRIES(100k) cap tofs_listto prevent host OOM on directories with millions of entriesfs_unlinkagainst deleting the mount root directory itselfTest plan
cargo test --libpasses (56 tests)cargo clippycleancargo fmtclean