fix(libSceNet): reject the flags and names the module rejects #9727

Merged
KernelPanicNT merged 1 commit from upstream-pr/9727 into main 2026-10-25 23:07:36 +00:00
KernelPanicNT commented 2026-10-22 10:05:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-10-22T10:05:06Z.


What

Four libSceNet calls now fail with EINVAL (0x80410116, errno 22) for the argument values the PS5 libSceNet module rejects. Until now they ignored their flags, and sceNetEpollCreate its name:

Source of the behaviour.

  • prosper's reading of the libSceNet module, which cites an image-relative offset for each check:
    • sceNetEpollCreate "requires a name and zero flags (+0x809f-+0x80b8); anything else is EINVAL" (L448-L449).
    • sceNetGetMacAddress: "The module first refuses a null addr or non-zero flags with EINVAL (+0x542c-+0x5438)" (L531-L541).
    • sceNetResolverCreate: "Non-zero flags are EINVAL (+0xbae0)" (L564-L578).
    • sceNetResolverStartNtoa: "The module refuses a negative timeout or retry and flags & 0xfffefffe with EINVAL (+0xbb11-+0xbb2c)", ahead of its resolver id check (L579-L594).
  • prosper says these NIDs are in the PS5 3.20 libSceNet export set (L436); it does not record which firmware version the disassembled module came from.
  • This follows the merged #7856, which took libSceGameUpdate's errors from a prosper module reading in the same way.

What is kept as it is, and why.

  • The two accepted resolver flag bits: sceNetResolverStartNtoa still ignores bits 0x1 and 0x10000, and the timeout and retry count: every lookup runs once, synchronously, through the host resolver, as on main. What these bits do on a console is not known (shadPS4 names them async and IP address literals disabled), and making them throw would break callers that pass them today. The new debt entry records this.
  • A null resolver name: prosper's sceNetResolverCreate also refuses a null name, but its module citation covers only the flags, so a null name is still accepted.
  • Everything after the new checks (the resolver lookups, epoll and the MAC address) is unchanged.

Changes:

  • Export.cpp: the checks above at the top of the four functions.
  • guest_sce_net, new CheckRejectedArguments: each rejected value fails with EINVAL and sets sceNetErrnoLoc to 22; a rejected sceNetGetMacAddress leaves the address untouched; on a resolver with a pending abort the rejected sceNetResolverStartNtoa calls return EINVAL and the next valid call still returns the abort's EINTR; on a destroyed resolver the rejected values return EINVAL, and flags 0, 0x1, 0x10000 and 0x10001 reach the EBADF id check.
  • docs/dev/debt/libSceNet.md: a new sceNetResolverStartNtoa entry for the two ignored flag bits, the timeout and the retry count.

Unblocks: none. No title is known to pass these values; this corrects the result on those paths.

Tested

Linux (GitHub Codespace, 4 cores, AMD EPYC 7763, native build of this branch b7372d895, rebased on main d969e4bd6):

  • guest_sce_net_tests: 5/5 runs pass.
  • ctest -R "net_epoll_lifetime|guest_sce_net" (guest_sce_net and the eight net_epoll_lifetime_* cases, which create epolls with a name and flags 0): 5/5 runs pass, 9/9 tests each.
  • Negative control: with core/libs/prx/libSceNet/Export.cpp from main, guest_sce_net_tests aborts (exit 134, SIGABRT in CheckRejectedArguments(); its Require aborts without a message): 1/9 Test #1292: guest_sce_net ....................Subprocess aborted***Exception, and the eight net_epoll_lifetime_* cases still pass. 5/5 pass again after restoring it.

Windows: @ycbuzi ran the previous head 5e48663b5 merged onto main 6a6a35fdf5 (Windows 11, MinGW-w64 GCC 15.2.0, Release): guest_sce_net passes, and aborts with Export.cpp from main.

Not tested: macOS, a console, a title run.

Checks:

  • python3 tools/check_conventions.py --base origin/main passes with no findings.
  • tools/progress.py: unchanged, 4835/11180 (43.25%) on base and head; no export is added or removed.
  • git diff --check against main: clean.

Duplicate and overlap check

Searches of open and closed pull requests for sceNetEpollCreate, sceNetResolverCreate, sceNetGetMacAddress, sceNetResolverStartNtoa, "libSceNet EINVAL" and "libSceNet flags" find no other change to these checks. None of the open libSceNet pull requests changes the four functions in its diff; #9636 (deterministic resolver failures) edits other sceNetResolverStartNtoa assertions in GuestSceNet.cpp, and #9493 adds an sceNetEpollCreate call with flags 0 in a test.

