fix(fex): invalidate translated code written through a later writable alias (#3020)

* fix(fex): invalidate translated code written through a later writable alias

x86-64 CoreCLR maps its W^X memfd writable after the executable view was
translated. Under SMCChecks=mtrack the new alias was never write-protected,
so writes through it did not invalidate stale translations. Protect the
overlapping part of an executable alias on mmap and mprotect.

* fix(fex): protect every writable alias in one mprotect range and build fmt without modules

* fix(fex): build without C++ module scanning or import std
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-22 12:22:11 -05:00
1 parent c6b6e7362e
commit fd2e1652ad
4 files changed
+301 -1

No files matched your search

+7
View File
@@ -197,6 +197,13 @@ alone would then read as an installed client.
restarted from the top forever (found with `perf_event_open` IP sampling, since proot holds
ptrace). Such a range is now skipped whole and a second exhausted scan returns `-ENOMEM`, as the
kernel does (`fex-2610-r3`).
- `0006-smc-alias-of-code-created-after-translation`: a JIT with a double-mapped memfd (CoreCLR's
W^X allocator) maps its writable alias after the executable alias was translated. Under
`SMCChecks=mtrack` the new alias was not write-protected, so writes through it never faulted and
never invalidated the translated code; x86-64 .NET programs ran stale code (access violations,
NullReferenceException, internal CLR errors). A writable mapping or mprotect now write-protects the
overlapping part of any alias that is already executable, so the first write faults and invalidates.
`FEX_SMCCHECKS=full` was the only workaround; no setting is needed with the patch.
- **Building and publishing.** Droid-Deck/DroidDeck-Components' `build-fex.yml` builds `tools/fex` from
this repository at a chosen ref (default `main`) with host thunks, in the same Arch Linux ARM container
with a read-only token, then a separate job replaces `fex.tzst` on Components' single `fex` release,