cpu: report a named skip for the pe_map blast longjmp cases when CFG is active #1614

Manually merged
github merged 1 commit from gh-pr/1614/head into gh-pr/1614/base 2026-11-26 23:21:00 +00:00
Owner

@⁠MasterDomino on GitHub · 2026-11-24 15:03 UTC · original
MasterDomino:cpu/pe-map-cfg-longjmp-skip → main · +97 −10 · 4 files · 1 commits · merged 2026-11-24 15:17 UTC

Refs #1293 (option 2, as agreed there; the issue stays open for actual mapped longjmp support under CFG)

When Control Flow Guard is active in the process that runs a pe_map-mapped fixture, blast's out-of-input longjmp fails fast with FAST_FAIL_INVALID_LONGJUMP_TARGET. The root cause is on #1293: ntdll accepts a long-jump target only inside an image the Windows loader registered, or under a process-wide protected policy, and pe_map maps blast_source privately. This change makes the three affected checks report a named capability skip for exactly that mapped case. The host's CFG policy is left in force.

Change

  • tests/cpu/archive_check.py:
    • The parent marks a mapped run with X2W_MAPPED_LONGJMP_CASE=1 only when the case's expected trace reaches blast's longjmp. That is the input 0 pull, the only path to it.
    • The mapped child (--mapped), before mapping anything, reads its own effective policy with GetProcessMitigationPolicy(ProcessControlFlowGuardPolicy). If EnableControlFlowGuard is set, it writes skip: CFG is active in the pe_map runner; blast's out-of-input longjmp would fail fast (#1293) to stderr and exits 77.
    • If the policy cannot be read, it writes cannot read the CFG policy of the pe_map runner: error N and exits 1, so the test fails explicitly.
    • Unmarked runs, and runs where CFG is not active, are unchanged.
    • The parent counts a run as skipped only if it was marked, exited 77 and printed that diagnostic. It runs every other case, then exits 77 and names the skipped cases.
  • archive_texture_check.py and archive_texture_gpu_check.py: they use the same helper (run_mapped_case) for their pe_map runner.
  • CMakeLists.txt: SKIP_RETURN_CODE 77 on cpu_native_archive_blast, cpu_archive_texture_publication and cpu_archive_texture_gpu_warp. cpu_archive_texture_gpu_hardware already had it, for a missing adapter.
  • The native and AOT runs, the native truncated-input check and cpu_native_archive_reader (no blast mapped) are unchanged.

Verification

main + this change at 7d4b477d (on 81df4051). Windows 11 26H2, build 26300.9974, ntdll 10.0.26100.9974, system CFG setting NOTSET, Python 3.13.1, dev preset.

1. Normal run (CFG not active for the runner on this host):

ctest --preset dev --no-tests=error -R '^(cpu_native_archive_(reader|blast)|cpu_archive_texture_(publication|gpu_warp|gpu_hardware))$'

5/5 pass, no skip.

2. The mapped child itself, started with PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY (CFG ALWAYS_ON/ALWAYS_OFF) on the base interpreter, as in the launcher on #1293:

child CFG case marked exit stderr
on truncated yes 77 the named diagnostic, before anything is mapped
off truncated yes 2 the full expected trace … input 4 / input 0 / output 1 / free / completed 1: error, cleanup and exit still checked
on both records no 0 the full expected trace: an unrelated mapped case runs under CFG
on truncated no 0xC0000409 the original fail-fast (negative control)

3. End to end (scratch harness, not committed): all three checks run in process, with only their pe_map children started under CFG ALWAYS_ON. A policy set on the parent is not inherited by its children, so the parent alone cannot show this.

  • archive_check.py: only the 14-byte mapped case is skipped; exit 77.
  • archive_texture_check.py: only mapped truncated is skipped; mapped both passes under CFG; exit 77.
  • archive_texture_gpu_check.py (WARP): only mapped truncated and first are skipped; mapped both, stale, fail (exit 4) and leak pass under CFG; exit 77.

