Conversation
xrl
force-pushed
the
fix/truncated-cmsg-len
branch
2 times, most recently
from
September 19, 2026 06:19
c0f3df1 to
1361c67
Compare
…buffer On macOS, `recvmsg` truncates control data to fit the buffer but leaves `cmsg_len` untruncated, so `AncillaryDrain::advance` underflowed the remaining length and the drain in `Drop` panicked again, aborting the process; with overflow checks off, `cvt_msg` instead sliced past the buffer and yielded `OwnedFd`s read from uninitialized memory. `Messages` now yields the buffer space at each header, `advance` clamps `cmsg_len` to it, and `cvt_msg` rounds `SCM_RIGHTS` payloads down to whole descriptors. Fixes bytecodealliance#1683. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
xrl
force-pushed
the
fix/truncated-cmsg-len
branch
from
September 19, 2026 06:33
1361c67 to
6a81010
Compare
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.
Fixes #1683.
On macOS,
recvmsgtruncates control data to fit theRecvAncillaryBufferbut leavescmsg_lenuntruncated, soAncillaryDrain::advanceunderflows the remaining length, the drain inDroppanics again and the process aborts; with overflow checks off,cvt_msginstead slices past the buffer and yieldsOwnedFds read from uninitialized memory.Messagesnow yields the buffer space at each header alongside it,advanceclampscmsg_lento that, andcvt_msgroundsSCM_RIGHTSpayloads down to whole descriptors.scm_detach_fdsadjustscmsg_len, so the clamp is a no-op there.CTRUNC, so the test doesn't assert on it.Disclosure: this change and its test were written by an AI coding agent (Claude, Anthropic) at the direction of @xrl, who reviewed the diff. Please review it with that in mind.
Run on macOS 15.6, aarch64, rustc 1.98.1:
cargo test --features=all-apis --test net(45 pass; the new test aborts with SIGABRT againstmain),cargo test --release --features=all-apis --test net truncated,cargo clippy --features=all-apis --all-targets,cargo fmt --all --check.