libkernel: __elf_phdr_match_addr reads ModuleInfoEx as dl_phdr_info and crashes LEGO Voyagers (PPSA23732) #8675

Closed
opened 2026-10-20 20:45:49 +00:00 by Filip722 · 1 comment
Filip722 commented 2026-10-20 20:45:49 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Filip722 on 2026-10-20T20:45:49Z.


LEGO Voyagers (PPSA23732, 01.001.000) crashes on Linux in __elf_phdr_match_addr (Fjc4-n1+y2g). Its bundled libc passes the 0x1A8-byte object returned by sceKernelGetModuleInfoFromAddr; AnyPS5 treats that object as dl_phdr_info and reads module-name bytes as a program-header pointer. A standalone reproducer using only AnyPS5 and a tiny native fixture triggers the same SIGSEGV without any game files.

Tested upstream revision: a6a4101e190ec408c3ed471d20f06872cae1b4a3, full Release runtime, no other unmerged PRs applied. The title gets through Unity/Vulkan initialization, then crashes before reaching a menu. No fix or bypass was applied.

Evidence

  • The bundled libc calls sceKernelGetModuleInfoFromAddr (f7KBOafysXo) with flags 2 and a stack buffer, then passes the same buffer to __elf_phdr_match_addr. The two imports were verified against the relinker's generated registry.
  • Two debugger runs stopped at __elf_phdr_match_addr_nid_postfix+48, on cmpl $0x1,(%rax).
  • Argument 1 contains size 0x1A8, a name at offset 0x08, segment records at 0x160, and segment count at 0x1A0, matching ModuleInfoEx.
  • The helper reads dlpi_phdr from offset 0x10 and dlpi_phnum from 0x18. Those offsets lie inside the supplied object's name. Short names can mask the mismatch by producing a zero header count.

Public source at the tested revision:

Standalone reproduction

Save anyps5-module-information-fixture.cpp in the repository root:

extern "C" int module_information_anchor() { return 42; }

Save module-match-repro.cpp alongside it. The declaration deliberately uses the argument layout observed in the title's caller; both functions link to real AnyPS5 implementations.

#include "SceTypes.hpp"
#include <cstdio>
#include <dlfcn.h>

extern "C" {
int APS5_VABI sceKernelGetModuleInfoFromAddr(std::uint64_t address, int flags, ModuleInfoEx* info);
int APS5_VABI __elf_phdr_match_addr_nid_postfix(ModuleInfoEx* info, void* address);
}

int main() {
    ModuleInfoEx info{};
    info.st_size = sizeof(info);
    void* image = dlopen("./anyps5-module-information-fixture.so", RTLD_NOW);
    if (!image) { std::puts(dlerror()); return 2; }
    void* address = dlsym(image, "module_information_anchor");
    if (!address) return 2;
    const int queried = sceKernelGetModuleInfoFromAddr(reinterpret_cast<std::uint64_t>(address), 2, &info);
    std::printf("sceKernelGetModuleInfoFromAddr: %d, size=0x%llx, name=%s, segments=%u\n",
        queried, static_cast<unsigned long long>(info.st_size), info.name, info.segment_count);
    if (queried != 0) return 2;
    for (std::uint32_t i = 0; i < info.segment_count; ++i) {
        const auto& segment = info.segments[i];
        std::printf("segment %u: address=0x%llx size=0x%x prot=0x%x\n", i,
            static_cast<unsigned long long>(segment.address), segment.size, segment.prot);
    }
    std::puts("Passing the returned 0x1a8-byte object to __elf_phdr_match_addr, as the title's libc does");
    std::fflush(stdout);
    const int matched = __elf_phdr_match_addr_nid_postfix(&info, address);
    std::printf("match=%d\n", matched);
    return 0;
}

From the repository root, after configuring a full Release build in build/:

cmake --build build --target libs --parallel 2
g++ -shared -fPIC anyps5-module-information-fixture.cpp \
    -o anyps5-module-information-fixture.so

g++ -std=c++20 -O2 -I core/libs module-match-repro.cpp \
    -Wl,--no-as-needed \
    build/core/libs/libs/unpatched/libkernel.prx \
    build/core/libs/libs/unpatched/libc.prx \
    -Wl,-rpath,"$(pwd)/build/core/libs/libs/unpatched" -ldl \
    -o module-match-repro