Each prints skip: CFG is active in the pe_map runner, so its blast longjmp cases did not run (#1293): <cases>.

4. Policy read failure: cfg_active() with a kernel32 stand-in whose GetProcessMitigationPolicy returns 0 raises cannot read the CFG policy of the pe_map runner: error 0.

I have no CFG-enforced host where the policy reaches the test children through CTest. @⁠legacy-code-archaeologist offered a Windows 11 26100 rerun on #1293.

AI-assisted.

🤖 Generated with Claude Code

**@⁠MasterDomino** on GitHub · 2026-11-24 15:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1614) `MasterDomino:cpu/pe-map-cfg-longjmp-skip` → `main` · +97 −10 · 4 files · 1 commits · merged 2026-11-24 15:17 UTC Refs #1293 (option 2, as agreed there; the issue stays open for actual mapped `longjmp` support under CFG) When Control Flow Guard is active in the process that runs a `pe_map`-mapped fixture, blast's out-of-input `longjmp` fails fast with `FAST_FAIL_INVALID_LONGJUMP_TARGET`. The root cause is on #1293: ntdll accepts a long-jump target only inside an image the Windows loader registered, or under a process-wide protected policy, and `pe_map` maps `blast_source` privately. This change makes the three affected checks report a named capability skip for exactly that mapped case. The host's CFG policy is left in force. ## Change - **`tests/cpu/archive_check.py`:** - The parent marks a mapped run with `X2W_MAPPED_LONGJMP_CASE=1` only when the case's expected trace reaches blast's longjmp. That is the `input 0` pull, the only path to it. - The mapped child (`--mapped`), before mapping anything, reads its own effective policy with `GetProcessMitigationPolicy(ProcessControlFlowGuardPolicy)`. If `EnableControlFlowGuard` is set, it writes `skip: CFG is active in the pe_map runner; blast's out-of-input longjmp would fail fast (#1293)` to stderr and exits 77. - If the policy cannot be read, it writes `cannot read the CFG policy of the pe_map runner: error N` and exits 1, so the test fails explicitly. - Unmarked runs, and runs where CFG is not active, are unchanged. - The parent counts a run as skipped only if it was marked, exited 77 and printed that diagnostic. It runs every other case, then exits 77 and names the skipped cases. - **`archive_texture_check.py` and `archive_texture_gpu_check.py`:** they use the same helper (`run_mapped_case`) for their `pe_map` runner. - **`CMakeLists.txt`:** `SKIP_RETURN_CODE 77` on `cpu_native_archive_blast`, `cpu_archive_texture_publication` and `cpu_archive_texture_gpu_warp`. `cpu_archive_texture_gpu_hardware` already had it, for a missing adapter. - The native and AOT runs, the native truncated-input check and `cpu_native_archive_reader` (no blast mapped) are unchanged. ## Verification `main` + this change at `7d4b477d` (on `81df4051`). Windows 11 26H2, build 26300.9974, `ntdll` 10.0.26100.9974, system CFG setting `NOTSET`, Python 3.13.1, `dev` preset. **1. Normal run** (CFG not active for the runner on this host): ``` ctest --preset dev --no-tests=error -R '^(cpu_native_archive_(reader|blast)|cpu_archive_texture_(publication|gpu_warp|gpu_hardware))$' ``` 5/5 pass, no skip. **2. The mapped child itself**, started with `PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY` (CFG `ALWAYS_ON`/`ALWAYS_OFF`) on the base interpreter, as in the launcher on #1293: | child CFG | case | marked | exit | stderr | |---|---|---|---|---| | on | truncated | yes | 77 | the named diagnostic, before anything is mapped | | off | truncated | yes | 2 | the full expected trace `… input 4 / input 0 / output 1 / free / completed 1`: error, cleanup and exit still checked | | on | both records | no | 0 | the full expected trace: an unrelated mapped case runs under CFG | | on | truncated | no | `0xC0000409` | the original fail-fast (negative control) | **3. End to end** (scratch harness, not committed): all three checks run in process, with only their `pe_map` children started under CFG `ALWAYS_ON`. A policy set on the parent is not inherited by its children, so the parent alone cannot show this. - `archive_check.py`: only the 14-byte mapped case is skipped; exit 77. - `archive_texture_check.py`: only mapped `truncated` is skipped; mapped `both` passes under CFG; exit 77. - `archive_texture_gpu_check.py` (WARP): only mapped `truncated` and `first` are skipped; mapped `both`, `stale`, `fail` (exit 4) and `leak` pass under CFG; exit 77. Each prints `skip: CFG is active in the pe_map runner, so its blast longjmp cases did not run (#1293): <cases>`. **4. Policy read failure:** `cfg_active()` with a `kernel32` stand-in whose `GetProcessMitigationPolicy` returns 0 raises `cannot read the CFG policy of the pe_map runner: error 0`. I have no CFG-enforced host where the policy reaches the test children through CTest. @⁠legacy-code-archaeologist offered a Windows 11 26100 rerun on #1293. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With Control Flow Guard enforced, ntdll accepts a longjmp target only in
an image the Windows loader registered (or under a process-wide
protected policy). pe_map maps blast_source privately, so blast's
out-of-input longjmp fails fast with FAST_FAIL_INVALID_LONGJUMP_TARGET.
The parent marks the mapped runs whose expected trace reaches that
longjmp ("input 0"). The mapped child reads its own effective CFG policy
before mapping anything; when CFG is active it prints a named diagnostic
and exits 77, and a failed policy read fails explicitly. The native and
AOT runs and every other mapped case keep running, and the test reports
a capability skip.

