Skip to content

test: cover FreeBSD short remote reads - #26

Closed
vankudothuadhinaik wants to merge 2 commits into
rbspy:mainfrom
vankudothuadhinaik:test/freebsd-short-read
Closed

vankudothuadhinaik wants to merge 2 commits into
rbspy:mainfrom
vankudothuadhinaik:test/freebsd-short-read

Conversation

@vankudothuadhinaik

@vankudothuadhinaik vankudothuadhinaik commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a FreeBSD-only regression test for remote-memory reads crossing into a protected PROT_NONE page.
  • Verify that the observed FreeBSD PT_IO failure preserves the original EFAULT error rather than incorrectly reporting UnexpectedEof.
  • Extract the PT_IO result and transfer-length classification into a helper used by production code.
  • Add deterministic tests covering syscall failure, full transfer success, successful short transfers, and preservation of the original OS error when a syscall fails.
  • Ensure child-process cleanup and fail CI if no FreeBSD test binaries are found.

Validation

  • cargo fmt --all -- --check — passed.
  • git diff --check — passed.
  • GitHub Actions — all four checks passed on the current PR head:
    • FreeBSD
    • macOS 26
    • Ubuntu 24.04
    • Windows 2025
  • FreeBSD CI ran the integration test and all four deterministic classifier tests successfully: 8 passed, 0 failed.
  • Local tests could not be completed on Windows because link.exe is unavailable; the FreeBSD Rust target is not installed locally.

Findings

The FreeBSD protected-page integration test produces EFAULT, not a successful partial transfer. The UnexpectedEof behavior is covered separately by a deterministic unit test for a successful short transfer.

@vankudothuadhinaik

Copy link
Copy Markdown
Contributor Author

Hi, thanks for taking a look at this PR. The GitHub Actions workflow is currently awaiting maintainer approval. Could you please approve the workflow when convenient so the FreeBSD regression test can run? Thank you!

@acj

acj commented Oct 26, 2026

Copy link
Copy Markdown
Member

Hey, thanks for looking into this.

Ensure FreeBSD test binaries are built regardless of the cross cache result and fail CI if no test binaries are found.

I've cherry-picked this since it's a good fix regardless of the FreeBSD tests - 064bf24.

Verify that a read crossing into PROT_NONE memory returns UnexpectedEof when the operating system reports a short transfer.

Based on the test output, this doesn't seem to match what FreeBSD actually does. We could assert a different error type, but either way, the test might not be checking for a short read.

@vankudothuadhinaik

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I’ve prepared an isolated diagnostic branch that logs the PT_IO return value, transferred length (piod_len), immediate errno, PT_DETACH result, and final copy_address() error. It preserves the existing assertion and production behavior.

Could you approve a temporary diagnostic run of the FreeBSD Firecracker job using this branch? I’ll use it only to determine whether the test produces a genuine short read or a syscall/cleanup error, then remove the temporary branch. I haven’t changed or pushed the original PR branch.

@acj

acj commented Oct 26, 2026

Copy link
Copy Markdown
Member

Your agent can run CI on your fork of this repo along with whatever changes it needs to test.

@vankudothuadhinaik

Copy link
Copy Markdown
Contributor Author

I ran the FreeBSD diagnostic to investigate whether the protected-page test produces a genuine short transfer.

The diagnostic output shows:

  • PT_IO = -1
  • Requested length: 8 bytes
  • piod_len = 8
  • Immediate errno: EFAULT (14)
  • PT_DETACH = 0
  • copy_address() returns the original OS error, not UnexpectedEof

This confirms that the syscall fails before reporting a successful partial transfer. The detach operation does not mask the error.

The FreeBSD integration test therefore verifies preservation of the actual EFAULT error. Successful short-transfer classification is covered separately by the deterministic ptrace_io_result() unit test.

Diagnostic runs:

The diagnostic work was kept separate from the original PR branch.

@acj acj closed this in f18ac83 Oct 27, 2026
@acj

acj commented Oct 27, 2026

Copy link
Copy Markdown
Member

I merged a simplified version of this. Thanks for your contribution

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