fix(relinker): trap the inlined SDK __syscall6 stubs #11137
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11137"
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 kaiffeetasse on 2026-10-25T19:26:23Z.
What
--trap-sdk-syscall-stubsrecognizes the generic and numbered wrapper stubs and the three inlinemmap/mprotectsequences from SDKlibc/mman.c, but not the inlined__syscall6wrappers from SDKlibc/mount.c. Both payloads named in #8624 stop onmount(ftpsrv v0.21.1 at code offset 0x709a, websrv v0.35 at 0xae6a) and, once that one is recognized, onnmount(0x70ec / 0xaebc) andunmount(0x713c / 0xaf0c).This adds an exact sequence for each of the three wrappers, with its syscall number pinned in the pattern like the mman sequences, so a stub that carries another number is not matched. Their argument preparation differs, so one pattern cannot cover them. The decoded-instruction-boundary check, the full-sequence requirement and the
UD2substitution are unchanged:mount,nmountandunmountare not implemented, and a call still faults. The technical-debt entry and the option description say so.#9549 edits the same trap condition line; whichever of the two lands second needs a trivial rebase. There is no dependency on it, and no other open PR implements these sequences (#8729 was closed).
Tested
Linux, Ubuntu 24.04, GCC 13.3, relinker-only Release build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON):ctest --test-dir build-relinker -R "syscall|sdk_mman": 4 of 4 pass (sdk_mman_syscall,guest_syscall_trap,syscall_number,syscall_scanner). The fixture set gains the three sequences, a near-match mutation check over every byte, and a check that rewrites each stub's syscall-number field to 0, 1, 21, 22 and 378 and requires every number other than the stub's own to be rejected.python3 tools/check_conventions.py --base origin/main: all checks pass.--trap-sdk-syscall-stubs --skip-sce-module: 22 of 22 exit 0 (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). On the same build recognizing onlymount, 10 of 22 convert and every failure is the next wrapper of the family. Trapped sites: ftpsrv 239, websrv 236.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T19:33:09Z.
Review: APPROVED
Reviewed exact head
d34554e71cdbc483cb8d5e561a1b815b80fba76a. The three byte patterns and masked syscall-number immediate offsets align with their fixtures (mount13..16,nmount15..18,unmount13..16); matching still requires the complete pattern and a decoded instruction boundary. The change only turns the recognized unimplemented wrappers into the existingUD2trap under the opt-in flag, and the usage/debt text states that execution remains unsupported.Local validation on this head:
relinkerbuild: passed.sdk_mman_syscall_testsandsyscall_scanner_tests; CTestsdk_mman_syscall,guest_syscall_trap,syscall_number, andsyscall_scanner: 4/4 passed.python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --check upstream/main...HEAD: passed.GitHub conventions, intake and labels pass; no hosted build job is listed. The PR reports additional payload conversion runs; I did not rerun those external payload sweeps. No blocking issue found in this change.
Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-25T21:45:54Z.
Review: COMMENTED
Reviewed head
d34554e71cby reading the diff and the existing review thread. I did not build or run this, so everything below is from the code, not from a test of mine.What it does.
--trap-sdk-syscall-stubslearns the three inlined__syscall6wrappers from the SDK'slibc/mount.c(mount,nmount,unmount), replacing them withUD2like the existing mman patterns. The conversion results in the description are the strongest part: 22 of 22 real payload assets convert, and 10 of 22 convert when onlymountis recognised.My main concern is the mask. Each pattern masks the four-byte syscall-number immediate (
maskOffset,maskLength), so the stub matches whatever number it carries. The justification is that an SDK build that renumbers a call should still match. But the mmap and mprotect patterns bake their numbers in, and the three known numbers are right there in the fixtures (0x15, 0x17a, 0x16). With the number masked, any inlined__syscall6stub with the same prologue and register setup is trapped, including a different syscall that happens to have the same argument shape. That is opt-in (--trap-sdk-syscall-stubs) and it traps rather than runs, so the damage is limited, but the match is wider than the debt entry's wording suggests. Either pin the numbers or say in the entry that the number is deliberately not matched, and why a renumbering is expected.Test gaps:
0x16and zeroes the rest. For theunmountfixture, whose number already is0x16, that produces the identical bytes, so for that fixture the check cannot fail.UNSTABLEmerge state, so CI had not finished when I looked. Please let it complete.The overlap note about #9549 editing the same condition is already acknowledged in the PR. Leaving a comment rather than approving because of the widened match and the incomplete CI.
AI-assisted: yes. Written with AI assistance and reviewed by me.
Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-26T07:21:18Z.
Review: APPROVED
Re-reviewed head
60cd4d2fb4by reading the diff since my first review. I did not build or run it.Both of my points are addressed. The mask is gone:
MatchesSdkInlineStubis back to an exactstd::equal, and themount,nmountandunmountpatterns carry 0x15, 0x17A and 0x16, like the mman ones. The fixture check now rewrites each stub's four-byte number to 0, 1, 0x15, 0x16 and 0x17A and requires every value other than its own to be rejected, so it can fail forunmountnow. Approving. I have not looked at CI, so please let it finish.AI-assisted: yes. Written with AI assistance and reviewed by me.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T23:27:44Z.
Review: APPROVED
Re-checked — new head, looks good
The rebased scanner recognizes the three exact SDK inline syscall wrappers while retaining full-pattern and instruction-boundary matching; I found no blocking issue in the new head.
What I ran
Reviewed head
fcf6fffda81e2dc77f107d5f3bfea714630379d2against refreshedmainf46f453a56f91d77e29ce0cbd7fe5bfb2fb69834; the merge preview is clean. Environment: Linux x86_64. No local build or CTest run.Results
mainaction_required; it did not run.Unedited output from checks I ran
Negative control
Findings
Blocking
None found in the reviewed diff.
Non-blocking
The product build workflow is gated, and I did not execute the relinker tests locally. The PR reports those tests and payload conversions on this exact head.
Sources
Not verified
I did not build or run CTest locally, execute converted payloads, or verify syscall behavior on console hardware. Windows and macOS builds were not run.