fix(relinker): trap inline SDK mount syscall #8729

Closed
hyvvs wants to merge 1 commit from upstream-pr/8729 into main
hyvvs commented 2026-10-20 22:37:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-10-20T22:37:37Z.


What

Recognize the exact SYS_mount inline syscall sequence observed in public ps5-payload-dev ftpsrv v0.21.1 and websrv v0.35 payloads when --trap-sdk-syscall-stubs is explicitly enabled (issue #8624).

The scanner keeps its decoded-instruction-boundary and full-sequence checks. The trapped syscall is still replaced with UD2; this does not implement mount or claim that either payload can execute successfully. This patch recognizes only the inline SYS_mount sequence. As reported in #8624, ftpsrv-ps5 and websrv-ps5 also contain nmount and unmount wrappers; the mount-only change still fails conversion at nmount (ftpsrv: 0x70ec; websrv: 0xaebc). These remaining wrappers need a separate design decision and implementation if the option is broadened.

Extend the existing SDK inline-syscall fixture and near-match mutation checks, and record the remaining functional gap in the relinker technical debt.

This is a design proposal for maintainer review: #8624 explicitly leaves open whether SYS_mount belongs in the opt-in trap list. No unrelated syscall patterns are accepted.

Tested

  • Windows NT 10.0.26200, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja 1.13.2, CMake 4.4.4, Release relinker-only build.
  • Confirmed the new regression fixture fails on the original implementation at code offset 0x123413.
  • cmake --build build-relinker --parallel 6: passed.
  • ctest --test-dir build-relinker --output-on-failure -j 4 -R '^(sdk_mman_syscall|relinker_conversion|cli_args|elf_reader_bounds|call_site_index)$': 5/5 passed.
  • sdk_mman_syscall_tests: 1,285 near-match rejections passed.
  • python tools/check_conventions.py --base upstream/main: passed.
  • The baseline full CTest run (before this change) reported 203 passed / 27 failed out of 230; those failures were Windows security blocks (WinError 225) launching the relinker executable, not demonstrated code failures. No full post-change suite claim.
  • End-to-end conversion of the published payload ELFs and GPU/title execution were not tested.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #9549
  • Fixes: none (related to #8624; does not resolve conversion of either reported payload)
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4943458930 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8729). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-10-20T22:37:37Z. --- ### What Recognize the exact `SYS_mount` inline syscall sequence observed in public ps5-payload-dev ftpsrv v0.21.1 and websrv v0.35 payloads when `--trap-sdk-syscall-stubs` is explicitly enabled (issue #8624). The scanner keeps its decoded-instruction-boundary and full-sequence checks. The trapped syscall is still replaced with `UD2`; this does not implement `mount` or claim that either payload can execute successfully. This patch recognizes only the inline `SYS_mount` sequence. As reported in #8624, `ftpsrv-ps5` and `websrv-ps5` also contain `nmount` and `unmount` wrappers; the mount-only change still fails conversion at `nmount` (ftpsrv: `0x70ec`; websrv: `0xaebc`). These remaining wrappers need a separate design decision and implementation if the option is broadened. Extend the existing SDK inline-syscall fixture and near-match mutation checks, and record the remaining functional gap in the relinker technical debt. This is a design proposal for maintainer review: #8624 explicitly leaves open whether `SYS_mount` belongs in the opt-in trap list. No unrelated syscall patterns are accepted. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Windows NT 10.0.26200, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja 1.13.2, CMake 4.4.4, Release relinker-only build. - Confirmed the new regression fixture fails on the original implementation at code offset `0x123413`. - `cmake --build build-relinker --parallel 6`: passed. - `ctest --test-dir build-relinker --output-on-failure -j 4 -R '^(sdk_mman_syscall|relinker_conversion|cli_args|elf_reader_bounds|call_site_index)$'`: 5/5 passed. - `sdk_mman_syscall_tests`: 1,285 near-match rejections passed. - `python tools/check_conventions.py --base upstream/main`: passed. - The baseline full CTest run (before this change) reported 203 passed / 27 failed out of 230; those failures were Windows security blocks (WinError 225) launching the relinker executable, not demonstrated code failures. No full post-change suite claim. - End-to-end conversion of the published payload ELFs and GPU/title execution were not tested. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #9549 - [x] Fixes: none (related to #8624; does not resolve conversion of either reported payload) - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-20 22:38:42 +00:00 (Migrated from github.com)

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


The exact-byte matcher and fixture look deliberately scoped: it requires the decoded sequence start, checks the full sequence within the code-section bound, and retains the near-match mutations. One design point before approval: #8624 leaves SYS_mount inclusion as an explicit contract decision, while the current option documentation describes trapping mmap/mprotect and rejecting other syscall instructions. If maintainers decide to broaden the opt-in, please update that user-facing description as part of the change; otherwise the implementation exceeds the documented scope. I only reviewed the patch and reported Windows test matrix here; the automatic checks are policy checks, with no hosted build job.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303356195 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8729#issuecomment-6303356195). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T22:38:42Z. --- The exact-byte matcher and fixture look deliberately scoped: it requires the decoded sequence start, checks the full sequence within the code-section bound, and retains the near-match mutations. One design point before approval: #8624 leaves `SYS_mount` inclusion as an explicit contract decision, while the current option documentation describes trapping mmap/mprotect and rejecting other syscall instructions. If maintainers decide to broaden the opt-in, please update that user-facing description as part of the change; otherwise the implementation exceeds the documented scope. I only reviewed the patch and reported Windows test matrix here; the automatic checks are policy checks, with no hosted build job.
hyvvs commented 2026-10-20 22:49:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-10-20T22:49:17Z.


Ty for reviewing!

Agreed that including SYS_mount should be a maintainer decision,

I'll keep the PR as a draft pending that decision. If maintainers agree with the extension, I'll update the user-facing option description to include SYS_mount and clarify that it is trapped rather than implemented.

The relinker-only Windows build and focused regression tests passed locally. A hosted Windows CI build hasn't been run yet.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303523849 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8729#issuecomment-6303523849). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-10-20T22:49:17Z. --- Ty for reviewing! Agreed that including `SYS_mount` should be a maintainer decision, I'll keep the PR as a draft pending that decision. If maintainers agree with the extension, I'll update the user-facing option description to include `SYS_mount` and clarify that it is trapped rather than implemented. The relinker-only Windows build and focused regression tests passed locally. A hosted Windows CI build hasn't been run yet.
MarcZX10 commented 2026-10-20 23:15:20 +00:00 (Migrated from github.com)

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


New exact-payload data was added to #8624 after this PR opened: recognizing only the mount wrapper still stops ftpsrv at nmount (0x70ec) and websrv at nmount (0xaebc); both also contain inline unmount wrappers. The three-wrapper change converts both payloads, while the mount-only version does not. Your body correctly says this PR does not claim successful execution, but Fixes #8624 would still close an issue whose reported conversion gap remains. Could you change that relation to a non-closing reference and state that this adds one recognized wrapper while nmount/unmount remain blockers (or coordinate with the measured three-wrapper follow-up if maintainers approve broadening the option)?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303911811 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8729#issuecomment-6303911811). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T23:15:20Z. --- New exact-payload data was added to #8624 after this PR opened: recognizing only the `mount` wrapper still stops `ftpsrv` at `nmount` (0x70ec) and `websrv` at `nmount` (0xaebc); both also contain inline `unmount` wrappers. The three-wrapper change converts both payloads, while the mount-only version does not. Your body correctly says this PR does not claim successful execution, but `Fixes #8624` would still close an issue whose reported conversion gap remains. Could you change that relation to a non-closing reference and state that this adds one recognized wrapper while `nmount`/`unmount` remain blockers (or coordinate with the measured three-wrapper follow-up if maintainers approve broadening the option)?
hyvvs commented 2026-10-20 23:25:41 +00:00 (Migrated from github.com)

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


I've updated the PR description to remove the closing reference to #8624 and clarify that this change only handles SYS_mount, while nmount and unmount remain blockers.

I'll keep the PR as a draft pending the maintainers' decision on whether to expand the supported wrappers.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304072539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8729#issuecomment-6304072539). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-10-20T23:25:41Z. --- I've updated the PR description to remove the closing reference to #8624 and clarify that this change only handles `SYS_mount`, while `nmount` and `unmount` remain blockers. I'll keep the PR as a draft pending the maintainers' decision on whether to expand the supported wrappers.
MarcZX10 commented 2026-10-22 01:46:06 +00:00 (Migrated from github.com)

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


I am reviewing #9549. Its trap-condition change edits the line where this PR renames IsSdkMmanSyscallStub to IsSdkInlineSyscallStub, so the two changes need an agreed landing order and a refreshed Depends on entry if one must land first. Could you coordinate with @DavidSamir on the integration order? #9549 currently calls the old name and would need that symbol updated if this PR merges first.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330685746 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8729#issuecomment-6330685746). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:46:06Z. --- I am reviewing #9549. Its trap-condition change edits the line where this PR renames `IsSdkMmanSyscallStub` to `IsSdkInlineSyscallStub`, so the two changes need an agreed landing order and a refreshed `Depends on` entry if one must land first. Could you coordinate with @DavidSamir on the integration order? #9549 currently calls the old name and would need that symbol updated if this PR merges first.
DavidSamir commented 2026-10-22 02:18:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T02:18:48Z.


@hyvvs, a coordination question on landing order, as @MarcZX10 asked on #9549. #9549 turns the trap condition you rename in (IsSdkMmanSyscallStub to IsSdkInlineSyscallStub, SyscallScanner.cpp L293-294) into const bool sdkStub = ..., so whichever of the two merges second needs that one helper name updated; there is no other overlap.

You have kept this PR as a draft pending a decision on nmount and unmount, so I propose #9549 lands first and your PR updates the call inside sdkStub when it is rebased (one word). #9549 does not need yours, so it keeps Depends on: none. If you would rather land first, say so here and I will rebase #9549 onto yours and list #8729 under Depends on.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6331101382 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8729#issuecomment-6331101382). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-22T02:18:48Z. --- @hyvvs, a coordination question on landing order, as @MarcZX10 asked on #9549. #9549 turns the trap condition you rename in (`IsSdkMmanSyscallStub` to `IsSdkInlineSyscallStub`, `SyscallScanner.cpp` L293-294) into `const bool sdkStub = ...`, so whichever of the two merges second needs that one helper name updated; there is no other overlap. You have kept this PR as a draft pending a decision on `nmount` and `unmount`, so I propose #9549 lands first and your PR updates the call inside `sdkStub` when it is rebased (one word). #9549 does not need yours, so it keeps `Depends on: none`. If you would rather land first, say so here and I will rebase #9549 onto yours and list #8729 under `Depends on`.
hyvvs commented 2026-10-22 02:37:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-10-22T02:37:55Z.


@DavidSamir @MarcZX10 Thanks for flagging the overlap.

I agree that #9549 should land first, since #8729 is still a draft pending the maintainer decision on the mount/nmount/unmount syscall wrappers.

Once #9549 merges, I'll rebase #8729 onto the updated main, preserve the new sdkStub diagnostic behavior, update the helper call to IsSdkInlineSyscallStub, and rerun the relevant tests and checks.

Happy to proceed with this

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6331335622 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8729#issuecomment-6331335622). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-10-22T02:37:55Z. --- @DavidSamir @MarcZX10 Thanks for flagging the overlap. I agree that #9549 should land first, since #8729 is still a draft pending the maintainer decision on the mount/nmount/unmount syscall wrappers. Once #9549 merges, I'll rebase #8729 onto the updated main, preserve the new `sdkStub` diagnostic behavior, update the helper call to `IsSdkInlineSyscallStub`, and rerun the relevant tests and checks. Happy to proceed with this

Pull request closed

Sign in to join this conversation.
No reviewers
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!8729
No description provided.