Refs #1293

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:20:58 +00:00
github manually merged commit 7d4b477d46 into gh-pr/1614/base 2026-11-26 23:21:00 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 15:13 UTC · original · reviewed

Reviewed 7d4b477d463b444f4f0dd1188e8f3ebf0b6b712e:

  • Diff & semantics: tests/cpu/archive_check.py, tests/cpu/archive_texture_check.py, and tests/cpu/archive_texture_gpu_check.py cleanly isolate the pe_map blast out-of-input longjmp cases ("input 0" in the expected trace, marked via X2W_MAPPED_LONGJMP_CASE=1). When cfg_active() (GetProcessMitigationPolicy(..., ProcessControlFlowGuardPolicy, ...)) reports CFG active in the mapped child before mapping, it emits the named skip message and exits 77; run_mapped_case only treats it as skipped when both reaches_longjmp and the CFG_SKIP marker + exit 77 match, while CMakeLists.txt wires SKIP_RETURN_CODE 77 on the affected cpu_* tests.
  • Hygiene (Linux): python3 tests/docs_links_check.py (16 Markdown files, 348 links), python3 tests/bidi_controls_check.py (1262 files), and python3 -m py_compile tests/cpu/archive_check.py tests/cpu/archive_texture_check.py tests/cpu/archive_texture_gpu_check.py passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): cmake --build --preset dev --target archive_all_lifted archive_codec archive_codec_gpu archive_codec_lifted archive_directory_gpu archive_directory_lifted archive_reader_lifted archive_texture_gpu_lifted archive_texture_lifted blast_lifted blast_source pe_map + ctest --preset dev -R '^(cpu_archive_directory_gpu_warp|cpu_archive_texture_gpu_warp|cpu_archive_texture_publication|cpu_native_archive_blast|cpu_native_archive_reader)$' --parallel 4 --no-tests=error --output-on-failure -> 5/5 passed (10.53s).
    • Release /O2 (--preset release): same targets and ctest --preset release -> 5/5 passed (10.10s).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 15:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1614#pullrequestreview-6041917074) · **reviewed** Reviewed `7d4b477d463b444f4f0dd1188e8f3ebf0b6b712e`: - **Diff & semantics**: `tests/cpu/archive_check.py`, `tests/cpu/archive_texture_check.py`, and `tests/cpu/archive_texture_gpu_check.py` cleanly isolate the `pe_map` blast out-of-input `longjmp` cases (`"input 0"` in the expected trace, marked via `X2W_MAPPED_LONGJMP_CASE=1`). When `cfg_active()` (`GetProcessMitigationPolicy(..., ProcessControlFlowGuardPolicy, ...)`) reports CFG active in the mapped child before mapping, it emits the named skip message and exits `77`; `run_mapped_case` only treats it as skipped when both `reaches_longjmp` and the `CFG_SKIP` marker + exit `77` match, while `CMakeLists.txt` wires `SKIP_RETURN_CODE 77` on the affected `cpu_*` tests. - **Hygiene (Linux)**: `python3 tests/docs_links_check.py` (16 Markdown files, 348 links), `python3 tests/bidi_controls_check.py` (1262 files), and `python3 -m py_compile tests/cpu/archive_check.py tests/cpu/archive_texture_check.py tests/cpu/archive_texture_gpu_check.py` passed. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`): `cmake --build --preset dev --target archive_all_lifted archive_codec archive_codec_gpu archive_codec_lifted archive_directory_gpu archive_directory_lifted archive_reader_lifted archive_texture_gpu_lifted archive_texture_lifted blast_lifted blast_source pe_map` + `ctest --preset dev -R '^(cpu_archive_directory_gpu_warp|cpu_archive_texture_gpu_warp|cpu_archive_texture_publication|cpu_native_archive_blast|cpu_native_archive_reader)$' --parallel 4 --no-tests=error --output-on-failure` -> **5/5 passed** (`10.53s`). - Release `/O2` (`--preset release`): same targets and `ctest --preset release` -> **5/5 passed** (`10.10s`). AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.