mremap: reject growth when mapping metadata does not match#927
Closed
brandonpayton wants to merge 1 commit into
Closed
mremap: reject growth when mapping metadata does not match#927brandonpayton wants to merge 1 commit into
brandonpayton wants to merge 1 commit into
Conversation
This was referenced Jul 13, 2026
Member
Author
|
Closing this focused source PR because its metadata-consistent |
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.
This pulls the remaining mremap metadata fix out of #769 and puts it directly on current
main.What #907 already landed
#907 already fixed mmap placement and munmap geometry. Current
mainalso keeps adjacent mmap regions as separate metadata entries, so this PR does not replay the old mapping-coalescing changes from1a9e7325b5a45002da9899da2ea20a2ae8a58b32.What remains here
An in-place mremap grow first checks whether the extra pages are free, then asks
MemoryManagerto extend the exact(address, old length)mapping. That update used to return no result. If the caller described an old range that was not actually mapped, the update did nothing but mremap still returned success.This change makes the metadata update return whether it found the exact mapping. mremap now returns
EFAULTwhen that invalid old range cannot be updated, matching Linux's documented error for an unmapped address in the old range. The regression checks that the original mapping stays unchanged and the next mmap can still use the genuinely free page.Deliberately left out
mainalready has that behavior.ABI and package artifacts
This stays on ABI 39. The ABI snapshot, syscall number, arguments, marshalling, exports, and memory layout do not change. The observable correction is limited to an invalid old range that previously reported false success; valid mremap calls keep the same behavior.
scripts/check-abi-version.shreports the committed snapshot is still current.There are no package recipe, package revision, VFS image, or binary artifact changes, so no package rebuild or revision bump is needed.
Validation
Run through
scripts/dev-shell.shon commit2a8bfbcd6ae7f7ebb5799a8e2db3c05bb491cf02:extend_mappingkernel tests: 7 passedbuild.shpassed after bootstrapping the clean worktree's wasm32 sysrootgit diff --checkpassedNot run locally: browser Playwright or
./run.sh browser, libc-test, Open POSIX, Sortix, or performance benchmarks. CI will run the repository-wide suites. mremap is Linux-specific and the conformance trees do not contain a focused mremap case. Performance was not measured and this PR makes no performance claim.Extracted from #769.