gdb -q -batch -ex 'set pagination off' -ex run -ex 'bt 8' \
    --args ./module-match-repro

Observed, with machine addresses and paths omitted:

sceKernelGetModuleInfoFromAddr: 0, size=0x1a8, name=anyps5-module-information-fixture.so, segments=4
Passing the returned 0x1a8-byte object to __elf_phdr_match_addr, as the title's libc does
Program received signal SIGSEGV, Segmentation fault.
#0 __elf_phdr_match_addr_nid_postfix ()
#1 main ()

Expected: the helper accepts the module-info object passed by this observed caller without treating its name as a header pointer. Exact segment-matching boundaries still require ABI/behavior evidence before implementing a general correction.

Coverage gap

The existing GuestElfPhdrMatch.cpp test passes against the same libraries: it constructs a FreeBSD-style dl_phdr_info, so it does not exercise this caller's query-to-match sequence. The original implementation in #337 explicitly inferred that signature from FreeBSD without a title run.

This report establishes the caller/layout mismatch and Linux crash, not the complete console contract. No independent console-hardware verification, Windows/macOS run, full-suite run, or progress beyond this first title crash is claimed.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5949374756 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8675). Originally posted by [Filip722](https://github.com/Filip722) on 2026-10-20T20:45:49Z. --- LEGO Voyagers (PPSA23732, 01.001.000) crashes on Linux in `__elf_phdr_match_addr` (`Fjc4-n1+y2g`). Its bundled libc passes the 0x1A8-byte object returned by `sceKernelGetModuleInfoFromAddr`; AnyPS5 treats that object as `dl_phdr_info` and reads module-name bytes as a program-header pointer. A standalone reproducer using only AnyPS5 and a tiny native fixture triggers the same SIGSEGV without any game files. Tested upstream revision: `a6a4101e190ec408c3ed471d20f06872cae1b4a3`, full Release runtime, no other unmerged PRs applied. The title gets through Unity/Vulkan initialization, then crashes before reaching a menu. No fix or bypass was applied. ### Evidence - The bundled libc calls `sceKernelGetModuleInfoFromAddr` (`f7KBOafysXo`) with flags 2 and a stack buffer, then passes the same buffer to `__elf_phdr_match_addr`. The two imports were verified against the relinker's generated registry. - Two debugger runs stopped at `__elf_phdr_match_addr_nid_postfix+48`, on `cmpl $0x1,(%rax)`. - Argument 1 contains size `0x1A8`, a name at offset `0x08`, segment records at `0x160`, and segment count at `0x1A0`, matching `ModuleInfoEx`. - The helper reads `dlpi_phdr` from offset `0x10` and `dlpi_phnum` from `0x18`. Those offsets lie inside the supplied object's name. Short names can mask the mismatch by producing a zero header count. Public source at the tested revision: - [Helper](https://github.com/boykopovar/AnyPS5/blob/a6a4101e190ec408c3ed471d20f06872cae1b4a3/core/libs/prx/libkernel/Module/src/Module.cpp#L306) - [ModuleInfoEx](https://github.com/boykopovar/AnyPS5/blob/a6a4101e190ec408c3ed471d20f06872cae1b4a3/core/libs/SceTypes.hpp#L251) - [Module-info query](https://github.com/boykopovar/AnyPS5/blob/a6a4101e190ec408c3ed471d20f06872cae1b4a3/core/libs/prx/libkernel/Module/src/ModuleInfo.cpp#L394) ### Standalone reproduction Save `anyps5-module-information-fixture.cpp` in the repository root: ```cpp extern "C" int module_information_anchor() { return 42; } ``` Save `module-match-repro.cpp` alongside it. The declaration deliberately uses the argument layout observed in the title's caller; both functions link to real AnyPS5 implementations. ```cpp #include "SceTypes.hpp" #include <cstdio> #include <dlfcn.h> extern "C" { int APS5_VABI sceKernelGetModuleInfoFromAddr(std::uint64_t address, int flags, ModuleInfoEx* info); int APS5_VABI __elf_phdr_match_addr_nid_postfix(ModuleInfoEx* info, void* address); } int main() { ModuleInfoEx info{}; info.st_size = sizeof(info); void* image = dlopen("./anyps5-module-information-fixture.so", RTLD_NOW); if (!image) { std::puts(dlerror()); return 2; } void* address = dlsym(image, "module_information_anchor"); if (!address) return 2; const int queried = sceKernelGetModuleInfoFromAddr(reinterpret_cast<std::uint64_t>(address), 2, &info); std::printf("sceKernelGetModuleInfoFromAddr: %d, size=0x%llx, name=%s, segments=%u\n", queried, static_cast<unsigned long long>(info.st_size), info.name, info.segment_count); if (queried != 0) return 2; for (std::uint32_t i = 0; i < info.segment_count; ++i) { const auto& segment = info.segments[i]; std::printf("segment %u: address=0x%llx size=0x%x prot=0x%x\n", i, static_cast<unsigned long long>(segment.address), segment.size, segment.prot); } std::puts("Passing the returned 0x1a8-byte object to __elf_phdr_match_addr, as the title's libc does"); std::fflush(stdout); const int matched = __elf_phdr_match_addr_nid_postfix(&info, address); std::printf("match=%d\n", matched); return 0; } ``` From the repository root, after configuring a full Release build in `build/`: ```sh cmake --build build --target libs --parallel 2 g++ -shared -fPIC anyps5-module-information-fixture.cpp \ -o anyps5-module-information-fixture.so g++ -std=c++20 -O2 -I core/libs module-match-repro.cpp \ -Wl,--no-as-needed \ build/core/libs/libs/unpatched/libkernel.prx \ build/core/libs/libs/unpatched/libc.prx \ -Wl,-rpath,"$(pwd)/build/core/libs/libs/unpatched" -ldl \ -o module-match-repro gdb -q -batch -ex 'set pagination off' -ex run -ex 'bt 8' \ --args ./module-match-repro ``` Observed, with machine addresses and paths omitted: ```text sceKernelGetModuleInfoFromAddr: 0, size=0x1a8, name=anyps5-module-information-fixture.so, segments=4 Passing the returned 0x1a8-byte object to __elf_phdr_match_addr, as the title's libc does Program received signal SIGSEGV, Segmentation fault. #0 __elf_phdr_match_addr_nid_postfix () #1 main () ``` Expected: the helper accepts the module-info object passed by this observed caller without treating its name as a header pointer. Exact segment-matching boundaries still require ABI/behavior evidence before implementing a general correction. ### Coverage gap The existing `GuestElfPhdrMatch.cpp` test passes against the same libraries: it constructs a FreeBSD-style `dl_phdr_info`, so it does not exercise this caller's query-to-match sequence. The original implementation in #337 explicitly inferred that signature from FreeBSD without a title run. This report establishes the caller/layout mismatch and Linux crash, not the complete console contract. No independent console-hardware verification, Windows/macOS run, full-suite run, or progress beyond this first title crash is claimed. AI-assisted: yes.
MarcZX10 commented 2026-10-20 20:49:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T20:49:58Z.


I checked the reported layouts against ModuleInfoEx and the implementation of sceKernelGetModuleInfoFromAddr: the segment addresses are already relocated, size is the PT_LOAD memory span, and prot uses read=1/write=2/execute=4. I am preparing a narrowly scoped compatibility fix that accepts this exact sized ModuleInfoEx form while retaining the existing dl_phdr_info path and tests. This addresses the demonstrated crash without claiming broader console ABI confirmation. The focused regression builds, but this host cannot execute it because its CPU lacks AVX2/BMI2 and other required guest instruction support.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6301178375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8675#issuecomment-6301178375). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T20:49:58Z. --- I checked the reported layouts against `ModuleInfoEx` and the implementation of `sceKernelGetModuleInfoFromAddr`: the segment addresses are already relocated, `size` is the `PT_LOAD` memory span, and `prot` uses read=1/write=2/execute=4. I am preparing a narrowly scoped compatibility fix that accepts this exact sized `ModuleInfoEx` form while retaining the existing `dl_phdr_info` path and tests. This addresses the demonstrated crash without claiming broader console ABI confirmation. The focused regression builds, but this host cannot execute it because its CPU lacks AVX2/BMI2 and other required guest instruction support.
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
boykopovar/AnyPS5#8675
No description provided.