fix(libSceNet): copy resolver connection flags from guest memory #25747

Merged
malekaifa merged 1 commit from upstream-pr/25747 into main 2026-11-27 19:22:00 +00:00
malekaifa commented 2026-11-22 16:25:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-22T16:25:33Z.


What

Add focused regression coverage for an unmapped non-null resolver connection passed to sceNetResolverConnectDestroy. The test verifies the existing validation order and that an unreadable flags byte returns NET_EFAULT.

This is intentionally stacked on #24646, which already contains the same GuestCopyIn_nid_no_patch guard in sceNetResolverConnectDestroy as part of broader socket-option safety work. This branch temporarily carries that guard so the regression can run before #24646 merges. After #24646 lands, this PR should be rebased to remove the duplicate implementation hunk and retain the regression test only.

Tested

Windows 11, UCRT MinGW GCC 16.2, Release, BUILD_TESTING=ON:

  • cmake --build C:/b/net-resolver-destroy-guest-pointer-20261122 --target guest_net_ps4_exports_tests --parallel 4 — passed
  • ctest --test-dir C:/b/net-resolver-destroy-guest-pointer-20261122 -R '^guest_net_ps4_exports$' --output-on-failure — 1/1 passed
  • negative control: restored only core/libs/prx/libSceNet/Export.cpp to the parent while keeping the new assertion; guest_net_ps4_exports crashed with access violation 0xc0000005, reading address 0x1e8 from connection 0x10; restoring the fix returned the test to 1/1 passing
  • after rebasing to current main (788b1afac9daf5129deff879755324bc4799d08e), rebuilt and reran the focused CTest — 1/1 passed
  • git diff --check HEAD^ HEAD — clean
  • python -I tools/check_conventions.py --base HEAD^ --head HEAD — passed

Checklist

  • Based on current main; the overlapping implementation is explicitly stacked on #24646 and will be removed after it merges
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw; the actual resolver connection destroy body remains unimplemented after its existing validation gate
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source: none added
  • Generic behaviour, not specific to one title
  • Depends on: #24646
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5440937966 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25747). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-11-22T16:25:33Z. --- ### What Add focused regression coverage for an unmapped non-null resolver connection passed to `sceNetResolverConnectDestroy`. The test verifies the existing validation order and that an unreadable flags byte returns `NET_EFAULT`. This is intentionally stacked on #24646, which already contains the same `GuestCopyIn_nid_no_patch` guard in `sceNetResolverConnectDestroy` as part of broader socket-option safety work. This branch temporarily carries that guard so the regression can run before #24646 merges. After #24646 lands, this PR should be rebased to remove the duplicate implementation hunk and retain the regression test only. ### Tested Windows 11, UCRT MinGW GCC 16.2, Release, `BUILD_TESTING=ON`: - `cmake --build C:/b/net-resolver-destroy-guest-pointer-20261122 --target guest_net_ps4_exports_tests --parallel 4` — passed - `ctest --test-dir C:/b/net-resolver-destroy-guest-pointer-20261122 -R '^guest_net_ps4_exports$' --output-on-failure` — 1/1 passed - negative control: restored only `core/libs/prx/libSceNet/Export.cpp` to the parent while keeping the new assertion; `guest_net_ps4_exports` crashed with access violation `0xc0000005`, reading address `0x1e8` from connection `0x10`; restoring the fix returned the test to 1/1 passing - after rebasing to current `main` (`788b1afac9daf5129deff879755324bc4799d08e`), rebuilt and reran the focused CTest — 1/1 passed - `git diff --check HEAD^ HEAD` — clean - `python -I tools/check_conventions.py --base HEAD^ --head HEAD` — passed ### Checklist - [x] Based on current `main`; the overlapping implementation is explicitly stacked on #24646 and will be removed after it merges - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw; the actual resolver connection destroy body remains unimplemented after its existing validation gate - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source: none added - [x] Generic behaviour, not specific to one title - [x] Depends on: #24646 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-11-22 16:25:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-22T16:25:44Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013256469 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25747#pullrequestreview-6013256469). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-22T16:25:44Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
PrivacyOnion commented 2026-11-22 16:26:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T16:26:44Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against fe260d6f20:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_net_ps4_exports_tests built cleanly.
  • CTest (guest_net_ps4_exports):
    1/1 Test #5092: guest_net_ps4_exports ............   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNet/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #5092: guest_net_ps4_exports ............***Exception: SegFault  0.15 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified sceNetResolverConnectDestroy checks net_initialized() returning NET_ENOTINIT and connection == nullptr returning NET_EINVAL before attempting any memory access
    • Verified GuestCopyIn_nid_no_patch safely copies 1 byte flags at offset NET_RESOLVER_CONNECTION_FLAGS (0x1D8) and returns NET_EFAULT on invalid guest pointer without host access violation
    • Verified flag bit 0 check ((flags & 1) == 0) returns NET_EBADF when cleared, preserving PS5 resolver connection validation logic
    • Verified GuestNetPs4Exports.cpp test coverage exercises the invalid guest pointer (0x10) returning kEfault as well as subsequent kEbadf check without regressions or test state leakage
    • Verified strict AGENTS.md compliance: no comments added, conventions passed, NotImplemented_nid_no_patch preserved on unimplemented path

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013260217 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25747#pullrequestreview-6013260217). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-22T16:26:44Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `fe260d6f20`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_net_ps4_exports_tests` built cleanly. - **CTest** (`guest_net_ps4_exports`): ``` 1/1 Test #5092: guest_net_ps4_exports ............ Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNet/Export.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #5092: guest_net_ps4_exports ............***Exception: SegFault 0.15 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified sceNetResolverConnectDestroy checks net_initialized() returning NET_ENOTINIT and connection == nullptr returning NET_EINVAL before attempting any memory access - Verified GuestCopyIn_nid_no_patch safely copies 1 byte flags at offset NET_RESOLVER_CONNECTION_FLAGS (0x1D8) and returns NET_EFAULT on invalid guest pointer without host access violation - Verified flag bit 0 check ((flags & 1) == 0) returns NET_EBADF when cleared, preserving PS5 resolver connection validation logic - Verified GuestNetPs4Exports.cpp test coverage exercises the invalid guest pointer (0x10) returning kEfault as well as subsequent kEbadf check without regressions or test state leakage - Verified strict AGENTS.md compliance: no comments added, conventions passed, NotImplemented_nid_no_patch preserved on unimplemented path Looks Good To Me
MarcZX10 commented 2026-11-22 16:51:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T16:51:33Z.

