Skip to content

[PHP] fix: reject unsupported mremap flags#750

Merged
brandonpayton merged 1 commit into
integration/kd-6nz-php-phpt-batch-1-kernel-fixesfrom
gascity/kd-6nz/split-pr717-mremap-flags
Jul 10, 2026
Merged

[PHP] fix: reject unsupported mremap flags#750
brandonpayton merged 1 commit into
integration/kd-6nz-php-phpt-batch-1-kernel-fixesfrom
gascity/kd-6nz/split-pr717-mremap-flags

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jun 20, 2026

Copy link
Copy Markdown
Member

Why

mremap(2) accepts flags Kandelo does not implement. The wasm libc import ABI for mremap passes only the first four Linux syscall arguments, so MREMAP_FIXED (which needs the fifth new_address argument) cannot be honored, and MREMAP_DONTUNMAP has 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: define SUPPORTED_FLAGS = MREMAP_MAYMOVE in sys_mremap and return EINVAL for any other flag bits, before attempting the remap. Adds a test that MREMAP_FIXED is rejected with EINVAL and leaves the original mapping intact.
  • crates/kernel/src/wasm_api.rs: update the kernel_mremap doc comment to state that in-place resize and MREMAP_MAYMOVE are supported while other flags are rejected.

Provenance

Supersedes fork-headed PR #730; identical head commit 978e08195c21b5e48cf71f35bd1164c173ba7de7, re-pointed onto an Automattic/kandelo branch. No code changed from #730.

(cherry picked from commit 8c015fa)
(cherry picked from commit ccf8d32)
@brandonpayton
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
brandonpayton merged commit 01ec019 into integration/kd-6nz-php-phpt-batch-1-kernel-fixes Jul 10, 2026
31 checks passed
@brandonpayton
brandonpayton deleted the gascity/kd-6nz/split-pr717-mremap-flags branch July 10, 2026 17:46
brandonpayton pushed a commit that referenced this pull request Jul 13, 2026
Rejecting previously accepted mremap flag bits changes the existing syscall argument and errno contract. Advance ABI 19 to 20 and regenerate ABI evidence atomically.

Source-PR: #750

Curated-Reconstruction: retains the reviewed #750 epoch as one commit.
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