[PHP] fix: reject unsupported mremap flags#750
Merged
brandonpayton merged 1 commit intoJul 10, 2026
Merged
Conversation
6 tasks
brandonpayton
changed the base branch from
integration/kd-6nz-php-phpt-harness-only-base
to
integration/kd-6nz-php-phpt-batch-1-kernel-fixes
July 10, 2026 17:46
brandonpayton
merged commit Jul 10, 2026
01ec019
into
integration/kd-6nz-php-phpt-batch-1-kernel-fixes
31 checks passed
13 tasks
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.
Why
mremap(2)accepts flags Kandelo does not implement. The wasm libc import ABI for mremap passes only the first four Linux syscall arguments, soMREMAP_FIXED(which needs the fifthnew_addressargument) cannot be honored, andMREMAP_DONTUNMAPhas Linux-specific aliasing semantics the kernel does not implement. Silently accepting those flags meant Kandelo would fall through to an ordinary in-place remap — promising behavior it does not provide and risking corrupt mappings.Returning a deterministic error is the correct kernel contract: it keeps the implemented surface precise and testable. PHP's memory-management tests probe exactly these mremap edge cases, so the fix belongs in the kernel rather than in a PHP shim.
What
crates/kernel/src/syscalls.rs: defineSUPPORTED_FLAGS = MREMAP_MAYMOVEinsys_mremapand returnEINVALfor any other flag bits, before attempting the remap. Adds a test thatMREMAP_FIXEDis rejected withEINVALand leaves the original mapping intact.crates/kernel/src/wasm_api.rs: update thekernel_mremapdoc comment to state that in-place resize andMREMAP_MAYMOVEare supported while other flags are rejected.Provenance
Supersedes fork-headed PR #730; identical head commit
978e08195c21b5e48cf71f35bd1164c173ba7de7, re-pointed onto anAutomattic/kandelobranch. No code changed from #730.