fix(libSceNet): list libkernel sockets in sceNetGetSockInfo6 #21705

Merged
AasishDairelSahayaGrinspan merged 1 commit from upstream-pr/21705 into main 2026-11-20 20:47:43 +00:00
AasishDairelSahayaGrinspan commented 2026-11-16 16:21:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AasishDairelSahayaGrinspan on 2026-11-16T16:21:34Z.


What

sceNetGetSockInfo6 looked only at the sceNet descriptor table, where sceNetGetSockInfo resolves both its own sockets and the libkernel table. A socket made with libkernel socket() therefore answered EBADF from the specific-id form and was absent from the s < 0 list, contradicting technical debt entries 105 and 108 (measured on PS4 Pro 10.71: such a socket is described from the libkernel table and listed).

fill_sock_info6 now resolves its source through the existing find_sock_info_source (descriptor table first, then KernelDescribeSocket, priority 0 unchanged) and the list path adds the KernelListSockets pass with the same IPv6 / 0x1000 family filter and ascending order as sceNetGetSockInfo. Everything else is unchanged.

Tested

Linux (Omarchy 4.0.2), host build Release with BUILD_TESTING=ON:

  • build/tests/guest_sce_net_tests — exit 0, 1.7 s
  • ctest --test-dir build -R "guest_sce_net" — 8/8 Passed, 2.2 s total

