[PHP] fix: enforce RLIMIT_FSIZE at file-write operation boundaries#748
Merged
brandonpayton merged 1 commit intoJul 11, 2026
Conversation
This was referenced Jul 10, 2026
Compute one wasm32-safe file-size budget per scalar, vectored, transfer, truncate, and mode-0 fallocate operation, including memfd and host scratch-buffer paths. Keep SIGXFSZ directed at the calling thread across fork/exec state, expose an additive host preflight export, and add wasm32/wasm64 Node plus Chromium guest coverage and POSIX documentation. This changes observable syscall and signal semantics and the exec-state wire format; it remains quarantined for the Batch 2 ABI 16-to-17 reconciliation.
brandonpayton
force-pushed
the
gascity/kd-6nz/split-pr717-posix-file-size-limit
branch
from
July 11, 2026 18:03
96b4600 to
7122d91
Compare
brandonpayton
changed the base branch from
integration/kd-6nz-php-phpt-harness-only-base
to
integration/kd-6nz-php-phpt-platform-fixes
July 11, 2026 18:04
brandonpayton
deleted the
gascity/kd-6nz/split-pr717-posix-file-size-limit
branch
July 11, 2026 18:04
13 tasks
brandonpayton
added a commit
that referenced
this pull request
Jul 13, 2026
Write preflight, fork and exec state, exact-thread SIGXFSZ ownership, return values, and error behavior alter existing file-operation contracts. Advance ABI 30 to 31 and regenerate ABI evidence atomically. Source-PR: #748
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.
Purpose
Make
RLIMIT_FSIZEobey one file-write operation boundary across Kandelo'skernel and host paths. An operation that starts below the soft limit returns
the prefix that fits without a signal; a later non-empty operation with no
room fails with
EFBIGand directsSIGXFSZto the calling thread. Pipes,terminals, sockets, and other non-size-bearing objects remain unaffected.
This supersedes the original non-compiling two-syscall patch with a reviewed
replacement built on the current Batch 2 aggregate tip.
Summary
writes, including offsets and limits above 4 GiB.
sendfile,copy_file_range,splice, regularfiles, memfds,
ftruncate/truncate, and mode-0fallocatewithoutover-consuming transfer input.
kernel_prepare_write_operationexport and keepsslow
writev/pwriteverror, offset, retry, and signal behavior coherent.SIGXFSZdirected at the exact calling thread. Main-thread-directedpending state remains separate from process-shared pending state across
signal delivery, signalfd/poll/select, fork, exec, and
/proc/<pid>/status.exec preserves the main thread's directed pending queue.
Chromium, and updates the POSIX status documentation and ABI snapshot.
Review changes
The review replaced the original implementation rather than preserving its
unsafe per-chunk check. It fixed the original borrow-check failure, wasm32
integer wrap, memfd bypass, append-side effects, transfer read-ahead, invalid
input/error ordering, truncate/fallocate overflow and shrink behavior, host
scratch-buffer decomposition, split
pwritevoffsets, non-EAGAINerrorloss, and exact-thread signal routing. Final audit repairs also bounded the
serialized directed-signal queue and preserved directed pending visibility in
procfs.
View
Accept into Batch 2 only. The repaired behavior and focused evidence are
sound, but this PR is deliberately not independently main-ready. It adds a
host-required kernel export and changes observable syscall, signal, and
exec-state-wire semantics while still reporting ABI 16. It must remain
quarantined for the aggregate ABI 16→17 reconciliation, regenerated/rebuilt
PHP and opcache artifacts, the exact opcache PHPT on Node and Chromium, and
the one full aggregate gate plus manual browser verification.
The generic pre-existing short-write source-advancement behavior outside an
RLIMIT-induced budget and broader worker signal-mask gaps are not claimed as
fixed here.
Verification on the replacement commit
scripts/dev-shell.sh cargo test -p kandelo --target aarch64-apple-darwin --lib— 1,089 passed, 0 failed.
scripts/dev-shell.sh cargo check -p kandelo --target wasm32-unknown-unknown --lib— passed.
scripts/dev-shell.sh bash -lc 'cd host && npm run typecheck'— passed.scripts/dev-shell.sh bash -lc 'cd host && npx vitest run test/rlimit-fsize.test.ts'— wasm32 and wasm64 guests passed, 2/2.
test/rlimit-fsize.spec.ts— passed, 1/1.bash build.sh— passed.scripts/dev-shell.sh bash scripts/check-abi-version.sh— snapshot/header/TSsynchronization passed and classified the new export as structurally
additive. This is not semantic ABI clearance; ABI 17 remains required.
git diff --check— clean.Per the locked batch policy, the complete host/libc/conformance/PHPT/browser
gate is deferred to the exact aggregate branch after ABI 17 rather than run
per constituent.