python3 tools/pr_overlap.py --branch fix/net-reject-unsupported-flags reports no conflict. It could not compare #5836, #6044, #6879, #7201 and #8398, which conflict with main in the shared files. Checked by hand: none of them changes these four functions or the new test (#5836 is peer socket retries, #6879 adds one line to Export.cpp for the browser build, #7201 is the macOS port, #8398 is NetCtl NpToolkit callbacks), and #6044 moves GuestSceNet.cpp to core/libs/tests/networking/; whichever lands second keeps both changes.

Checklist

  • Based on current main (d969e4bd6); 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 (argument errors only; no title is known to pass these values)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4965608408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9727). Originally posted by [KernelPanicNT](https://github.com/KernelPanicNT) on 2026-10-22T10:05:06Z. --- ### What Four libSceNet calls now fail with `EINVAL` (`0x80410116`, errno 22) for the argument values the PS5 `libSceNet` module rejects. Until now they ignored their flags, and `sceNetEpollCreate` its name: - [`sceNetEpollCreate(name, flags)`](https://github.com/boykopovar/AnyPS5/blob/7e2ba73e4c8c26b5d632b0d2f46166ffc1b8a29d/core/libs/prx/libSceNet/Export.cpp#L1751-L1759): a null name or non-zero flags. - [`sceNetGetMacAddress(addr, flags)`](https://github.com/boykopovar/AnyPS5/blob/7e2ba73e4c8c26b5d632b0d2f46166ffc1b8a29d/core/libs/prx/libSceNet/Export.cpp#L2024-L2033): non-zero flags, as a null address already did. The address is not written. - [`sceNetResolverCreate(name, memid, flags)`](https://github.com/boykopovar/AnyPS5/blob/7e2ba73e4c8c26b5d632b0d2f46166ffc1b8a29d/core/libs/prx/libSceNet/Export.cpp#L2036-L2044): non-zero flags. - [`sceNetResolverStartNtoa(rid, hostname, addr, timeout, retry, flags)`](https://github.com/boykopovar/AnyPS5/blob/7e2ba73e4c8c26b5d632b0d2f46166ffc1b8a29d/core/libs/prx/libSceNet/Export.cpp#L2090-L2099): a negative timeout, a negative retry count, or a flag bit outside `0x10001` (`flags & 0xfffefffe`). This is checked before anything else, so it comes before `EBADF` for an unknown resolver and before a pending `sceNetResolverAbort` is reported. **Source of the behaviour.** - [prosper's reading of the libSceNet module](https://github.com/mattias800/prosper/blob/6c09a34a092a00898fcead5f855200ca7c368cd2/prosper/src/hle/net/hle_net.cpp#L436-L455), which cites an image-relative offset for each check: - `sceNetEpollCreate` "requires a name and zero flags (+0x809f-+0x80b8); anything else is EINVAL" ([L448-L449](https://github.com/mattias800/prosper/blob/6c09a34a092a00898fcead5f855200ca7c368cd2/prosper/src/hle/net/hle_net.cpp#L448-L449)). - `sceNetGetMacAddress`: "The module first refuses a null addr or non-zero flags with EINVAL (+0x542c-+0x5438)" ([L531-L541](https://github.com/mattias800/prosper/blob/6c09a34a092a00898fcead5f855200ca7c368cd2/prosper/src/hle/net/hle_net.cpp#L531-L541)). - `sceNetResolverCreate`: "Non-zero flags are EINVAL (+0xbae0)" ([L564-L578](https://github.com/mattias800/prosper/blob/6c09a34a092a00898fcead5f855200ca7c368cd2/prosper/src/hle/net/hle_net.cpp#L564-L578)). - `sceNetResolverStartNtoa`: "The module refuses a negative timeout or retry and flags & 0xfffefffe with EINVAL (+0xbb11-+0xbb2c)", ahead of its resolver id check ([L579-L594](https://github.com/mattias800/prosper/blob/6c09a34a092a00898fcead5f855200ca7c368cd2/prosper/src/hle/net/hle_net.cpp#L579-L594)). - prosper says these NIDs are in the PS5 3.20 libSceNet export set ([L436](https://github.com/mattias800/prosper/blob/6c09a34a092a00898fcead5f855200ca7c368cd2/prosper/src/hle/net/hle_net.cpp#L436)); it does not record which firmware version the disassembled module came from. - This follows the merged #7856, which took libSceGameUpdate's errors from a prosper module reading in the same way. **What is kept as it is, and why.** - **The two accepted resolver flag bits:** `sceNetResolverStartNtoa` still ignores bits `0x1` and `0x10000`, and the timeout and retry count: every lookup runs once, synchronously, through the host resolver, as on `main`. What these bits do on a console is not known (shadPS4 names them async and IP address literals disabled), and making them throw would break callers that pass them today. The new debt entry records this. - **A null resolver name:** prosper's `sceNetResolverCreate` also refuses a null name, but its module citation covers only the flags, so a null name is still accepted. - **Everything after the new checks** (the resolver lookups, epoll and the MAC address) is unchanged. Changes: - `Export.cpp`: the checks above at the top of the four functions. - `guest_sce_net`, new `CheckRejectedArguments`: each rejected value fails with `EINVAL` and sets `sceNetErrnoLoc` to 22; a rejected `sceNetGetMacAddress` leaves the address untouched; on a resolver with a pending abort the rejected `sceNetResolverStartNtoa` calls return `EINVAL` and the next valid call still returns the abort's `EINTR`; on a destroyed resolver the rejected values return `EINVAL`, and flags 0, `0x1`, `0x10000` and `0x10001` reach the `EBADF` id check. - `docs/dev/debt/libSceNet.md`: a new `sceNetResolverStartNtoa` entry for the two ignored flag bits, the timeout and the retry count. Unblocks: none. No title is known to pass these values; this corrects the result on those paths. ### Tested Linux (GitHub Codespace, 4 cores, AMD EPYC 7763, native build of this branch `b7372d895`, rebased on `main` `d969e4bd6`): - `guest_sce_net_tests`: 5/5 runs pass. - `ctest -R "net_epoll_lifetime|guest_sce_net"` (`guest_sce_net` and the eight `net_epoll_lifetime_*` cases, which create epolls with a name and flags 0): 5/5 runs pass, 9/9 tests each. - Negative control: with `core/libs/prx/libSceNet/Export.cpp` from `main`, `guest_sce_net_tests` aborts (exit 134, `SIGABRT` in `CheckRejectedArguments()`; its `Require` aborts without a message): `1/9 Test #1292: guest_sce_net ....................Subprocess aborted***Exception`, and the eight `net_epoll_lifetime_*` cases still pass. 5/5 pass again after restoring it. Windows: @ycbuzi ran the previous head `5e48663b5` merged onto `main` `6a6a35fdf5` (Windows 11, MinGW-w64 GCC 15.2.0, Release): `guest_sce_net` passes, and aborts with `Export.cpp` from `main`. Not tested: macOS, a console, a title run. Checks: - `python3 tools/check_conventions.py --base origin/main` passes with no findings. - `tools/progress.py`: unchanged, 4835/11180 (43.25%) on base and head; no export is added or removed. - `git diff --check` against `main`: clean. ### Duplicate and overlap check Searches of open and closed pull requests for `sceNetEpollCreate`, `sceNetResolverCreate`, `sceNetGetMacAddress`, `sceNetResolverStartNtoa`, "libSceNet EINVAL" and "libSceNet flags" find no other change to these checks. None of the open libSceNet pull requests changes the four functions in its diff; #9636 (deterministic resolver failures) edits other `sceNetResolverStartNtoa` assertions in `GuestSceNet.cpp`, and #9493 adds an `sceNetEpollCreate` call with flags 0 in a test. `python3 tools/pr_overlap.py --branch fix/net-reject-unsupported-flags` reports no conflict. It could not compare #5836, #6044, #6879, #7201 and #8398, which conflict with `main` in the shared files. Checked by hand: none of them changes these four functions or the new test (#5836 is peer socket retries, #6879 adds one line to `Export.cpp` for the browser build, #7201 is the macOS port, #8398 is NetCtl NpToolkit callbacks), and #6044 moves `GuestSceNet.cpp` to `core/libs/tests/networking/`; whichever lands second keeps both changes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main` (`d969e4bd6`); 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 - [x] Fixes: none - [x] Unblocks: none (argument errors only; no title is known to pass these values) - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-22 11:58:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:58:41Z.

Review: DISMISSED


The cited module evidence and focused regression coverage are substantive. Separately, the branch is 13 commits behind current main and the test report is against 7e2ba73e4. Please refresh the branch and rerun guest_sce_net and the overlap check on the resulting head before merge. The queue comment is not a reason to hold this PR; it is fine to keep submitting PRs and they will be handled in due course. Product Linux/Windows CI jobs are skipped on the current PR.

I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5613769574 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9727#pullrequestreview-5613769574). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:58:41Z. **Review:** DISMISSED --- The cited module evidence and focused regression coverage are substantive. Separately, the branch is 13 commits behind current `main` and the test report is against `7e2ba73e4`. Please refresh the branch and rerun `guest_sce_net` and the overlap check on the resulting head before merge. The queue comment is not a reason to hold this PR; it is fine to keep submitting PRs and they will be handled in due course. Product Linux/Windows CI jobs are skipped on the current PR. I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
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!9727
No description provided.