relinker, libkernel: ps5-payload-dev SDK payloads need a loader entry with kernel access (payload_args_t); in scope? #9381

Closed
opened 2026-10-21 19:49:21 +00:00 by rocklouis055 · 3 comments
rocklouis055 commented 2026-10-21 19:49:21 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by rocklouis055 on 2026-10-21T19:49:21Z.


Description

With #9234, an executable built with the ps5-payload-dev SDK links against libs/ on Linux (#9180), but it still cannot start: the SDK's startup code expects to be entered by a PS5 ELF loader with kernel access, not as a process. This is a question of scope, not a proposal: is the SDK payload entry something AnyPS5 should support?

What the SDK startup needs

The SDK's _start receives a payload_args_t* in rdi from the ELF loader (crt/payload.h):

typedef struct payload_args {
  int (*sys_dynlib_dlsym)(int, const char*, void*);
  int  *rwpipe;
  int  *rwpair;
  long  kpipe_addr;
  long  kdata_base_addr;
  int  *payloadout;
} payload_args_t;

payload_init in crt/crt.c then runs, in order:

  1. __crt_syscall_init (crt/syscall.c): calls args->sys_dynlib_dlsym for sceKernelDlsym and getpid, and uses getpid + 0xa as the address of a syscall instruction.
  2. __kernel_init (crt/kernel.c): requires the kernel read/write descriptors rwpipe/rwpair, kpipe_addr and kdata_base_addr, and derives kernel addresses from them per firmware version.
  3. __patch_init (crt/patch.c): patches the process credentials and the syscall permissions in kernel memory.
  4. __rtld_init and __rtld_lib_open: the SDK's own runtime linker, which reads the kernel's loaded-module objects with kernel_copyout (crt/rtld_sprx.c).

So supplying payload_args_t would need more than a sys_dynlib_dlsym: steps 2 to 4 read and write kernel memory.

Observed

Linux x86-64 (Ubuntu 26.04, GCC 15), Release, full libs of main 7280a17ec, relinker from #9234 at be51ab7, --to-intel --skip-sce-module --trap-sdk-syscall-stubs.

Payload Result
SDK samples/hello_world (v0.44, sha256 6fef85336910398c242baa1f0bae1bc2c318d4dc5da52817375d8a8defc75d5e) loads; SIGSEGV, exit 139, jump to 0x1 from +0x463 in __crt_syscall_init
LÖVE (pacbrew-repo v0.41.1, sha256 10ccd3ed1253cb92eb0fed3c93af3c474caef2a2e27267b7b6b7980d2fe9693f) loads; SIGSEGV, exit 139, jump to 0x1

Run as a process, rdi holds 1 at entry, which the startup dereferences as payload_args_t.

Not covered

Homebrew built as a title instead of a payload, such as the ps5link-sdk examples, imports by NID through the SCE dynamic tables and does not use this entry. Its gpu_cube example runs to its end on the same build.

