Skip to content

mremap: reject growth when mapping metadata does not match#927

Closed
brandonpayton wants to merge 1 commit into
mainfrom
fix/mremap-metadata-success
Closed

mremap: reject growth when mapping metadata does not match#927
brandonpayton wants to merge 1 commit into
mainfrom
fix/mremap-metadata-success

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jul 13, 2026

Copy link
Copy Markdown
Member

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 main also keeps adjacent mmap regions as separate metadata entries, so this PR does not replay the old mapping-coalescing changes from 1a9e7325b5a45002da9899da2ea20a2ae8a58b32.

What remains here

An in-place mremap grow first checks whether the extra pages are free, then asks MemoryManager to 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 EFAULT when 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

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.sh reports 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.sh on commit 2a8bfbcd6ae7f7ebb5799a8e2db3c05bb491cf02:

  • focused mremap and extend_mapping kernel tests: 7 passed
  • CI-shaped kernel suite: 1,153 passed
  • focused mmap/mremap host tests: 49 passed
  • CI-shaped Vitest: 146 files passed, 31 skipped; 1,266 tests passed, 2 expected failures, 130 skipped
  • Bun teardown follow-up: 2 files and 3 tests passed
  • host typecheck passed
  • full build.sh passed after bootstrapping the clean worktree's wasm32 sysroot
  • wasm64 musl and program builds passed as setup for the full Vitest run
  • ABI snapshot/version check passed with no generated diff
  • git diff --check passed

Not 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.

@brandonpayton

Copy link
Copy Markdown
Member Author

Closing this focused source PR because its metadata-consistent mremap growth behavior is now carried by #934 at exact green head 260d75d5adc31b327f5591229dbfbb287d395fd6. #934 keeps it as a separate purpose commit and passed the full staging gates. This is not a claim that this branch was merged verbatim.

@brandonpayton
brandonpayton deleted the fix/mremap-metadata-success branch July 14, 2026 02:43
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.

1 participant