Skip to content

fix(hypercall): bound read buffer to VM memory - #1500

Merged
jounathaen merged 1 commit into
hermit-os:mainfrom
Abhinavmadake:read-bound-guest-buffer
Oct 6, 2026
Merged

jounathaen merged 1 commit into
hermit-os:mainfrom
Abhinavmadake:read-bound-guest-buffer

Conversation

@Abhinavmadake

Copy link
Copy Markdown
Contributor

read resolved the guest buffer with host_address + from_raw_parts_mut, so a guest-controlled buf/len could point outside the guest mapping. write, getdents and serialwrite already bound their buffers with slice_at/slice_at_mut; this makes read consistent.

  • use slice_at_mut so an out-of-range or oversized buffer returns -EFAULT instead of reading or writing past VM memory
  • add tests: valid read, buffer crossing the end, buffer past memory, oversized len

Fixes #1499

Comment thread src/hypercall/by_fd.rs Outdated
Comment thread src/hypercall/by_fd.rs Outdated
read resolved the guest buffer with host_address + from_raw_parts_mut, so a guest-controlled buf/len could fall outside the guest mapping and read or write host memory. Use slice_at_mut, as write/getdents/serialwrite already do, returning -EFAULT when the buffer is not within guest memory.

Signed-off-by: Abhinav Madake <abhinavmadake@gmail.com>
@Abhinavmadake

Copy link
Copy Markdown
Contributor Author

thanks, done

@Abhinavmadake
Abhinavmadake force-pushed the read-bound-guest-buffer branch from f619c00 to 22172d5 Compare October 5, 2026 19:42
@fogti
fogti requested a review from jounathaen October 5, 2026 19:57

@jounathaen jounathaen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, thank you!

@jounathaen
jounathaen enabled auto-merge October 5, 2026 21:11
@codecov

codecov Bot commented Oct 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.95918% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.93%. Comparing base (ff7ce4b) to head (22172d5).

Files with missing lines Patch % Lines
src/hypercall/by_fd.rs 97.95% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1500      +/-   ##
==========================================
+ Coverage   79.69%   79.93%   +0.23%     
==========================================
  Files          41       41              
  Lines        5640     5682      +42     
==========================================
+ Hits         4495     4542      +47     
+ Misses       1145     1140       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jounathaen
jounathaen added this pull request to the merge queue Oct 6, 2026
Merged via the queue into hermit-os:main with commit 4a00142 Oct 6, 2026
21 of 24 checks passed
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.

read hypercall does not bound the guest buffer to VM memory

3 participants