relinker: the SDK SYS_mount stub is not trapped, so two public ps5-payload-dev payloads do not convert #8624

Closed
opened 2026-10-20 18:51:12 +00:00 by javierUDP · 5 comments
javierUDP commented 2026-10-20 18:51:12 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by javierUDP on 2026-10-20T18:51:12Z.


--trap-sdk-syscall-stubs recognizes the ps5-payload-dev SDK syscall stubs, and on two of that project's public payloads it traps 233 of them and then stops at one more it does not know: the inline SYS_mount stub.

Where

The payloads are published as ELFs in the ps5-payload-dev releases, so no dump is needed.

image release sha256
ftpsrv-ps5.elf ftpsrv v0.21.1 7d4b31c83eae4e056580482a3a074e1db25922efc74ac1e439473b45d71a5938
websrv-ps5.elf websrv v0.35 25501b41887a42789792d1367edd2fc892454bfe6b0b1519bc36456a581f264c

On main 892a4f132, with --windows --skip-sce-module:

image without the option with --trap-sdk-syscall-stubs stubs trapped
ftpsrv-ps5 refused at 0x60c7 refused at 0x709a 233
websrv-ps5 refused at 0x2707 refused at 0xae6a 233
elfldr-ps5 refused at 0x2187 converts 233
shsrv-ps5 refused at 0x6c7 converts 233
ftpsrv-ps5-install converts converts 0

--macos and the Linux target refuse at the same offsets.

The sequence

The bytes before the syscall at those two offsets are identical in both images:

48 63 d2                      movslq %edx, %rdx
31 db                         xorl   %ebx, %ebx
b8 15 00 00 00                movl   $21, %eax
49 89 ca                      movq   %rcx, %r10
45 31 c0                      xorl   %r8d, %r8d
45 31 c9                      xorl   %r9d, %r9d
0f 05                         syscall
0f 93 c1                      setae  %cl
49 89 c6                      movq   %rax, %r14
49 f7 de                      negq   %r14
84 c9                         testb  %cl, %cl

21 is SYS_mount in the SDK's own include/freebsd/sys/syscall.h. The shape matches the three mman.c sequences IsSdkMmanSyscallStub already knows, arguments then syscall then the carry-flag error path, and it is not the generic stub either, since it does not end in syscall; ret.

What this is not

Every other syscall in these images is already handled: 233 of them match SDK_GENERIC_SYSCALL_STUB and are trapped. This is one sequence short of converting both images.

What I am not asking for

Whether mount belongs in that list is a design call, not an omission to patch blindly: the technical debt entry says other SDK output stays rejected on purpose, and a payload that mounts a filesystem is further from a title than mmap and mprotect are. Recognizing it would only let the rest of the image convert, since a trapped syscall becomes UD2 and still faults when called.

Posting the measurements so the decision has them. If adding a fourth sequence is wanted, I can send it with a test.