Review: APPROVED


Reviewed — looks good

Nothing in the inspected change blocks merging; the implementation follows established guest-memory read handling and preserves the stated validation order.

What I ran

Reviewed head fe260d6f209b888b8ce7a3942a1da8bc59ac32f5 using repo_read.py to inspect the prepared diff, manifest and changed source ranges. No commands or tests were run; the build and test results in the PR description are author-reported.

Results

Check Result Note
Changed code review passed Implementation and regression assertion read
Build and tests not run Results reported by author only
Physical console behavior not run No measurement provided

Findings

Blocking

None.

Non-blocking

None.

Not verified

The changed files core/libs/prx/libSceNet/Export.cpp and core/libs/tests/GuestNetPs4Exports.cpp were read at the relevant function and test ranges. Both files listed as reviewed in the manifest were included and inspected. The remaining file contents, test execution, and exact console result for inaccessible resolver objects were not verified. review/files.json was not available; the reader's file listing confirmed both changed files were included.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013357988 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25747#pullrequestreview-6013357988). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T16:51:33Z. **Review:** APPROVED --- # Reviewed — looks good Nothing in the inspected change blocks merging; the implementation follows established guest-memory read handling and preserves the stated validation order. ## What I ran Reviewed head `fe260d6f209b888b8ce7a3942a1da8bc59ac32f5` using `repo_read.py` to inspect the prepared diff, manifest and changed source ranges. No commands or tests were run; the build and test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Implementation and regression assertion read | | Build and tests | not run | Results reported by author only | | Physical console behavior | not run | No measurement provided | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The changed files `core/libs/prx/libSceNet/Export.cpp` and `core/libs/tests/GuestNetPs4Exports.cpp` were read at the relevant function and test ranges. Both files listed as reviewed in the manifest were included and inspected. The remaining file contents, test execution, and exact console result for inaccessible resolver objects were not verified. `review/files.json` was not available; the reader's file listing confirmed both changed files were included. ## To get this to a good state Nothing is required.
throny commented 2026-11-22 17:10:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T17:10:35Z.

Review: APPROVED


Review: ✅ correct, I'd merge it

Basis: code read

Checked

  • On main, sceNetResolverConnectDestroy reads the flags byte at connection + 0x1D8 directly after only a null check, so a bad non-null pointer faults the host. The other connect exports (Abort, Create, Connect) never dereference the pointer.
  • Order is unchanged: ENOTINIT, null → EINVAL, the checked 1-byte copy → EFAULT, bit 0 clear → EBADF, then NotImplemented. EFAULT on a failed copy matches sceNetResolverStartAton/Aton6. The existing ENOTINIT, EINVAL and EBADF assertions still pass with a readable record.
  • The new 0x10 → EFAULT assertion faults on main.

Findings
none

Suggested action: merge

AI-assisted review (Claude Code) · head fe260d6f20 · base main 23b8772462

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013438403 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25747#pullrequestreview-6013438403). Originally posted by [throny](https://github.com/throny) on 2026-11-22T17:10:35Z. **Review:** APPROVED --- ### Review: ✅ correct, I'd merge it **Basis:** code read **Checked** - On main, `sceNetResolverConnectDestroy` reads the flags byte at `connection + 0x1D8` directly after only a null check, so a bad non-null pointer faults the host. The other connect exports (`Abort`, `Create`, `Connect`) never dereference the pointer. - Order is unchanged: ENOTINIT, null → EINVAL, the checked 1-byte copy → EFAULT, bit 0 clear → EBADF, then `NotImplemented`. EFAULT on a failed copy matches `sceNetResolverStartAton`/`Aton6`. The existing ENOTINIT, EINVAL and EBADF assertions still pass with a readable record. - The new `0x10` → EFAULT assertion faults on main. **Findings** none **Suggested action:** merge <sub>AI-assisted review (Claude Code) · head `fe260d6f20` · base `main` `23b8772462`</sub>
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!25747
No description provided.