fix(libkernel): reject 0.0.0.0/8 multicast interface addresses on every host #26806

Open
Romannachwievor wants to merge 3 commits from upstream-pr/26806 into main
Romannachwievor commented 2026-11-24 22:43:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Romannachwievor on 2026-11-24T22:43:58Z.


What

guest_socket_options fails on macOS since #25533: a 0.0.0.0/8 address other than INADDR_ANY must fail IP_MULTICAST_IF with EADDRNOTAVAIL (49) (errno 22). #25533 added ZeroNetworkAddress and its two EADDRNOTAVAIL checks in SocketOptions.cpp inside #ifdef _WIN32, while the new test cases expect EADDRNOTAVAIL on every host, as FreeBSD 11.4 answers when no interface has the address. A Linux host returns that error itself, but a macOS host answers EINVAL and the emulator passes it through. Main CI has no macOS job that builds the libraries (#24117), so the failure was not caught there.

This removes the three #ifdef _WIN32 guards, so IP_MULTICAST_IF, IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP reject an interface address in 0.0.0.0/8 other than 0.0.0.0 before the host sees it, on every host. The Windows path is unchanged. The debt entry in fix-libkernel-ip-multicast-if-mreqn.md now says "on every host" instead of "on Windows".

pr_overlap.py --names SetIpLevelOption ZeroNetworkAddress found no open PR. --branch could not compare four open PRs that also change SocketOptions.cpp and conflict with main; their hunks are elsewhere in the file: #12688, #12700 and #12965 change SetSocketLevelOption (around line 239), #18108 the includes and ReadValue (lines 15 and 166). None touches the multicast checks at lines 437-500.

Tested