Apple M5, macOS 26.4, AppleClang 21.0.0, relinker-only build. AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5947599843 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8624). Originally posted by [javierUDP](https://github.com/javierUDP) on 2026-10-20T18:51:12Z. --- `--trap-sdk-syscall-stubs` recognizes the ps5-payload-dev SDK syscall stubs, and on two of that project's public payloads it traps 233 of them and then stops at one more it does not know: the inline `SYS_mount` stub. ### Where The payloads are published as ELFs in the ps5-payload-dev releases, so no dump is needed. | image | release | sha256 | | --- | --- | --- | | `ftpsrv-ps5.elf` | [ftpsrv v0.21.1](https://github.com/ps5-payload-dev/ftpsrv/releases/tag/v0.21.1) | `7d4b31c83eae4e056580482a3a074e1db25922efc74ac1e439473b45d71a5938` | | `websrv-ps5.elf` | [websrv v0.35](https://github.com/ps5-payload-dev/websrv/releases/tag/v0.35) | `25501b41887a42789792d1367edd2fc892454bfe6b0b1519bc36456a581f264c` | On `main` `892a4f132`, with `--windows --skip-sce-module`: | image | without the option | with `--trap-sdk-syscall-stubs` | stubs trapped | | --- | --- | --- | --- | | `ftpsrv-ps5` | refused at `0x60c7` | **refused at `0x709a`** | 233 | | `websrv-ps5` | refused at `0x2707` | **refused at `0xae6a`** | 233 | | `elfldr-ps5` | refused at `0x2187` | converts | 233 | | `shsrv-ps5` | refused at `0x6c7` | converts | 233 | | `ftpsrv-ps5-install` | converts | converts | 0 | `--macos` and the Linux target refuse at the same offsets. ### The sequence The bytes before the `syscall` at those two offsets are identical in both images: ``` 48 63 d2 movslq %edx, %rdx 31 db xorl %ebx, %ebx b8 15 00 00 00 movl $21, %eax 49 89 ca movq %rcx, %r10 45 31 c0 xorl %r8d, %r8d 45 31 c9 xorl %r9d, %r9d 0f 05 syscall 0f 93 c1 setae %cl 49 89 c6 movq %rax, %r14 49 f7 de negq %r14 84 c9 testb %cl, %cl ``` `21` is `SYS_mount` in the SDK's own `include/freebsd/sys/syscall.h`. The shape matches the three `mman.c` sequences `IsSdkMmanSyscallStub` already knows, arguments then `syscall` then the carry-flag error path, and it is not the generic stub either, since it does not end in `syscall; ret`. ### What this is not Every other syscall in these images is already handled: 233 of them match `SDK_GENERIC_SYSCALL_STUB` and are trapped. This is one sequence short of converting both images. ### What I am not asking for Whether `mount` belongs in that list is a design call, not an omission to patch blindly: the technical debt entry says other SDK output stays rejected on purpose, and a payload that mounts a filesystem is further from a title than `mmap` and `mprotect` are. Recognizing it would only let the rest of the image convert, since a trapped syscall becomes `UD2` and still faults when called. Posting the measurements so the decision has them. If adding a fourth sequence is wanted, I can send it with a test. Apple M5, macOS 26.4, AppleClang 21.0.0, relinker-only build. AI-assisted: yes.
MarcZX10 commented 2026-10-20 19:26:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T19:26:10Z.


I checked the current contract before weighing in: SyscallScanner.cpp documents three exact inline sequences from SDK mman.c (syscall 74 and both 477 paths), and docs/user/USAGE.md describes --trap-sdk-syscall-stubs as recognizing mmap/mprotect sequences while rejecting other syscall instructions. Since a trapped call still becomes UD2, adding SYS_mount would broaden the opt-in beyond its documented memory-management scope and let an image convert even though a called mount still faults. I think keeping this one rejected is consistent with the current debug-only contract; the two payload measurements are useful evidence if maintainers want to broaden that contract deliberately.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6299406848 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8624#issuecomment-6299406848). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T19:26:10Z. --- I checked the current contract before weighing in: `SyscallScanner.cpp` documents three exact inline sequences from SDK `mman.c` (syscall 74 and both 477 paths), and `docs/user/USAGE.md` describes `--trap-sdk-syscall-stubs` as recognizing mmap/mprotect sequences while rejecting other syscall instructions. Since a trapped call still becomes `UD2`, adding `SYS_mount` would broaden the opt-in beyond its documented memory-management scope and let an image convert even though a called mount still faults. I think keeping this one rejected is consistent with the current debug-only contract; the two payload measurements are useful evidence if maintainers want to broaden that contract deliberately.
kaiffeetasse commented 2026-10-20 23:02:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by kaiffeetasse on 2026-10-20T23:02:35Z.


Data for the open design question in #8729: SYS_mount is not the last blocker in either payload.

Both payloads also inline __syscall6 for nmount (0x17a) and unmount (0x16), and the scan stops at the next one:

payload mount nmount unmount
ftpsrv v0.21.1 0x709a 0x70ec 0x713c
websrv v0.35 0xae6a 0xaebc 0xaf0c

Measured locally: recognizing only the mount sequence (the scope of #8729) still fails at 0x70ec on ftpsrv and 0xaebc on websrv, both FAIL: Forbidden syscall instruction. Recognizing all three converts both payloads with exit 0 (239 and 236 trapped sites).

The three wrappers do not share one byte sequence apart from the number: they differ in argument preparation (mount: movslq %edx,%rdx ... mov %rcx,%r10; nmount: mov %esi,%esi ... xor %r10d,%r10d; unmount: movslq %esi,%rsi ... xor %edx,%edx). So one pattern with only the four-byte number immediate masked cannot cover them; each needs its own sequence, with its number masked so an SDK build that renumbers the call still matches. All three come from __syscall6 in ps5-payload-dev/sdk libc/mount.c (7116a650a0).

If maintainers extend the opt-in, I have that three-wrapper change ready (scanner, fixture with a different-number case, debt entry, USAGE line) and can open one PR for it, or hand the sequences to #8729 so the two do not overlap. If not, this remains a diagnostic gap and neither payload converts.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303726056 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8624#issuecomment-6303726056). Originally posted by [kaiffeetasse](https://github.com/kaiffeetasse) on 2026-10-20T23:02:35Z. --- Data for the open design question in #8729: `SYS_mount` is not the last blocker in either payload. Both payloads also inline `__syscall6` for `nmount` (0x17a) and `unmount` (0x16), and the scan stops at the next one: | payload | mount | nmount | unmount | | --- | --- | --- | --- | | ftpsrv v0.21.1 | 0x709a | 0x70ec | 0x713c | | websrv v0.35 | 0xae6a | 0xaebc | 0xaf0c | Measured locally: recognizing only the mount sequence (the scope of #8729) still fails at 0x70ec on ftpsrv and 0xaebc on websrv, both `FAIL: Forbidden syscall instruction`. Recognizing all three converts both payloads with exit 0 (239 and 236 trapped sites). The three wrappers do not share one byte sequence apart from the number: they differ in argument preparation (`mount`: `movslq %edx,%rdx` ... `mov %rcx,%r10`; `nmount`: `mov %esi,%esi` ... `xor %r10d,%r10d`; `unmount`: `movslq %esi,%rsi` ... `xor %edx,%edx`). So one pattern with only the four-byte number immediate masked cannot cover them; each needs its own sequence, with its number masked so an SDK build that renumbers the call still matches. All three come from `__syscall6` in ps5-payload-dev/sdk `libc/mount.c` (7116a650a0). If maintainers extend the opt-in, I have that three-wrapper change ready (scanner, fixture with a different-number case, debt entry, USAGE line) and can open one PR for it, or hand the sequences to #8729 so the two do not overlap. If not, this remains a diagnostic gap and neither payload converts. AI-assisted: yes
hyvvs commented 2026-10-20 23:34:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-10-20T23:34:22Z.


@kaiffeetasse Thanks for testing both payloads and offering to share the implementation!

I'd be happy to incorporate the additional patterns and tests into #8729 if the maintainers approve extending the syscall trapping behavior. That way we can avoid overlapping PRs.

I'll keep the PR as a draft until we get a decision.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304200138 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8624#issuecomment-6304200138). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-10-20T23:34:22Z. --- @kaiffeetasse Thanks for testing both payloads and offering to share the implementation! I'd be happy to incorporate the additional patterns and tests into #8729 if the maintainers approve extending the syscall trapping behavior. That way we can avoid overlapping PRs. I'll keep the PR as a draft until we get a decision.
mpratsaki commented 2026-10-21 11:06:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by mpratsaki on 2026-10-21T11:06:15Z.


More data for the scope question: four more public ps5-payload-dev payloads stop on the same wrapper, and in these the mount family is the only blocker.

On main 2abfb1beb (Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release), with and without --trap-sdk-syscall-stubs, for --windows and the Linux target, each stops with FAIL: Forbidden syscall instruction at its mount wrapper (mov eax, 0x15, the same bytes as in the issue). objdump -d shows exactly three syscall instructions in each image, the mount, nmount and unmount wrappers, and no SDK mman.c stubs:

image release sha256 mount nmount unmount
launchpad-install.elf launchpad v0.2 5f53da68…afed02 0x4aa 0x4fc 0x54c
plutotv-install.elf plutotv v0.2 278fca81…ba756f4 0x63a 0x68c 0x6dc
svtplay-install.elf svtplay v0.3 31f2caac…603b56832 0x4ba 0x50c 0x55c
tv4play-install.elf tv4play v0.2 8e93a551…137fc43ea 0x63a 0x68c 0x6dc

All four are installers: the wrappers sit next to install_app, and their job is to set the app up on the console, so a converted image would most likely reach the trapped calls. A mount-only trap would still stop all four at nmount, as with ftpsrv and websrv.

For comparison, from the same releases: gdbsrv-ps5.elf, klogsrv-ps5.elf, and the websrv bundles EDuke32 and Wolf4SDL (both .elfs) convert only with --trap-sdk-syscall-stubs; LakeSnes, Omnispeak, OpenJazz and PKGInstall convert without it. Conversion only, nothing was run.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6314408098 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8624#issuecomment-6314408098). Originally posted by [mpratsaki](https://github.com/mpratsaki) on 2026-10-21T11:06:15Z. --- More data for the scope question: four more public ps5-payload-dev payloads stop on the same wrapper, and in these the mount family is the only blocker. On `main` `2abfb1beb` (Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release), with and without `--trap-sdk-syscall-stubs`, for `--windows` and the Linux target, each stops with `FAIL: Forbidden syscall instruction` at its `mount` wrapper (`mov eax, 0x15`, the same bytes as in the issue). `objdump -d` shows exactly three `syscall` instructions in each image, the `mount`, `nmount` and `unmount` wrappers, and no SDK `mman.c` stubs: | image | release | sha256 | mount | nmount | unmount | | --- | --- | --- | --- | --- | --- | | `launchpad-install.elf` | launchpad v0.2 | `5f53da68…afed02` | 0x4aa | 0x4fc | 0x54c | | `plutotv-install.elf` | plutotv v0.2 | `278fca81…ba756f4` | 0x63a | 0x68c | 0x6dc | | `svtplay-install.elf` | svtplay v0.3 | `31f2caac…603b56832` | 0x4ba | 0x50c | 0x55c | | `tv4play-install.elf` | tv4play v0.2 | `8e93a551…137fc43ea` | 0x63a | 0x68c | 0x6dc | All four are installers: the wrappers sit next to `install_app`, and their job is to set the app up on the console, so a converted image would most likely reach the trapped calls. A mount-only trap would still stop all four at `nmount`, as with ftpsrv and websrv. For comparison, from the same releases: `gdbsrv-ps5.elf`, `klogsrv-ps5.elf`, and the websrv bundles EDuke32 and Wolf4SDL (both `.elf`s) convert only with `--trap-sdk-syscall-stubs`; LakeSnes, Omnispeak, OpenJazz and PKGInstall convert without it. Conversion only, nothing was run. AI-assisted: yes (Claude Code).
kaiffeetasse commented 2026-10-21 11:35:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by kaiffeetasse on 2026-10-21T11:35:01Z.


Same measurement over the whole public payload catalog, relinker-only build of main d97361bd0, each asset converted with --trap-sdk-syscall-stubs --skip-sce-module.

recognised wrappers PS5 payload assets that convert
mount only (the scope of #8729) 10 of 22
mount, nmount, unmount (the __syscall6 family) 22 of 22

Catalog: every PS5 asset of the current ps5-payload-dev releases - elfldr v0.25/v0.26, ftpsrv v0.21/v0.21.1 (binary and installer), websrv v0.34/v0.35, shsrv v0.19/v0.20, gdbsrv v0.8/v0.9, klogsrv v0.8/v0.9, launchpad v0.1/v0.2, plutotv v0.2/v0.3, svtplay v0.3/v0.4, tv4play v0.2/v0.3. The six other release assets are -ps4.elf and fail for the same reason; they are out of scope here.

With mount only, every failure is the next wrapper of the family: ftpsrv at 0x70ec (v0.21.1) and 0x70fc (v0.21), websrv at 0xaebc and 0xa96c, launchpad at 0x4fc, plutotv at 0x68c, svtplay at 0x50c, tv4play at 0x68c. elfldr, shsrv, gdbsrv and klogsrv contain no mount-family wrapper and convert under either scope.

So if the opt-in is extended, it has to cover the family: mount only converts 10 of 22 and leaves both payloads named in this issue failing.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6314914611 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8624#issuecomment-6314914611). Originally posted by [kaiffeetasse](https://github.com/kaiffeetasse) on 2026-10-21T11:35:01Z. --- Same measurement over the whole public payload catalog, relinker-only build of `main` d97361bd0, each asset converted with `--trap-sdk-syscall-stubs --skip-sce-module`. | recognised wrappers | PS5 payload assets that convert | | --- | --- | | `mount` only (the scope of #8729) | 10 of 22 | | `mount`, `nmount`, `unmount` (the `__syscall6` family) | 22 of 22 | Catalog: every PS5 asset of the current ps5-payload-dev releases - elfldr v0.25/v0.26, ftpsrv v0.21/v0.21.1 (binary and installer), websrv v0.34/v0.35, shsrv v0.19/v0.20, gdbsrv v0.8/v0.9, klogsrv v0.8/v0.9, launchpad v0.1/v0.2, plutotv v0.2/v0.3, svtplay v0.3/v0.4, tv4play v0.2/v0.3. The six other release assets are `-ps4.elf` and fail for the same reason; they are out of scope here. With mount only, every failure is the next wrapper of the family: ftpsrv at 0x70ec (v0.21.1) and 0x70fc (v0.21), websrv at 0xaebc and 0xa96c, launchpad at 0x4fc, plutotv at 0x68c, svtplay at 0x50c, tv4play at 0x68c. elfldr, shsrv, gdbsrv and klogsrv contain no mount-family wrapper and convert under either scope. So if the opt-in is extended, it has to cover the family: `mount` only converts 10 of 22 and leaves both payloads named in this issue failing. AI-assisted: yes
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#8624
No description provided.