cpu_native_load_config_callback fails when system CFG is off: the native /guard:cf runs inherit the host policy #1359

Closed
opened 2026-11-24 09:24:28 +00:00 by Maxim-Root · 2 comments
Maxim-Root commented 2026-11-24 09:24:28 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Maxim-Root on 2026-11-24T09:24:28Z.


Commit or build

c4966c64 (main), dev preset (Debug), clean build.

Reproduction

On a host where Get-ProcessMitigation -System reports CFG Enable: OFF (Windows Security > App & browser control > Exploit protection > Control flow guard = Off):

.\tools\dev.ps1
cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^cpu_native_load_config_callback$' --output-on-failure

Expected behavior

The check either measures the Windows CFG behavior it asserts for the two /guard:cf images, or reports that the host does not enforce CFG for them. A host setting should not turn into a failure that reads like a pe_map or fixture regression.

Observed behavior

The test fails on every run in the native (Windows loader) launch of cfg_record. It never reaches the pe_map side of that variant:

record: Windows exit 0x55 trace 0x2200000011 0x100000033 0x3008; pe_map exit 0x55 ...; mapped slots read-only and relocated
other: Windows exit 0x99 ...
invalid: Windows exit 0x77 trace 0x0 0x0 0x0; ...
cfg_record: slots in read-only .rdata with DIR64 relocations (null entry has none), guard flags 0x17500, GUARD_CF True, 6 function table entries, 2 calls through the dispatch slot
AssertionError: cfg_record: Windows (85, (146028888081, 4294967347, 12296)), expected both slots replaced and 0x55

tests/cpu/load_config_callback_check.py assumes that Windows replaces both guard slots of every /guard:cf image. That only holds when CFG is enforced for the process. With the system CFG setting off, the loader leaves the image's own slots in place. cfg_record then behaves exactly like record (exit 0x55, no slot bits), and cfg_invalid runs the invalid target like invalid does (exit 0x77) instead of ending before output.

Measured root cause. I started the fixtures directly with CreateProcessW and an explicit per-process PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY. No system setting was changed. After each exit I read GetProcessMitigationPolicy(ProcessControlFlowGuardPolicy) on the child's handle:

Image Child CFG policy EnableControlFlowGuard Exit Trace words
record host default 0 0x55 0x2200000011 0x100000033 0x3008
cfg_record host default 0 0x55 0x2200000011 0x100000033 0x3008
cfg_record CONTROL_FLOW_GUARD_ALWAYS_OFF 0 0x55 same
cfg_record CONTROL_FLOW_GUARD_ALWAYS_ON 1 0x30055 same
cfg_invalid host default 0 0x77 0x0 0x0 0x0
cfg_invalid CONTROL_FLOW_GUARD_ALWAYS_ON 1 0xC0000409 no output

With CFG forced on for the child, both images give exactly what the check expects: both slots are replaced, and the invalid target ends before writing output. The policy is still readable through the process handle after the child has exited. The hosted windows-2025 runner uses the Windows default (CFG on), which is why CI is green.

Related but separate: #1293 is the opposite host condition (system CFG on) in the archive tests.

Proposed change (one small PR, tests/cpu/load_config_callback_check.py only). Launch the two /guard:cf images natively with an explicit per-process CFG policy instead of inheriting the host setting:

  • ALWAYS_ON: the existing CFG assertions, now deterministic on any host;
  • ALWAYS_OFF as a negative control: cfg_record must equal record (0x55, slots kept) and cfg_invalid must equal invalid, which shows the policy, and not something else, is what changes the result;
  • after each launch, read the child's EnableControlFlowGuard and fail with a named diagnostic if it does not match the requested policy.

The pe_map side and the non-CFG variants stay unchanged. If you would rather keep the host's own policy, the alternative is to read the child's effective policy and report a named capability skip (77) when CFG is not enforced. I can do either. I have the forced-policy version ready and will link the PR here. If you prefer the skip, I will switch it.

Environment

Windows 11 Pro build 26300.9818, system CFG off (Get-ProcessMitigation -System). Visual Studio 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100.0, CMake 3.31.6 (VS bundled), Python 3.12.10. AMD Ryzen 7 7800X3D. In a full non-hardware run at d6cbd5d7 this was the only failure; the other 579 tests passed or reported their named skips. At c4966c64 I reran only this test.

