Windows: scoped kernel variant imports miss canonical libkernel providers #8853
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-21T03:13:08Z.
What fails
A synthetic Windows startup import of
getpagesize(k+AXqu2-eBc) resolves when qualified tolibkernel.prx, but fails when qualified tolibkernel_sys.prxorlibkernel_web.prx, even with canonical libkernel and libc explicitly loaded. Unqualified lookup with those same modules succeeds. The guest entry only returns zero; it does not invoke the import. No title, firmware binary or proprietary trace was used.Reproduction and results
Windows x86-64, GCC 15.2 Release. Relinker source is current main
e0e57a3270d3de4466266c06254a516cfe1cd7e2; local headaae12fa111174f7d27af06c96ec0e47ccae3c2c1additionally contains unrelated cfsetspeed changes, with no relinker changes. Libraries built locally from public source.Generate a PE using the existing WindowsImportBuilder, WindowsEntryStubBuilder and WindowsPeWriter. Set a strong PeImport to
{.Name="k+AXqu2-eBc", .TargetRva=got.Rva, .Addend=0, .Library=scope}and load{requested, "libkernel.prx", "libc.prx"}(deduplicating canonical libkernel). Use eager binding, a writable eight-byte GOT, and an executable guest entry{0x31,0xc0,0xc3}. The current builders supply all startup code. The complete generator is below.Both failures report
GetLastError: 127and searched libraries containing only the requested variant and libc. PE inspection confirms the NID exists in canonical libkernel and is absent from the variants/libc. An initial attempt failed earlier with missing compiler runtime DLLs; after copying the three MinGW runtime DLLs into this isolated libs directory, the controls and failures above were obtained. Sandbox image loading also required rerunning the generated probes outside the sandbox. Those initial failures are not evidence for this issue.Evidence and scope
Before implementing a fix, the host kernel-variant provider policy needs to be explicit: module-specific forwarding or a narrowly defined host-only alias must preserve requested-provider precedence, guest-module isolation, missing-symbol failure, and initialization/ownership semantics. I have not added duplicate implementations or assumed firmware modules are globally interchangeable.
AI-assisted investigation and reproduction.
Standalone generator (public AnyPS5 headers and relinker_core)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T03:34:53Z.
I traced the Windows search-table construction. A narrowly testable policy could be: for a scoped import whose requested host library is exactly
libkernel_sys.prxorlibkernel_web.prx, search that requested module first, then canonical hostlibkernel.prxif it is loaded, then the existinglibc.prxfallback. Keep guest modules out of this alias path and leave unqualified import ordering unchanged. Tests should prove (1) requested variant wins when it has the export, (2) canonical fallback resolvesgetpagesizewhen the variant lacks it, (3) missing in both still fails, and (4) a guest provider cannot satisfy this scoped import.That defines a host-provider fallback rule rather than claiming the firmware variants are interchangeable. The remaining policy question is whether this fallback is acceptable for all canonical libkernel exports or should be restricted to a reviewed allowlist; the current reproduction establishes only
getpagesize.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T03:43:36Z.
I opened #8867 with the narrowly scoped fallback discussed above. It searches the requested kernel variant first, then canonical host
libkernel.prx, and adds canonical libkernel to Windows dependencies for bothlibkernel_sysandlibkernel_web. The Linux relinker-onlyentry_stubtest and convention checks pass; hosted checks are starting. The PR does not claim all firmware variant exports are interchangeable.Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-21T04:05:54Z.
Independently tested #8867 on Windows x86-64, GCC15.2 Release, at exact head
fef2755c76cb1f567c82dfeaaf646b88e241c3a6versus base7ab4b2e5610c3d4328c83566cba488eb82972c9cin a separate checkout. Same generator source and locally built runtime libraries for both; no games or imported guest functions executed.The original four generated startup cases now all exit0: canonical scoped, sys scoped, web scoped and unqualified control. With dependency inference from only the requested variant, both scoped getpagesize cases also now pass. The PR's entry_stub and windows_dependency_diagnostics suites pass on Windows (2/2).
Two added cases still fail with0xc0000139 on both base and candidate:
libkernel_sys.prx, scoped__error(9BcDykPmo1I).libkernel_web.prx, same scoped import.The SDK lists __error in all three kernel variants. The locally built provider is shared libc. Candidate ReadLibraries produces
[variant, libkernel.prx]for these inputs, so the search table has no explicit libc handle even though the canonical module's dependency loads it. The canonical-only control produces[libkernel.prx, libc.prx]and resolves the same NID successfully.The libc-insertion condition runs before the inferred canonical dependency is appended. Dependency closure for an inferred kernel therefore leaves the existing shared-runtime fallback unavailable. These are remaining pre-existing failures, not a newly introduced regression; getpagesize is fixed by the proposed patch.
To reproduce with the source generator in the issue, construct
SysVDynamicSectionwith a single DT_NEEDED entry for the variant, obtainlibrariesfrom WindowsImportBuilder::ReadLibraries, and use PeImport{.Name="9BcDykPmo1I", .TargetRva=got.Rva, .Addend=0, .Library=variant}. The guest entry remains xor-eax/ret and does not call __error.Across the nine cases: base3 pass/6 unresolved; candidate7 pass/2 unresolved. Requested-provider precedence has a generated-byte-pattern assertion for sys in the added tests. Guest isolation has no added fixture there, and neither property was independently exercised with colliding native fixture providers in this run. This does not establish equivalence of all firmware variant exports or settle the allowlist policy question.
AI-assisted independent validation; no edits to the contributor's branch or changes to their authorship.
Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-21T04:10:55Z.
Follow-up at the same #8867 head: I added a separate native execution matrix with synthetic colliding DLL providers, using identical generator source for base and candidate. The expected return values are supplied by the fixtures, so these checks exercise binding policy without assuming firmware function behavior.
For each of sys and web, eight cases now execute:
Candidate matches all16 expected outcomes; base matches12/16, returning libc's43 instead of canonical kernel's29 in the four canonical-fallback cases. This adds runtime evidence for requested-provider precedence and guest isolation beyond the PR's byte-pattern assertion. The two variant-only __error dependency-closure failures from the nine-case real-library probe remain separate and unresolved at this head.
The complete standalone generator below links against relinker_core. Run it with a new output directory, then execute each generated probe.exe with APS5_MIMALLOC unset. Each fixture lives in its own directory and imports no firmware or proprietary module. Native shell runtime APIs are the only platform dependencies. AI-assisted validation, no changes to the contributor's branch.
Standalone synthetic provider generator
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T19:24:04Z.
Fixed by #8867: scoped libkernel_sys/libkernel_web imports now search canonical libkernel and libc, covered by
entry_stubandwindows_dependency_diagnostics.Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-22T14:20:29Z.
Confirmed that #8867 addressed the general scoped-provider fallback tracked here. The separate case where a variant's own throwing timed-join export shadows that fallback is covered by #9582 (depending on #8890), including actual sys/web-scoped import regressions. That follow-up does not require reopening this resolved general-loader issue.