Found with AI assistance (Claude Code); the commands and outputs above were run locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5967440514 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9381). Originally posted by [rocklouis055](https://github.com/rocklouis055) on 2026-10-21T19:49:21Z. --- ### Description With #9234, an executable built with the [ps5-payload-dev SDK](https://github.com/ps5-payload-dev/sdk) links against `libs/` on Linux (#9180), but it still cannot start: the SDK's startup code expects to be entered by a PS5 ELF loader with kernel access, not as a process. This is a question of scope, not a proposal: is the SDK payload entry something AnyPS5 should support? ### What the SDK startup needs The SDK's `_start` receives a `payload_args_t*` in `rdi` from the ELF loader ([crt/payload.h](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/payload.h)): ```c typedef struct payload_args { int (*sys_dynlib_dlsym)(int, const char*, void*); int *rwpipe; int *rwpair; long kpipe_addr; long kdata_base_addr; int *payloadout; } payload_args_t; ``` `payload_init` in [crt/crt.c](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/crt.c) then runs, in order: 1. `__crt_syscall_init` ([crt/syscall.c](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/syscall.c)): calls `args->sys_dynlib_dlsym` for `sceKernelDlsym` and `getpid`, and uses `getpid` + `0xa` as the address of a `syscall` instruction. 2. `__kernel_init` ([crt/kernel.c](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/kernel.c)): requires the kernel read/write descriptors `rwpipe`/`rwpair`, `kpipe_addr` and `kdata_base_addr`, and derives kernel addresses from them per firmware version. 3. `__patch_init` ([crt/patch.c](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/patch.c)): patches the process credentials and the syscall permissions in kernel memory. 4. `__rtld_init` and `__rtld_lib_open`: the SDK's own runtime linker, which reads the kernel's loaded-module objects with `kernel_copyout` ([crt/rtld_sprx.c](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/rtld_sprx.c)). So supplying `payload_args_t` would need more than a `sys_dynlib_dlsym`: steps 2 to 4 read and write kernel memory. ### Observed Linux x86-64 (Ubuntu 26.04, GCC 15), Release, full `libs` of `main` `7280a17ec`, relinker from #9234 at `be51ab7`, `--to-intel --skip-sce-module --trap-sdk-syscall-stubs`. | Payload | Result | | --- | --- | | SDK `samples/hello_world` (v0.44, sha256 `6fef85336910398c242baa1f0bae1bc2c318d4dc5da52817375d8a8defc75d5e`) | loads; SIGSEGV, exit 139, jump to `0x1` from `+0x463` in `__crt_syscall_init` | | LÖVE ([pacbrew-repo v0.41.1](https://github.com/ps5-payload-dev/pacbrew-repo/releases/tag/v0.41.1), sha256 `10ccd3ed1253cb92eb0fed3c93af3c474caef2a2e27267b7b6b7980d2fe9693f`) | loads; SIGSEGV, exit 139, jump to `0x1` | Run as a process, `rdi` holds `1` at entry, which the startup dereferences as `payload_args_t`. ### Not covered Homebrew built as a title instead of a payload, such as the [ps5link-sdk](https://github.com/Rufidj/ps5link-sdk) examples, imports by NID through the SCE dynamic tables and does not use this entry. Its `gpu_cube` example runs to its end on the same build. Found with AI assistance (Claude Code); the commands and outputs above were run locally.
MarcZX10 commented 2026-10-21 22:42:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T22:42:13Z.


For the scope decision, I recommend keeping direct ps5-payload-dev payload startup out of scope unless a future design can support its kernel-dependent startup without granting or emulating kernel read/write access. The issue traces payload_init beyond argument delivery into credential and syscall patching plus kernel-backed module lookup, so synthesizing payload_args_t alone would not make these payloads safe or functional. The existing --trap-sdk-syscall-stubs option is explicitly a debugging aid and traps if a wrapper executes; it is not a payload runtime. The issue also separates title-built homebrew that uses SCE imports, which remains testable through the normal path. If maintainers agree, documenting this boundary and closing as out of scope seems clearer than implementing a partial loader.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328171099 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9381#issuecomment-6328171099). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T22:42:13Z. --- For the scope decision, I recommend keeping direct `ps5-payload-dev` payload startup out of scope unless a future design can support its kernel-dependent startup without granting or emulating kernel read/write access. The issue traces `payload_init` beyond argument delivery into credential and syscall patching plus kernel-backed module lookup, so synthesizing `payload_args_t` alone would not make these payloads safe or functional. The existing `--trap-sdk-syscall-stubs` option is explicitly a debugging aid and traps if a wrapper executes; it is not a payload runtime. The issue also separates title-built homebrew that uses SCE imports, which remains testable through the normal path. If maintainers agree, documenting this boundary and closing as out of scope seems clearer than implementing a partial loader.
MarcZX10 commented 2026-10-22 01:17:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:17:32Z.


The issue’s trace shows payload startup immediately proceeds from payload_args_t into kernel read/write descriptor use, credential/syscall patching and kernel-backed module lookup. A loader entry alone would not make this payload model safe or complete. The title-built homebrew path is explicitly distinct and already works through normal SCE imports. I recommend treating direct ps5-payload-dev payload startup as out of scope unless maintainers want a separately designed kernel model; no implementation PR appears justified by the current evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330314465 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9381#issuecomment-6330314465). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:17:32Z. --- The issue’s trace shows payload startup immediately proceeds from `payload_args_t` into kernel read/write descriptor use, credential/syscall patching and kernel-backed module lookup. A loader entry alone would not make this payload model safe or complete. The title-built homebrew path is explicitly distinct and already works through normal SCE imports. I recommend treating direct `ps5-payload-dev` payload startup as out of scope unless maintainers want a separately designed kernel model; no implementation PR appears justified by the current evidence.
rocklouis055 commented 2026-10-22 06:15:03 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by rocklouis055 on 2026-10-22T06:15:03Z.


Agreed, thanks @MarcZX10. I have no use case that needs the payload entry; title-built homebrew covers my testing. Happy for this to be closed as out of scope, or kept open only if maintainers want the boundary documented first.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6334130671 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9381#issuecomment-6334130671). Originally posted by [rocklouis055](https://github.com/rocklouis055) on 2026-10-22T06:15:03Z. --- Agreed, thanks @MarcZX10. I have no use case that needs the payload entry; title-built homebrew covers my testing. Happy for this to be closed as out of scope, or kept open only if maintainers want the boundary documented first.
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#9381
No description provided.