The new case creates a libkernel socket(), checks it is absent from the flags 0 list and present under 0x1000/0x1040, that the specific-id call answers EAFNOSUPPORT without 0x1000 and fills the record with 0x1000, and that it answers EBADF and disappears from the list after close.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5340707924 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21705). Originally posted by [AasishDairelSahayaGrinspan](https://github.com/AasishDairelSahayaGrinspan) on 2026-11-16T16:21:34Z. --- ### What `sceNetGetSockInfo6` looked only at the `sceNet` descriptor table, where `sceNetGetSockInfo` resolves both its own sockets and the libkernel table. A socket made with libkernel `socket()` therefore answered `EBADF` from the specific-id form and was absent from the `s < 0` list, contradicting technical debt entries 105 and 108 (measured on PS4 Pro 10.71: such a socket is described from the libkernel table and listed). `fill_sock_info6` now resolves its source through the existing `find_sock_info_source` (descriptor table first, then `KernelDescribeSocket`, priority 0 unchanged) and the list path adds the `KernelListSockets` pass with the same IPv6 / `0x1000` family filter and ascending order as `sceNetGetSockInfo`. Everything else is unchanged. ### Tested Linux (Omarchy 4.0.2), host build `Release` with `BUILD_TESTING=ON`: - `build/tests/guest_sce_net_tests` — exit 0, 1.7 s - `ctest --test-dir build -R "guest_sce_net"` — 8/8 Passed, 2.2 s total The new case creates a libkernel `socket()`, checks it is absent from the `flags 0` list and present under `0x1000`/`0x1040`, that the specific-id call answers `EAFNOSUPPORT` without `0x1000` and fills the record with `0x1000`, and that it answers `EBADF` and disappears from the list after close. ### Checklist - [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) and the licence notice of code adapted from upstream (see AGENTS.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 -->
PrivacyOnion commented 2026-11-16 16:23:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T16:23:21Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_sce_net_tests built cleanly.
  • CTest (guest_sce_net):
    1/1 Test #4459: guest_sce_net ....................   Passed    1.69 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 #4459: guest_sce_net ....................Subprocess aborted***Exception:   1.05 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified fill_sock_info6 in core/libs/prx/libSceNet/Export.cpp:2437-2441 resolves descriptors via find_sock_info_source (matching sceNetGetSockInfo), returning NET_EBADF when absent from both g_socks and KernelDescribeSocket, and returning NET_EAFNOSUPPORT when an AF_INET socket is queried without NET_SOCKINFO6_IPV46 (0x1000).
    • Verified sceNetGetSockInfo6 list path (s < 0) in core/libs/prx/libSceNet/Export.cpp:2486-2501 releases g_mutex before invoking KernelListSockets_nid_no_patch and KernelDescribeSocket_nid_no_patch (preventing lock-order inversions), filters by NET_AF_INET6 or (includeIpv4 && NET_AF_INET), and sorts descriptors in ascending order.
    • Verified pointer, capacity, and flags checks in sceNetGetSockInfo6 (info == nullptr returns listed.size() for s < 0 or fail(NET_EINVAL) for s >= 0; capacity < 1 returns fail(NET_EINVAL)) remain intact after the list pass.
    • Verified technical debt fragment docs/dev/debt/changes/fix-libSceNet-sockinfo6-kernel-sockets.md updates both the sceNetGetSockInfo6 and sceNetGetSockInfo entries in docs/dev/debt/libSceNet.md accurately and passes check_conventions.py.
    • Verified CheckSockInfo6 in core/libs/tests/GuestSceNet.cpp:2679-2769 exercises libkernel socket() creation, bind, getsockname, list exclusion with flags 0, list inclusion with flags 0x1000/0x1040, EAFNOSUPPORT (47) on specific-id without 0x1000, record content verification with 0x1000, and cleanup/EBADF (9) on both IPv6-available and ipv6Unavailable paths.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5923439746 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21705#pullrequestreview-5923439746). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T16:23:21Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `5f8bc742f3`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_sce_net_tests` built cleanly. - **CTest** (`guest_sce_net`): ``` 1/1 Test #4459: guest_sce_net .................... Passed 1.69 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 #4459: guest_sce_net ....................Subprocess aborted***Exception: 1.05 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified fill_sock_info6 in core/libs/prx/libSceNet/Export.cpp:2437-2441 resolves descriptors via find_sock_info_source (matching sceNetGetSockInfo), returning NET_EBADF when absent from both g_socks and KernelDescribeSocket, and returning NET_EAFNOSUPPORT when an AF_INET socket is queried without NET_SOCKINFO6_IPV46 (0x1000). - Verified sceNetGetSockInfo6 list path (s < 0) in core/libs/prx/libSceNet/Export.cpp:2486-2501 releases g_mutex before invoking KernelListSockets_nid_no_patch and KernelDescribeSocket_nid_no_patch (preventing lock-order inversions), filters by NET_AF_INET6 or (includeIpv4 && NET_AF_INET), and sorts descriptors in ascending order. - Verified pointer, capacity, and flags checks in sceNetGetSockInfo6 (info == nullptr returns listed.size() for s < 0 or fail(NET_EINVAL) for s >= 0; capacity < 1 returns fail(NET_EINVAL)) remain intact after the list pass. - Verified technical debt fragment docs/dev/debt/changes/fix-libSceNet-sockinfo6-kernel-sockets.md updates both the sceNetGetSockInfo6 and sceNetGetSockInfo entries in docs/dev/debt/libSceNet.md accurately and passes check_conventions.py. - Verified CheckSockInfo6 in core/libs/tests/GuestSceNet.cpp:2679-2769 exercises libkernel socket() creation, bind, getsockname, list exclusion with flags 0, list inclusion with flags 0x1000/0x1040, EAFNOSUPPORT (47) on specific-id without 0x1000, record content verification with 0x1000, and cleanup/EBADF (9) on both IPv6-available and ipv6Unavailable paths. Looks Good To Me
MarcZX10 commented 2026-11-20 07:45:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T07:45:40Z.

Review: APPROVED


Reviewed — looks good

The reviewed change at head 5f8bc742f3604acab0a1fa4d131aa5755e67ef01 addresses the described libkernel socket lookup and listing gap, and the inspected code supports merging.

What I ran

Read the prepared description, commit list, manifest, diff, and all changed lines in the three changed files. Inspected find_sock_info_source, its libkernel descriptor lookup, and the list filling path at the pinned head. No commands or tests were run; the Linux build and test results in the description are author-reported.

Results

Check Result Note
Changed code review passed All changed lines read
Build and tests not run Results reported by author
Console behavior not run Author reports a console measurement in description

Findings

Blocking

None.

Non-blocking

None.

Sources

The specific-id path now uses the existing source resolver, which checks the sceNet table and then asks libkernel to describe the descriptor. The list path adds kernel sockets, filters by family, sorts descriptors, and skips sockets that disappear before filling their records. These behaviors are visible in Export.cpp at the reviewed head. Tests cover IPv4 inclusion flags, specific-id results, and behavior after closing the kernel socket in GuestSceNet.cpp at the reviewed head.

Not verified

No build, test, or console run was performed. The author's stated host build and test results were not independently verified. All three changed files listed in the manifest were read; no changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5989168345 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21705#pullrequestreview-5989168345). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T07:45:40Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change at head `5f8bc742f3604acab0a1fa4d131aa5755e67ef01` addresses the described libkernel socket lookup and listing gap, and the inspected code supports merging. ## What I ran Read the prepared description, commit list, manifest, diff, and all changed lines in the three changed files. Inspected `find_sock_info_source`, its libkernel descriptor lookup, and the list filling path at the pinned head. No commands or tests were run; the Linux build and test results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All changed lines read | | Build and tests | not run | Results reported by author | | Console behavior | not run | Author reports a console measurement in description | ## Findings ### Blocking None. ### Non-blocking None. ## Sources The specific-id path now uses the existing source resolver, which checks the `sceNet` table and then asks libkernel to describe the descriptor. The list path adds kernel sockets, filters by family, sorts descriptors, and skips sockets that disappear before filling their records. These behaviors are visible in [Export.cpp at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/5f8bc742f3604acab0a1fa4d131aa5755e67ef01/core/libs/prx/libSceNet/Export.cpp#L2437-L2518). Tests cover IPv4 inclusion flags, specific-id results, and behavior after closing the kernel socket in [GuestSceNet.cpp at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/5f8bc742f3604acab0a1fa4d131aa5755e67ef01/core/libs/tests/GuestSceNet.cpp#L2679-L2769). ## Not verified No build, test, or console run was performed. The author's stated host build and test results were not independently verified. All three changed files listed in the manifest were read; no changed files were excluded. ## To get this to a good state Nothing is required.
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!21705
No description provided.