Apple M1, macOS 26.5, x86_64 Release under Rosetta 2, main 61cce6e86b plus #17425, #11049 and #26739, which a macOS full build needs. ctest --test-dir build -R '^guest_socket_options$' --output-on-failure, serial:

  • main: 0 of 3 passed, each at the IP_MULTICAST_IF check with errno 22.
  • This change: 3 of 3 passed.
  • Mutation, IP_MULTICAST_IF check removed: 0 of 3, at must fail IP_MULTICAST_IF. Mutation, membership check removed: 0 of 3, at must fail IP_ADD_MEMBERSHIP.
  • ctest -R '^guest_(socket|udp|tcp|net|sce_net|multicast)' -j4 with this change: 61 of 64 passed. The three failures, guest_sce_net, guest_udp and guest_socket_port_zero, fail on main too and have owners (#22623, #25134, #17878).

These runs used commit f7178d0241. Head 91cbf540f9 only merges 23 later main commits, none of which touch core/libs/prx/libkernel/Socket, the test or the debt files.

Linux and Windows were not run locally. On Linux the outcome stays EADDRNOTAVAIL, now from the emulator instead of the host; the Windows code path does not change.

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

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5481572042 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26806). Originally posted by [Romannachwievor](https://github.com/Romannachwievor) on 2026-11-24T22:43:58Z. --- ### What `guest_socket_options` fails on macOS since #25533: `a 0.0.0.0/8 address other than INADDR_ANY must fail IP_MULTICAST_IF with EADDRNOTAVAIL (49) (errno 22)`. #25533 added `ZeroNetworkAddress` and its two `EADDRNOTAVAIL` checks in `SocketOptions.cpp` inside `#ifdef _WIN32`, while the new test cases expect `EADDRNOTAVAIL` on every host, as FreeBSD 11.4 answers when no interface has the address. A Linux host returns that error itself, but a macOS host answers `EINVAL` and the emulator passes it through. Main CI has no macOS job that builds the libraries (#24117), so the failure was not caught there. This removes the three `#ifdef _WIN32` guards, so `IP_MULTICAST_IF`, `IP_ADD_MEMBERSHIP` and `IP_DROP_MEMBERSHIP` reject an interface address in 0.0.0.0/8 other than `0.0.0.0` before the host sees it, on every host. The Windows path is unchanged. The debt entry in `fix-libkernel-ip-multicast-if-mreqn.md` now says "on every host" instead of "on Windows". `pr_overlap.py --names SetIpLevelOption ZeroNetworkAddress` found no open PR. `--branch` could not compare four open PRs that also change `SocketOptions.cpp` and conflict with `main`; their hunks are elsewhere in the file: #12688, #12700 and #12965 change `SetSocketLevelOption` (around line 239), #18108 the includes and `ReadValue` (lines 15 and 166). None touches the multicast checks at lines 437-500. ### 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. --> Apple M1, macOS 26.5, x86_64 Release under Rosetta 2, `main` `61cce6e86b` plus #17425, #11049 and #26739, which a macOS full build needs. `ctest --test-dir build -R '^guest_socket_options$' --output-on-failure`, serial: - `main`: 0 of 3 passed, each at the `IP_MULTICAST_IF` check with errno 22. - This change: 3 of 3 passed. - Mutation, `IP_MULTICAST_IF` check removed: 0 of 3, at `must fail IP_MULTICAST_IF`. Mutation, membership check removed: 0 of 3, at `must fail IP_ADD_MEMBERSHIP`. - `ctest -R '^guest_(socket|udp|tcp|net|sce_net|multicast)' -j4` with this change: 61 of 64 passed. The three failures, `guest_sce_net`, `guest_udp` and `guest_socket_port_zero`, fail on `main` too and have owners (#22623, #25134, #17878). These runs used commit `f7178d0241`. Head `91cbf540f9` only merges 23 later `main` commits, none of which touch `core/libs/prx/libkernel/Socket`, the test or the debt files. Linux and Windows were not run locally. On Linux the outcome stays `EADDRNOTAVAIL`, now from the emulator instead of the host; the Windows code path does not change. ### 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) 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-11-25 02:36:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T02:36:59Z.

Review: COMMENTED


Reviewed — no blocking findings

The changed multicast checks match the stated behavior, and the review found no verified blocking defect.

What I ran

Reviewed head 91cbf540f9e02cc932086e6b8e7b6fce80785aa. I read the prepared description, commits, manifest, diff, and both changed files at the pinned head; I used repo_read.py to search callers. I did not run tests or build commands.

Results

Check Result Note
Changed code review passed Both changed files read
Build and tests not run No local execution available

Findings

Blocking

None.

Non-blocking

None.

Sources

The changed code rejects nonzero IPv4 addresses in 0.0.0.0/8 before the host setsockopt call for multicast interface selection and membership changes. The diff removes the platform guards around those checks. The debt note now describes the behavior as applying on every host.

Not verified

Builds and tests were not run during this review. The reported macOS test results in the PR description were not independently verified. Both changed files were read; the manifest lists no excluded changed files.

To get this to a good state

Nothing is required. The PR description reports passing macOS tests and mutation checks; those results were not independently run in this review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6050946782 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26806#pullrequestreview-6050946782). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T02:36:59Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The changed multicast checks match the stated behavior, and the review found no verified blocking defect. ## What I ran Reviewed head `91cbf540f9e02cc932086e6b8e7b6fce80785aa`. I read the prepared description, commits, manifest, diff, and both changed files at the pinned head; I used `repo_read.py` to search callers. I did not run tests or build commands. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Both changed files read | | Build and tests | not run | No local execution available | ## Findings ### Blocking None. ### Non-blocking None. ## Sources The changed code rejects nonzero IPv4 addresses in `0.0.0.0/8` before the host `setsockopt` call for multicast interface selection and membership changes. The diff removes the platform guards around those checks. The debt note now describes the behavior as applying on every host. ## Not verified Builds and tests were not run during this review. The reported macOS test results in the PR description were not independently verified. Both changed files were read; the manifest lists no excluded changed files. ## To get this to a good state Nothing is required. The PR description reports passing macOS tests and mutation checks; those results were not independently run in this review.
NobleBrains commented 2026-12-01 00:22:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-12-01T00:22:01Z.

Review: APPROVED


Confirmed on macOS 15.

Setup: Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta, BUILD_TESTING=ON. These are the OS and compiler generation of the macos-15 runner.
Tree: main 93d64f2d1e + the open macOS build fixes #27201, #27739, #27843, #17425, #27827, #27767 (main does not build on macOS without them, see #28168), + #22091, #28369, #28075, #28076, #28284, then #17878, #20161, #25134, #26806, #22932, #28373, #27828, #27950, #27582, #24311 merged one after another. All merged cleanly.

guest_socket_options failures
same tree before this PR 3/3
with this PR at 91cbf540f9 0/5

Full ctest -j 6 after all of them: 7047/7066 pass. Compared with the run before the second group of merges, no test fails that passed before.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6122949547 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26806#pullrequestreview-6122949547). Originally posted by [NobleBrains](https://github.com/NobleBrains) on 2026-12-01T00:22:01Z. **Review:** APPROVED --- Confirmed on macOS 15. **Setup:** Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta, `BUILD_TESTING=ON`. These are the OS and compiler generation of the `macos-15` runner. **Tree:** `main` `93d64f2d1e` + the open macOS build fixes #27201, #27739, #27843, #17425, #27827, #27767 (`main` does not build on macOS without them, see #28168), + #22091, #28369, #28075, #28076, #28284, then #17878, #20161, #25134, #26806, #22932, #28373, #27828, #27950, #27582, #24311 merged one after another. All merged cleanly. | `guest_socket_options` | failures | |---|---| | same tree before this PR | 3/3 | | with this PR at `91cbf540f9` | 0/5 | **Full `ctest -j 6`** after all of them: 7047/7066 pass. Compared with the run before the second group of merges, no test fails that passed before. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 14:03:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T14:03:21Z.

Review: COMMENTED


Compiled this head's socket-options translation unit and ran a focused Linux IPv4 UDP check. IP_MULTICAST_IF accepted INADDR_ANY and returned guest EADDRNOTAVAIL for 0.0.0.1. Membership add and drop also returned guest EADDRNOTAVAIL for that interface, and the recorded interface and memberships stayed at their defaults. The Linux probe used a local socket.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6171296015 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26806#pullrequestreview-6171296015). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T14:03:21Z. **Review:** COMMENTED --- Compiled this head's socket-options translation unit and ran a focused Linux IPv4 UDP check. `IP_MULTICAST_IF` accepted `INADDR_ANY` and returned guest `EADDRNOTAVAIL` for `0.0.0.1`. Membership add and drop also returned guest `EADDRNOTAVAIL` for that interface, and the recorded interface and memberships stayed at their defaults. The Linux probe used a local socket. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/26806:upstream-pr/26806'
git switch 'upstream-pr/26806'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/26806'
git switch 'upstream-pr/26806'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/26806'
git switch 'upstream-pr/26806'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/26806'
git switch 'main'
git merge --squash 'upstream-pr/26806'
git switch 'main'
git merge --ff-only 'upstream-pr/26806'
git switch 'main'
git merge 'upstream-pr/26806'
git push origin 'main'
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!26806
No description provided.