fix(libkernel): query peers of libSceNet sockets #18472

Merged
THEMANnt merged 1 commit from upstream-pr/18472 into main 2026-11-12 18:50:43 +00:00
THEMANnt commented 2026-11-11 17:31:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-11-11T17:31:01Z.


What

Allow POSIX getpeername to query descriptors owned by libSceNet. Hold the registered socket owner through the native query and use the existing guest address and length copy path.

Tested

Windows x64, GCC 15.2. Built libkernel and libSceNet. The existing guest_sce_net_kernel_forwards test now checks both providers, the returned loopback address and EFAULT on a null address. It passed with local loopback access. Repository conventions passed. No title run.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5263940738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18472). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-11-11T17:31:01Z. --- ### What Allow POSIX `getpeername` to query descriptors owned by `libSceNet`. Hold the registered socket owner through the native query and use the existing guest address and length copy path. ### Tested Windows x64, GCC 15.2. Built libkernel and libSceNet. The existing guest_sce_net_kernel_forwards test now checks both providers, the returned loopback address and EFAULT on a null address. It passed with local loopback access. Repository conventions passed. No title run. <!-- 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. --> ### 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: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-11-12 14:27:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T14:27:09Z.

Review: COMMENTED


Reviewed — no blocking findings

The change at head 7dd13f1cc4cc7bd12c246380c0a180d84d10c905 lets getpeername answer for libSceNet descriptors, and the code I read supports that. I did not build or run anything.

What I ran

  • Head SHA: 7dd13f1cc4cc7bd12c246380c0a180d84d10c905.
  • Read description.md, commits.md, manifest.json, diff.patch and files.json in the run folder.
  • Read at head with the reader: Udp.cpp lines 1880–1960, Socket.cpp lines 195–225, GuestNetKernelForwards.cpp lines 110–150, and the name searches for KernelFindSocketNative_nid_no_patch.
  • No build, no test run, no merged-preview check.

Results

Check Result Note
Diff read in full passed 2 files, 19 changed lines
Changed code read at head passed Both changed files
Build and tests not run Author reports a Windows x64 run
Repository conventions not run Author reports a pass
Comments in added code passed None added

Findings

Blocking

None.

Non-blocking

None that I can cite with a concrete defect.

Sources

  • Udp.cpp change: the owner is held for the native call; the forwarded path never reads socket.
  • Native lookup: returns the owner and native handle, or false.
  • Test additions: peer address and null-address EFAULT for both providers.

Not verified

  • The build on any platform, and the test run the author reports (Windows x64, GCC 15.2).
  • The Linux and POSIX path of the test on this head.
  • The repository conventions check the author reports as passed.
  • The GuestSockets::IsOpen body, which I only saw as a declaration in SocketRuntime.hpp.

To get this to a good state

No change is needed from the author for this review. Keep the Windows run output with the PR. No command needs rerunning on a new head unless the code changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5876114417 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18472#pullrequestreview-5876114417). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T14:27:09Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The change at head `7dd13f1cc4cc7bd12c246380c0a180d84d10c905` lets `getpeername` answer for `libSceNet` descriptors, and the code I read supports that. I did not build or run anything. ## What I ran - Head SHA: `7dd13f1cc4cc7bd12c246380c0a180d84d10c905`. - Read `description.md`, `commits.md`, `manifest.json`, `diff.patch` and `files.json` in the run folder. - Read at head with the reader: `Udp.cpp` lines 1880–1960, `Socket.cpp` lines 195–225, `GuestNetKernelForwards.cpp` lines 110–150, and the name searches for `KernelFindSocketNative_nid_no_patch`. - No build, no test run, no merged-preview check. ## Results | Check | Result | Note | |---|---|---| | Diff read in full | passed | 2 files, 19 changed lines | | Changed code read at head | passed | Both changed files | | Build and tests | not run | Author reports a Windows x64 run | | Repository conventions | not run | Author reports a pass | | Comments in added code | passed | None added | ## Findings **Blocking** None. **Non-blocking** None that I can cite with a concrete defect. ## Sources - [`Udp.cpp` change](https://github.com/boykopovar/AnyPS5/blob/7dd13f1cc4cc7bd12c246380c0a180d84d10c905/core/libs/prx/libkernel/Socket/src/Udp.cpp#L1918-L1936): the owner is held for the native call; the forwarded path never reads `socket`. - [Native lookup](https://github.com/boykopovar/AnyPS5/blob/7dd13f1cc4cc7bd12c246380c0a180d84d10c905/core/libs/prx/libkernel/Socket/src/Socket.cpp#L207-L210): returns the owner and native handle, or false. - [Test additions](https://github.com/boykopovar/AnyPS5/blob/7dd13f1cc4cc7bd12c246380c0a180d84d10c905/core/libs/tests/GuestNetKernelForwards.cpp#L134-L138): peer address and null-address `EFAULT` for both providers. ## Not verified - The build on any platform, and the test run the author reports (Windows x64, GCC 15.2). - The Linux and POSIX path of the test on this head. - The repository conventions check the author reports as passed. - The `GuestSockets::IsOpen` body, which I only saw as a declaration in `SocketRuntime.hpp`. ## To get this to a good state No change is needed from the author for this review. Keep the Windows run output with the PR. No command needs rerunning on a new head unless the code changes.
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!18472
No description provided.