Checklist

  • I reproduced this on a source-built input.
  • I did not include game files, dumps, distribution links or credentials.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6578636095 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1366). Originally posted by [Maxim-Root](https://github.com/Maxim-Root) on 2026-11-24T09:24:28Z. --- ### Commit or build `c4966c64` (`main`), `dev` preset (Debug), clean build. ### Reproduction On a host where `Get-ProcessMitigation -System` reports CFG `Enable: OFF` (Windows Security > App & browser control > Exploit protection > Control flow guard = Off): ```powershell .\tools\dev.ps1 cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R '^cpu_native_load_config_callback$' --output-on-failure ``` ### Expected behavior The check either measures the Windows CFG behavior it asserts for the two `/guard:cf` images, or reports that the host does not enforce CFG for them. A host setting should not turn into a failure that reads like a `pe_map` or fixture regression. ### Observed behavior The test fails on every run in the native (Windows loader) launch of `cfg_record`. It never reaches the `pe_map` side of that variant: ```text record: Windows exit 0x55 trace 0x2200000011 0x100000033 0x3008; pe_map exit 0x55 ...; mapped slots read-only and relocated other: Windows exit 0x99 ... invalid: Windows exit 0x77 trace 0x0 0x0 0x0; ... cfg_record: slots in read-only .rdata with DIR64 relocations (null entry has none), guard flags 0x17500, GUARD_CF True, 6 function table entries, 2 calls through the dispatch slot AssertionError: cfg_record: Windows (85, (146028888081, 4294967347, 12296)), expected both slots replaced and 0x55 ``` `tests/cpu/load_config_callback_check.py` assumes that Windows replaces both guard slots of every `/guard:cf` image. That only holds when CFG is enforced for the process. With the system CFG setting off, the loader leaves the image's own slots in place. `cfg_record` then behaves exactly like `record` (exit `0x55`, no slot bits), and `cfg_invalid` runs the invalid target like `invalid` does (exit `0x77`) instead of ending before output. **Measured root cause.** I started the fixtures directly with `CreateProcessW` and an explicit per-process `PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY`. No system setting was changed. After each exit I read `GetProcessMitigationPolicy(ProcessControlFlowGuardPolicy)` on the child's handle: | Image | Child CFG policy | `EnableControlFlowGuard` | Exit | Trace words | |---|---|---|---|---| | `record` | host default | 0 | `0x55` | `0x2200000011 0x100000033 0x3008` | | `cfg_record` | host default | 0 | `0x55` | `0x2200000011 0x100000033 0x3008` | | `cfg_record` | `CONTROL_FLOW_GUARD_ALWAYS_OFF` | 0 | `0x55` | same | | `cfg_record` | `CONTROL_FLOW_GUARD_ALWAYS_ON` | 1 | `0x30055` | same | | `cfg_invalid` | host default | 0 | `0x77` | `0x0 0x0 0x0` | | `cfg_invalid` | `CONTROL_FLOW_GUARD_ALWAYS_ON` | 1 | `0xC0000409` | no output | With CFG forced on for the child, both images give exactly what the check expects: both slots are replaced, and the invalid target ends before writing output. The policy is still readable through the process handle after the child has exited. The hosted `windows-2025` runner uses the Windows default (CFG on), which is why CI is green. Related but separate: #1293 is the opposite host condition (system CFG on) in the archive tests. **Proposed change (one small PR, `tests/cpu/load_config_callback_check.py` only).** Launch the two `/guard:cf` images natively with an explicit per-process CFG policy instead of inheriting the host setting: - `ALWAYS_ON`: the existing CFG assertions, now deterministic on any host; - `ALWAYS_OFF` as a negative control: `cfg_record` must equal `record` (`0x55`, slots kept) and `cfg_invalid` must equal `invalid`, which shows the policy, and not something else, is what changes the result; - after each launch, read the child's `EnableControlFlowGuard` and fail with a named diagnostic if it does not match the requested policy. The `pe_map` side and the non-CFG variants stay unchanged. If you would rather keep the host's own policy, the alternative is to read the child's effective policy and report a named capability skip (77) when CFG is not enforced. I can do either. I have the forced-policy version ready and will link the PR here. If you prefer the skip, I will switch it. ### Environment Windows 11 Pro build 26300.9818, system CFG off (`Get-ProcessMitigation -System`). Visual Studio 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100.0, CMake 3.31.6 (VS bundled), Python 3.12.10. AMD Ryzen 7 7800X3D. In a full non-hardware run at `d6cbd5d7` this was the only failure; the other 579 tests passed or reported their named skips. At `c4966c64` I reran only this test. ### Checklist - [x] I reproduced this on a source-built input. - [x] I did not include game files, dumps, distribution links or credentials. AI-assisted (Claude Code).
ChazY11 commented 2026-11-24 11:03:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T10:32:16Z.


One data point on the boundary of the condition

I tried to reproduce this to work on it, and could not, which narrows the condition:

Windows 11 build 26300.9974, main at 695805a3, dev preset, DXC 1.8.2502.11, debug layer enabled

Get-ProcessMitigation -System   .Cfg:
  OverrideCFG            : False
  OverrideStrictCFG      : False
  Enable                 : NOTSET
  SuppressExports        : NOTSET
  StrictControlFlowGuard : NOTSET

ctest --preset dev -R '^cpu_native_load_config_callback$' --output-on-failure
  1/1 Test #458: cpu_native_load_config_callback ...  Passed  2.54 sec

So with Enable: NOTSET the check passes on this host — the un-enforced-CFG case needs an explicit OFF, not merely an
unset policy. That also means the fix has to read the resolved policy rather than "the setting is absent", if it is
going to gate on it.

Two things I could not do here: flip the system policy to OFF (needs the Exploit protection UI plus a restart), and
therefore check any candidate guard. If a fix lands, Get-ProcessMitigation -System output pasted next to the test
result would be enough for me to tell you whether my host now takes the new path or still the asserting one.

I am not sending a patch for this: without a host that reproduces it, anything I wrote would be a guess about which
observed value goes missing, and the issue's own expectation is already precise.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7128912481 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1366#issuecomment-7128912481). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T10:32:16Z. --- ## One data point on the boundary of the condition I tried to reproduce this to work on it, and could not, which narrows the condition: ```text Windows 11 build 26300.9974, main at 695805a3, dev preset, DXC 1.8.2502.11, debug layer enabled Get-ProcessMitigation -System .Cfg: OverrideCFG : False OverrideStrictCFG : False Enable : NOTSET SuppressExports : NOTSET StrictControlFlowGuard : NOTSET ctest --preset dev -R '^cpu_native_load_config_callback$' --output-on-failure 1/1 Test #458: cpu_native_load_config_callback ... Passed 2.54 sec ``` So with `Enable: NOTSET` the check passes on this host — the un-enforced-CFG case needs an explicit `OFF`, not merely an unset policy. That also means the fix has to read the resolved policy rather than "the setting is absent", if it is going to gate on it. Two things I could not do here: flip the system policy to `OFF` (needs the Exploit protection UI plus a restart), and therefore check any candidate guard. If a fix lands, `Get-ProcessMitigation -System` output pasted next to the test result would be enough for me to tell you whether my host now takes the new path or still the asserting one. I am not sending a patch for this: without a host that reproduces it, anything I wrote would be a guess about which observed value goes missing, and the issue's own expectation is already precise.
Maxim-Root commented 2026-11-24 11:03:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Maxim-Root on 2026-11-24T10:44:34Z.


@ChazY11 thanks, that matches what I see. NOTSET is the Windows default, which enforces CFG for /guard:cf images, so the native cfg_record run replaces both slots and the old assertion holds. It fails only with an explicit Enable: OFF, as on the reporting host (Get-ProcessMitigation -System → Enable: OFF, build 26300.9818).

The fix in #1367 does not gate on the host setting at all, so there is no NOTSET/OFF distinction to get wrong. It starts the two /guard:cf images with an explicit per-process PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY. CFG is always on for the existing assertions, and always off as a negative control that must equal the images linked without /guard:cf. After each launch, the child's effective EnableControlFlowGuard bit (read through GetProcessMitigationPolicy) must match the requested policy. The test takes the same path on every host.

Measured with it so far:

  • Enable: OFF, build 26300 (here): passes. Before the change it failed.
  • Enable: NOTSET, Windows Server 2025 build 26100 (hosted windows-2025, fork-only probe run): passes 3/3.
  • @tedin7's Windows Server 2025 runs: Debug and /O2.

If you run ctest --preset dev --no-tests=error -R '^cpu_native_load_config_callback$' -V on the #1367 branch, a pass on your NOTSET 26300.9974 host would add the third combination. The cfg_record line should show Windows exit 0x30055 with CFG on and Windows with CFG off exit 0x55.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7129183552 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1366#issuecomment-7129183552). Originally posted by [Maxim-Root](https://github.com/Maxim-Root) on 2026-11-24T10:44:34Z. --- @ChazY11 thanks, that matches what I see. `NOTSET` is the Windows default, which enforces CFG for `/guard:cf` images, so the native `cfg_record` run replaces both slots and the old assertion holds. It fails only with an explicit `Enable: OFF`, as on the reporting host (`Get-ProcessMitigation -System` → `Enable: OFF`, build 26300.9818). The fix in #1367 does not gate on the host setting at all, so there is no `NOTSET`/`OFF` distinction to get wrong. It starts the two `/guard:cf` images with an explicit per-process `PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY`. CFG is always on for the existing assertions, and always off as a negative control that must equal the images linked without `/guard:cf`. After each launch, the child's effective `EnableControlFlowGuard` bit (read through `GetProcessMitigationPolicy`) must match the requested policy. The test takes the same path on every host. Measured with it so far: - `Enable: OFF`, build 26300 (here): passes. Before the change it failed. - `Enable: NOTSET`, Windows Server 2025 build 26100 (hosted `windows-2025`, [fork-only probe run](https://github.com/Maxim-Root/Xbox2Windows/actions/runs/45373932340)): passes 3/3. - @tedin7's Windows Server 2025 runs: Debug and `/O2`. If you run `ctest --preset dev --no-tests=error -R '^cpu_native_load_config_callback$' -V` on the #1367 branch, a pass on your `NOTSET` 26300.9974 host would add the third combination. The `cfg_record` line should show `Windows exit 0x30055` with CFG on and `Windows with CFG off exit 0x55`. AI-assisted (Claude Code).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#1359
No description provided.