sceKernelLoadStartModule discards the module parameter block, so modules that validate it fault at start-up #918
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 jeffrey12cali on 2026-10-06T16:39:58Z.
Symptom
On Linux a title's own module faults inside its start-up path immediately after being loaded. Measured on PPSA28997, in its
PSN.prx:The faulting helper is a parameter validator. Its own strings identify the handshake:
Disassembly of the entry (
PSN+0x3e86):So the module expects a 16-byte, version-
0x200parameter block at start-up, never receives one, and its error path then dereferences the missing block.Cause
sceKernelLoadStartModuleaccepts the parameter block and throws it away (core/libs/prx/libkernel/Module/src/Module.cpp):sceKernelStopUnloadModulediscardsargs/argp/flags/optthe same way. Nothing in the tree forwards a module parameter block to a guest module's start routine - the Windows.ginitlifecycle hook (DynamicLoader.cpp) invokes the lifecycle functions but passes no arguments either. On PS5 the module's entry receives(args, argp), so any title that hands its modules a parameter struct cannot work: the module sees a null block and, in this case, crashes in its own unchecked error path.Expected
LoadStartModuleshould retain(args, argp)for the load it is performing and pass them to the module's start entry (the same entry the.ginitlifecycle runs on Windows), andStopUnloadModuleshould pass its pair to the stop entry. Theflags/optfields likely want at least validation, andresshould carry the module's own result rather than being pinned to 0.Notes
.nativewrapper dependency edge), which is what prevents this module from loading at all; with that worked around, the module loads and then hits this.sceKernelLoadStartModulecall site that passes a non-zeroargsis affected. In this title the parameter block is 16 bytes with a0x200version field, i.e. a versioned struct rather than a string or handle.LoadStartModulethrough to that call rather than intodlopen).Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-06T16:48:32Z.
Adding the measurement, since it strengthens the case: the title really does pass a parameter block, and it passes it to exactly the modules that then misbehave. Breakpoint on
libs/libkernel.prx+0x54a60(sceKernelLoadStartModule), readingrsi/rdxat entry:So the block is
0x34bytes (not the0x10in my earlier note - that is a nested struct the module validates inside the payload, which is why the helper checkssize == 0x10andversion == 0x200), it is the same block for all three modules, andsceKernelLoadStartModuledrops it on the floor. The module's start entry therefore sees a null parameter pointer and takes its own "old version / plugin args version" error path, which dereferences it unchecked.Two notes for whoever picks this up:
PS5Util.prxis loaded withargs = 0, so the plumbing has to tolerate a genuinely empty parameter block as well - it is not simply "always pass the pointer".(args, argp)to a module's start entry on either platform (the Windows.ginitlifecycle hook calls the entry with no arguments either), so this is likely latent on Windows too and only visible here because this title's module validates the block hard. Happy to test a Windows-side build if that helps confirm.Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-06T17:07:23Z.
Two questions, because the fix needs a piece that the conversion currently drops.
1. How should the PRX start entry be surfaced so
LoadStartModulecan call it with(args, argp)?I tried to wire the parameter block through on our side and stopped at a hard blocker: the converted module exposes no callable start entry.
app0/sce_module/PSN.prx.guest.prxe_entry0x0readelf -Syields nothing)DT_INIT_ARRAYDT_INIT = 0xb24c8,DT_FINI = 0xb24d3DT_INITtargetPT_LOAD(vaddr 0x88000, file0xb64c8), and disassembles as data, not a prologueSo there is no ELF lifecycle hook that could receive
(args, argp)even ifLoadStartModulekept them. The relinker clearly sees the real entry -analysis/CodeInstructionCollector.cppparsesPT_PRX(p_type 0x6100003b) and reads an entry field out of it - so the information exists at conversion time. Would you take a relinker change that preserves it (exported symbol at a known name, or a pointer in a section the loader can find), and then haveLoadStartModulecall it afterdlopen? Or do you have a different place in mind for that handoff?I would rather not guess the entry's calling convention: the module's validator checks a nested
size == 0x10/version == 0x200struct, so a wrong register layout corrupts guest memory silently instead of failing loudly.2. Is the discard latent on Windows too?
(void)args; (void)argp;is unconditional, and the Windows.ginitlifecycle path (RunDeferredLifecycle) invokes the lifecycle function with no arguments either - so I expect Windows to hit the same wall, and to be reaching PSN by a different route (its import table rather thanLoadStartModule). I am testing that on the win64 build now and will report the result here either way; if Windows really does never reach the validator, then this is a Linux-only-visible bug with a shared cause, which changes how you might want to fix it.Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-06T17:08:54Z.
Answering my own question 2 from the Windows build of this title (win64 release, same commit as our vendored tree), because it changes what the fix should be.
Windows hits the exact same missing-parameters condition and survives it. Its log:
So the parameter block is missing on Windows too (the title's own validator reports
found 0000/found 0), and the game tolerates PSN being unusable - it prints the error and carries on. Nothing about NP has to be implemented to get past this.The difference is when the validator runs.
Loading PRX ... -> OK, returnsdlopennever returns - the title faults atPSN+0x3e86inside the loadrsi = 0→ error path dereferencesrbx+4→ SIGSEGVRunDeferredLifecyclecalls the.ginitentry asfn(0, 0, 0), so Windows also passes no real arguments - but it reaches the validator through a path where the descriptor pointer is a valid zeroed block, whereas on Linux the same code is reached from the module's load-time init with a nullrsi.That reframes the ask: the problem is not only that
LoadStartModuledrops(args, argp), but that on Linux the PRX start appears to be wired into the ELF load-time init (DT_INIT), so it executes duringdlopenwith whatever registers ld.so left, instead of being called byLoadStartModulewith the caller's block. Fixing the discard without fixing the timing would still leave the module running its entry with the wrong arguments.So the question from (1) becomes sharper: where should the PRX entry live in the converted ELF - is it currently being emitted as
DT_INIT, and would you rather it be exposed as a named symbol thatLoadStartModulecalls with(args, argp, flags, opt, res)afterdlopen?Meanwhile the practical consequence for us: this title does not need NP implemented to boot. It needs PSN's start entry to be invoked the way the platform invokes it.
Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-06T18:16:16Z.
Correction to my previous comment - I asserted that on Windows "the validator runs later with a readable zeroed descriptor" while Linux gets null. That was an inference from the log text, and it is wrong. Measured directly:
DT_INITis a relinker-generated trampoline, not module code:31 ff 31 f6 31 d2 e9 <rel32>=xor edi,edi; xor esi,esi; xor edx,edx; jmp <start>, and the target is vaddr0x10..ginitentry holds RVA0x10010- the same start function (the image base offset accounts for the difference).RunDeferredLifecyclecalls it asfn(0, 0, 0), so both platforms pass(0, 0, 0).55 48 89 e5 41 57 41 56 41 55 41 54 53 50 4c 8d 3d ...), and its prologue keepsrdi -> r14,rsi -> rbx,rdx -> r13- so both enter it with all three null.So the difference is not the arguments. What I can still stand behind from that comment:
LoadStartModulegenuinely discards(args, argp)(measured: the title passes a shared0x34-byte block to three modules), and on Linux the module's start executes inside_dl_initduringdlopen(core-dump stack). The Windows-vs-Linux behavioural gap must come from something else - the log line "Plugin args version, found 0000" exists on Windows, so the same validator runs there and returns instead of faulting, which means the null-descriptor error path is not the whole story.I tried passing a non-null zeroed descriptor by rewriting the 14-byte Linux trampoline in place (
xor edi,edi; lea rsi,[rip+zero_block]; jmp start, with the block in the module's zero-filled RW slack). It changed the failure mode rather than fixing it - the run now stops earlier and PSN is not reached at all - so that is not the answer either, and I am dropping that experiment.Leaving the core ask unchanged:
LoadStartModuleshould deliver(args, argp)to the module start, and the start currently runs duringdlopenwhere no caller arguments can reach it. Those are both real. My explanation of why Windows survives was not.Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-06T18:16:17Z.
Adding the decisive evidence for the "why does Windows survive" part of my correction, since it comes from generated code rather than from log text.
WindowsGuestStartup::callLifecycle(core/relinker/elfpatcher/src/windows/WindowsGuestStartup.cpp) emits the lifecycle invocation as raw bytes:That is the same argument setup the relinker emits for the Linux
DT_INITtrampoline (31 ff 31 f6 31 d2 e9 rel32), so both platforms enter the module start with all three arguments null - and the start body is byte-identical between the two builds (first 48 bytes at the target match exactly).So to be precise about what this issue is and is not:
sceKernelLoadStartModulediscards(args, argp)that the title demonstrably passes (a shared0x34-byte block toIl2cppUserAssemblies,lib_burst_generatedandPSN; none toPS5Util). Any module that reads its parameter block cannot work.lea r15,[table] … add r15,8 … mov rax,[r15]; test rax,rax) and the faulting validator has zero direct call sites in the module - it is reachable only through that table. So what differs is the table's contents at the moment the start runs, not the arguments.Keeping the ask as is: preserve the PRX start entry through conversion and deliver
(args, argp)to it. Just not overselling it as the cause of this particular crash.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-06T22:50:25Z.
Before investing in this: @jeffrey12cali you wrote that you could prototype the plumbing if pointed at the right place — are you still planning to send this as a PR? If so I will stay out. If not, I would like to take it.
For context, I opened #1001 for #948 (the heap finalization ordering). I will leave this one alone until you answer.
Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-06T23:08:59Z.
Yes, I am taking this one — please don't spend your time on it, and thank you for asking before starting.
What I can hand over immediately, measured on PPSA28997 through the native Linux relink path:
sceKernelLoadStartModulewithargs=0x34andargp=0x200022aa0for three of its own modules (Il2cppUserAssemblies.prx,lib_burst_generated.prx,PSN.prx); the fourth (PS5Util.prx) getsargs=0. All three share the one 0x34-byte block. Bothargsandargpare discarded today ((void)args; (void)argp;).InitializeDeferredModulereads__aps5_guest_initializewithGetProcAddressand calls it with(args, argp, nullptr). That half is Windows-only (HMODULE,GetProcAddress), so the Linux half is genuinely free, and I would rather converge on the same exported name than invent a second one.The shape I plan to send: the relinker's Linux writer exports the module's initialisation entry as
__aps5_guest_initializeand stops lettingDT_INITrun it, so the loader can pass arguments;sceKernelLoadStartModulelooks the symbol up, calls it withargs/argpand stores the result in*res, falling back to the currentDT_INITbehaviour when the symbol is absent so modules that only ever usedDT_INITkeep working.Why it matters for this title: its
PSNmodule validates that parameter block in its start-up path and, with nothing delivered, faults on a null descriptor (rip = PSN+0x3ee7,rbx = 0). The Windows target of the same toolchain printsPlugin args version, found 0000, expected 0200from the same code and continues — so delivering the block is what turns a fault into a handled error. I do not need the online subsystem to work, only to fail the way the reference does.I will post the PR here with a test that fails on
main. If you have already started, say so and I will rebase onto yours instead.Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-07T09:35:06Z.
Progress note on the PR I said I would send, plus proof that the missing arguments are fatal rather than cosmetic - on a second, independent module.
Making the three deferred modules start-up dependencies here produced a one-second, pre-
mainsegfault instead of a slow stall. From the core, with the PC attributed through the core's own mappings:So
SaveDatadereferencesargpas the first thing its start-up path does, with the samesize >= 0x10/*argp == 0x10validation I had already mapped insidePSN(PSN+0x3ee7,rbx = 0). Two modules, same contract.The zeroing is ours, not the title's.
core/relinker/elfpatcher/src/linux/LinuxGuestModuleWriter.cppsynthesizes the initialisation trampoline:so on Linux
DT_INITis built to clearargs/argpbefore jumping to the guest entry point.WindowsGuestStartup.cpphas the counterpart, and #846 turns that one into an exported__aps5_guest_initializecalled with the arguments - Windows only.The plan for the Linux half, which I would like to keep naming-compatible with #846:
libkernelholds a pending(args, argp)pair;sceKernelLoadStartModulesets it under a lock beforedlopen, clears it after, and writes the module's returned status to*res.libkernelreturning that pair, added to the NID patcher's exclusion list so the rename step leaves the plain name alone.lifecycle()above emitscall <accessor>thenmov rdi,rax/mov rsi,rdx/xor edx,edxbefore the existingjmp- one extra undefined symbol and oneR_X86_64_JUMP_SLOT, inside the.dynsym/.hash/RelaDatamachinery the writer already builds.DT_NEEDED) keep getting(0,0), because that is what both platforms already do for them and it is demonstrably survivable there.Two notes for anyone reading before the PR lands. First, eager loading is not a workaround: with these modules in
DT_NEEDEDnobody has calledsceKernelLoadStartModuleyet, so there is no pending pair to deliver and the same trampoline faults - which is why the launcher's defer list exists. Second, on this title the practical stakes are large: the game blocks retryingPSN's load, so untilargs/argparrive (or the module can be made to fail cleanly the way the Windows branch does), the title never reaches its controller or save-data work.@Dextroid17 if #846 introduces a name for the pending-arguments accessor, tell me and I will use it instead of inventing one, so the two platforms converge on one convention rather than two.
Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-07T11:24:53Z.
Sent as #1102 with the measurements from this thread. Summary of the shape (my previous comment lost its code formatting to the shell, so restating it properly):
sceKernelLoadStartModuleparks{args, argp}under a mutex beforedlopenand clears it afterwards, and reports the initializer's return value through*resinstead of leaving it at 0.DT_INIT/DT_FINIstub no longer clearsedi/esi/edx. It reads the parked pair through two accessors exported by libkernel, thencalls the module's real initializer so its return value is observable.(0, 0), which is what both platforms do for them today._nid_no_patch, asCONTRIBUTING.mdprescribes for helper symbols that must not become NIDs - without the suffixResolveNidshashes the export into a NID name and the guest's plain-name import cannot resolve. That is what happened on the first attempt here.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T03:07:41Z.
Fixed by #1102:
sceKernelLoadStartModulenow handsargs/argpto the module initialiser on Linux and returns its result inres.sceKernelStopUnloadModulestill drops its pair; open a new issue if a title needs that.Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-10T11:02:57Z.
Confirming the load side for a second title:
PPSA28997reaches its main menu with the parameter blockpassed, and the
guest_module_argstest in #1102 is the regression we were missing.On
sceKernelStopUnloadModule, I have to be explicit that we have not measured it. I looked for the call inour run log first, found nothing, and discarded that result:
sceKernelLoadStartModuleis equally absent fromthe same log, and this title certainly calls it. The module lifecycle entry points are not traced in our
build, and the guest modules import by NID rather than by name, so a string scan of the module binaries does
not answer it either. We therefore cannot say whether this title needs the stop side, and I am not opening an
issue on that basis. If a title is ever observed unloading a module, we will file it with the call evidence.