fix(libkernel): accept an nfds above 1024 in select and pselect, as a PS5 does #19631

Merged
brajankw merged 1 commit from upstream-pr/19631 into main 2026-11-16 22:46:20 +00:00
brajankw commented 2026-11-13 16:59:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by brajankw on 2026-11-13T16:59:23Z.


What

select failed an nfds above 1024 with EINVAL, where a PS5 (firmware 13.60) accepts 1025 (the select entry in docs/dev/debt/libkernel.md).

  • select now takes any nfds from 0 up.
    • KernelSelectCheckSets_nid_no_patch reads the bits from descriptor 1024 up to the byte of bit nfds - 1, in chunks of 4096 bytes, and one byte at a time after a chunk fails. A set bit on a descriptor that is not open fails EBADF, and an unreadable byte fails EFAULT. FreeBSD 11.4's select_check_badfd does the same past its last open descriptor.
    • It returns the number of descriptors to scan: nfds up to 1024, otherwise 1024 or the highest set descriptor plus one. This bounds the copied sets by the open descriptors, whatever nfds is.
    • KernelSelectCheckedSets_nid_no_patch copies that range in, runs the existing scan and copies it back. Sets up to 1024 bits stay on the stack.
  • pselect: when a caught signal interrupts it, ScanAfterCaughtSignal checks the sets once. It saves and restores the range the scan writes, instead of handing an nfds above 1024 to select.
  • Changed tests: the tests that asserted EINVAL for 1025 (GuestSelect.cpp, GuestSelectWait.cpp, GuestSceNet.cpp) now expect the console's answer.
  • New tests: the descriptor set helpers of GuestSelect.cpp and GuestKernelSysPselect.cpp hold 2048 bits.
    • GuestSelect.cpp, above 1024:
      • a ready pipe at nfds 1025;
      • EBADF for the closed descriptor 1500 in the read set and in the except set;
      • pipe ends dup2'd to 1500, reported as ready in the read set and the write set;
      • the read end at 1500 timing out with its bit cleared.
    • GuestSelect.cpp, sets at the end of a mapping:
      • a set whose byte 128 is the last mapped byte: nfds 1025 succeeds, 1033 fails EFAULT, and with descriptor 1025 set, 1033 fails EBADF before reaching the unreadable byte;
      • an nfds of INT_MAX over one mapped page fails EFAULT.
    • GuestKernelSysPselect.cpp: a caught signal with descriptor 1500 in the set returns EINTR and leaves the set as it was, and EBADF once 1500 is closed.
  • Debt entry: cut to what is still open:
    • the cap at the last open descriptor that this implementation does not know;
    • what that changes below 1024 and in the order of EBADF, EFAULT and EINVAL;
    • the unmeasured console sets past 1024 bits;
    • the timeout gap that was already listed.

Tested

Linux (Debian 13, GCC 14.2.0, Release), on main fc69f49ce4.

  • ctest -R '^(guest_kernel_sys_pselect|guest_select|guest_select_wait|guest_sce_net.*|guest_poll|guest_socket_descriptors|guest_sp_syscall_wrapper)$': 14/14 passed, guest_sce_net_kernel_forwards included.
  • Negative control: this branch's tests with main's libkernel fail. All four of guest_select, guest_select_wait, guest_sce_net and guest_kernel_sys_pselect fail. The page-edge nfds 1025 case and the EBADF-before-fault case also fail on the previous head d3e86ee87d, which read whole words.
  • Full ctest (5811 tests, -j 12, RTX 3060) on this head: 5795 passed. Of the 16 failures, five are agc_driver cases that also failed on main in the same environment and ten need a .git directory, network or a passwd entry for the user. agc_driver_image_table_packed_guards passed when rerun on its own.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • python3 tools/pr_overlap.py --branch fix/libkernel-select-nfds-above-1024: failed closed on 30 pull requests that conflict with main. None of their diffs touches select, pselect or the select debt entry.
  • Windows: JJenkx's run of 17bebb404f in the comments; the rebase changed no line of the patch. Not tested on macOS. No title.

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:5299545576 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19631). Originally posted by [brajankw](https://github.com/brajankw) on 2026-11-13T16:59:23Z. --- ### What `select` failed an `nfds` above 1024 with `EINVAL`, where a PS5 (firmware 13.60) accepts 1025 (the `select` entry in `docs/dev/debt/libkernel.md`). - **`select`** now takes any `nfds` from 0 up. - `KernelSelectCheckSets_nid_no_patch` reads the bits from descriptor 1024 up to the byte of bit `nfds - 1`, in chunks of 4096 bytes, and one byte at a time after a chunk fails. A set bit on a descriptor that is not open fails `EBADF`, and an unreadable byte fails `EFAULT`. FreeBSD 11.4's `select_check_badfd` does the same past its last open descriptor. - It returns the number of descriptors to scan: `nfds` up to 1024, otherwise 1024 or the highest set descriptor plus one. This bounds the copied sets by the open descriptors, whatever `nfds` is. - `KernelSelectCheckedSets_nid_no_patch` copies that range in, runs the existing scan and copies it back. Sets up to 1024 bits stay on the stack. - **`pselect`**: when a caught signal interrupts it, `ScanAfterCaughtSignal` checks the sets once. It saves and restores the range the scan writes, instead of handing an `nfds` above 1024 to `select`. - **Changed tests:** the tests that asserted `EINVAL` for 1025 (`GuestSelect.cpp`, `GuestSelectWait.cpp`, `GuestSceNet.cpp`) now expect the console's answer. - **New tests:** the descriptor set helpers of `GuestSelect.cpp` and `GuestKernelSysPselect.cpp` hold 2048 bits. - `GuestSelect.cpp`, above 1024: - a ready pipe at `nfds` 1025; - `EBADF` for the closed descriptor 1500 in the read set and in the except set; - pipe ends `dup2`'d to 1500, reported as ready in the read set and the write set; - the read end at 1500 timing out with its bit cleared. - `GuestSelect.cpp`, sets at the end of a mapping: - a set whose byte 128 is the last mapped byte: `nfds` 1025 succeeds, 1033 fails `EFAULT`, and with descriptor 1025 set, 1033 fails `EBADF` before reaching the unreadable byte; - an `nfds` of `INT_MAX` over one mapped page fails `EFAULT`. - `GuestKernelSysPselect.cpp`: a caught signal with descriptor 1500 in the set returns `EINTR` and leaves the set as it was, and `EBADF` once 1500 is closed. - **Debt entry:** cut to what is still open: - the cap at the last open descriptor that this implementation does not know; - what that changes below 1024 and in the order of `EBADF`, `EFAULT` and `EINVAL`; - the unmeasured console sets past 1024 bits; - the timeout gap that was already listed. ### 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. --> Linux (Debian 13, GCC 14.2.0, Release), on `main` `fc69f49ce4`. - `ctest -R '^(guest_kernel_sys_pselect|guest_select|guest_select_wait|guest_sce_net.*|guest_poll|guest_socket_descriptors|guest_sp_syscall_wrapper)$'`: 14/14 passed, `guest_sce_net_kernel_forwards` included. - Negative control: this branch's tests with `main`'s libkernel fail. All four of `guest_select`, `guest_select_wait`, `guest_sce_net` and `guest_kernel_sys_pselect` fail. The page-edge `nfds` 1025 case and the `EBADF`-before-fault case also fail on the previous head `d3e86ee87d`, which read whole words. - Full `ctest` (5811 tests, `-j 12`, RTX 3060) on this head: 5795 passed. Of the 16 failures, five are `agc_driver` cases that also failed on `main` in the same environment and ten need a `.git` directory, network or a passwd entry for the user. `agc_driver_image_table_packed_guards` passed when rerun on its own. - `python3 tools/check_conventions.py --base origin/main`: passed. - `python3 tools/pr_overlap.py --branch fix/libkernel-select-nfds-above-1024`: failed closed on 30 pull requests that conflict with `main`. None of their diffs touches `select`, `pselect` or the `select` debt entry. - Windows: JJenkx's run of `17bebb404f` in the comments; the rebase changed no line of the patch. Not tested on macOS. No title. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-13 17:26:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T17:26:30Z.

Review: CHANGES_REQUESTED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_kernel_sys_pselect_tests, guest_sce_net_tests, guest_select_tests, guest_select_wait_tests built cleanly.
  • CTest (guest_kernel_sys_pselect, guest_sce_net_linger, guest_sce_net_keepalive, guest_sce_net_kernel_forwards, guest_sce_net, guest_sce_net_reuseport_ipv4, guest_sce_net_reuseport_ipv6, guest_sce_net_listen_ipv4, guest_sce_net_listen_ipv6, guest_select_wait, guest_select):
    1/11 Test #3977: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception:   1.58 sec
    2/11 Test #4001: guest_sce_net_listen_ipv6 ........   Passed    0.02 sec
    3/11 Test #4000: guest_sce_net_listen_ipv4 ........   Passed    0.02 sec
    4/11 Test #3972: guest_sce_net_linger .............   Passed    0.02 sec
    5/11 Test #3995: guest_sce_net_reuseport_ipv4 .....   Passed    0.02 sec
    6/11 Test #3996: guest_sce_net_reuseport_ipv6 .....   Passed    0.03 sec
    7/11 Test #3976: guest_sce_net_keepalive ..........   Passed    0.02 sec
    8/11 Test  #828: guest_kernel_sys_pselect .........   Passed    0.42 sec
    9/11 Test #4794: guest_select_wait ................   Passed    0.08 sec
    10/11 Test #3994: guest_sce_net ....................   Passed    2.25 sec
    11/11 Test #4795: guest_select .....................   Passed    4.72 sec
    91% tests passed, 1 tests failed out of 11
    
    The following tests FAILED:
    
  • Minor: please drop the Generated with footer from the description; the AI-assisted checkbox can stay.

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5895341646 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19631#pullrequestreview-5895341646). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-13T17:26:30Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `d3e86ee87d`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_kernel_sys_pselect_tests`, `guest_sce_net_tests`, `guest_select_tests`, `guest_select_wait_tests` built cleanly. - **CTest** (`guest_kernel_sys_pselect`, `guest_sce_net_linger`, `guest_sce_net_keepalive`, `guest_sce_net_kernel_forwards`, `guest_sce_net`, `guest_sce_net_reuseport_ipv4`, `guest_sce_net_reuseport_ipv6`, `guest_sce_net_listen_ipv4`, `guest_sce_net_listen_ipv6`, `guest_select_wait`, `guest_select`): ``` 1/11 Test #3977: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception: 1.58 sec 2/11 Test #4001: guest_sce_net_listen_ipv6 ........ Passed 0.02 sec 3/11 Test #4000: guest_sce_net_listen_ipv4 ........ Passed 0.02 sec 4/11 Test #3972: guest_sce_net_linger ............. Passed 0.02 sec 5/11 Test #3995: guest_sce_net_reuseport_ipv4 ..... Passed 0.02 sec 6/11 Test #3996: guest_sce_net_reuseport_ipv6 ..... Passed 0.03 sec 7/11 Test #3976: guest_sce_net_keepalive .......... Passed 0.02 sec 8/11 Test #828: guest_kernel_sys_pselect ......... Passed 0.42 sec 9/11 Test #4794: guest_select_wait ................ Passed 0.08 sec 10/11 Test #3994: guest_sce_net .................... Passed 2.25 sec 11/11 Test #4795: guest_select ..................... Passed 4.72 sec 91% tests passed, 1 tests failed out of 11 ``` ``` The following tests FAILED: ``` - Minor: please drop the `Generated with` footer from the description; the AI-assisted checkbox can stay. Requesting changes for the points above.
PrivacyOnion commented 2026-11-13 18:42:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T18:42:01Z.

Review: CHANGES_REQUESTED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_kernel_sys_pselect_tests, guest_sce_net_tests, guest_select_tests, guest_select_wait_tests built cleanly.
  • CTest (guest_kernel_sys_pselect, guest_sce_net_linger, guest_sce_net_keepalive, guest_sce_net_kernel_forwards, guest_sce_net, guest_sce_net_reuseport_ipv4, guest_sce_net_reuseport_ipv6, guest_sce_net_listen_ipv4, guest_sce_net_listen_ipv6, guest_select_wait, guest_select):
    1/11 Test #3977: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception:   0.86 sec
    2/11 Test #3995: guest_sce_net_reuseport_ipv4 .....   Passed    0.03 sec
    3/11 Test #4000: guest_sce_net_listen_ipv4 ........   Passed    0.03 sec
    4/11 Test #3972: guest_sce_net_linger .............   Passed    0.03 sec
    5/11 Test #3996: guest_sce_net_reuseport_ipv6 .....   Passed    0.03 sec
    6/11 Test #3976: guest_sce_net_keepalive ..........   Passed    0.04 sec
    7/11 Test #4001: guest_sce_net_listen_ipv6 ........   Passed    0.03 sec
    8/11 Test  #828: guest_kernel_sys_pselect .........   Passed    0.44 sec
    9/11 Test #4794: guest_select_wait ................   Passed    0.09 sec
    10/11 Test #3994: guest_sce_net ....................   Passed    1.86 sec
    11/11 Test #4795: guest_select .....................   Passed    4.90 sec
    91% tests passed, 1 tests failed out of 11
    
    The following tests FAILED:
    
  • Note: the AI-assisted checkbox can stay.

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5896254738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19631#pullrequestreview-5896254738). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-13T18:42:01Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `17bebb404f`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_kernel_sys_pselect_tests`, `guest_sce_net_tests`, `guest_select_tests`, `guest_select_wait_tests` built cleanly. - **CTest** (`guest_kernel_sys_pselect`, `guest_sce_net_linger`, `guest_sce_net_keepalive`, `guest_sce_net_kernel_forwards`, `guest_sce_net`, `guest_sce_net_reuseport_ipv4`, `guest_sce_net_reuseport_ipv6`, `guest_sce_net_listen_ipv4`, `guest_sce_net_listen_ipv6`, `guest_select_wait`, `guest_select`): ``` 1/11 Test #3977: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception: 0.86 sec 2/11 Test #3995: guest_sce_net_reuseport_ipv4 ..... Passed 0.03 sec 3/11 Test #4000: guest_sce_net_listen_ipv4 ........ Passed 0.03 sec 4/11 Test #3972: guest_sce_net_linger ............. Passed 0.03 sec 5/11 Test #3996: guest_sce_net_reuseport_ipv6 ..... Passed 0.03 sec 6/11 Test #3976: guest_sce_net_keepalive .......... Passed 0.04 sec 7/11 Test #4001: guest_sce_net_listen_ipv6 ........ Passed 0.03 sec 8/11 Test #828: guest_kernel_sys_pselect ......... Passed 0.44 sec 9/11 Test #4794: guest_select_wait ................ Passed 0.09 sec 10/11 Test #3994: guest_sce_net .................... Passed 1.86 sec 11/11 Test #4795: guest_select ..................... Passed 4.90 sec 91% tests passed, 1 tests failed out of 11 ``` ``` The following tests FAILED: ``` - Note: the AI-assisted checkbox can stay. Requesting changes for the points above.
PrivacyOnion commented 2026-11-15 20:24:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T20:24:10Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_kernel_sys_pselect_tests, guest_sce_net_tests, guest_select_tests, guest_select_wait_tests built cleanly.
  • CTest (guest_kernel_sys_pselect, guest_sce_net_linger, guest_sce_net_keepalive, guest_sce_net_kernel_forwards, guest_sce_net, guest_sce_net_reuseport_ipv4, guest_sce_net_reuseport_ipv6, guest_sce_net_listen_ipv4, guest_sce_net_listen_ipv6, guest_select_wait, guest_select):
    1/11 Test #4145: guest_sce_net ....................   Passed    1.80 sec
    2/11 Test  #834: guest_kernel_sys_pselect .........   Passed    0.43 sec
    3/11 Test #4128: guest_sce_net_kernel_forwards ....   Passed    0.23 sec
    4/11 Test #4977: guest_select_wait ................   Passed    0.09 sec
    5/11 Test #4147: guest_sce_net_reuseport_ipv6 .....   Passed    0.03 sec
    6/11 Test #4151: guest_sce_net_listen_ipv4 ........   Passed    0.03 sec
    7/11 Test #4127: guest_sce_net_keepalive ..........   Passed    0.03 sec
    8/11 Test #4152: guest_sce_net_listen_ipv6 ........   Passed    0.02 sec
    9/11 Test #4123: guest_sce_net_linger .............   Passed    0.02 sec
    10/11 Test #4146: guest_sce_net_reuseport_ipv4 .....   Passed    0.03 sec
    11/11 Test #4978: guest_select .....................   Passed    4.77 sec
    100% tests passed, 0 tests failed out of 11
    
  • Negative control: with core/libs/prx/libkernel/Socket/include/SocketPoll.hpp, core/libs/prx/libkernel/Socket/src/Pselect.cpp, core/libs/prx/libkernel/Socket/src/Socket.cpp reverted to main and the new tests kept, the suite fails:
    5/11 Test #4147: guest_sce_net_reuseport_ipv6 .....   Passed    0.03 sec
    6/11 Test #4151: guest_sce_net_listen_ipv4 ........   Passed    0.02 sec
    7/11 Test #4127: guest_sce_net_keepalive ..........   Passed    0.03 sec
    8/11 Test #4152: guest_sce_net_listen_ipv6 ........   Passed    0.01 sec
    9/11 Test #4146: guest_sce_net_reuseport_ipv4 .....   Passed    0.03 sec
    10/11 Test #4123: guest_sce_net_linger .............   Passed    0.02 sec
    11/11 Test #4978: guest_select .....................Subprocess aborted***Exception:   5.05 sec
    64% tests passed, 4 tests failed out of 11
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckSets_nid_no_patch bounds set reads past descriptor 1024 in 4096-byte chunks with single-byte GuestCopyIn_nid_no_patch fallbacks, returning GuestEfault (14) on inaccessible memory and GuestEbadf (9) on closed descriptors before advancing.
    • core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckedSets_nid_no_patch correctly allocates stack buffers for sets <= 1024 and vector storage for sets up to scanned descriptors, accurately copying in/out SelectSetBytes(scanned) and clearing unready descriptors without buffer overruns.
    • core/libs/prx/libkernel/Socket/src/Pselect.cpp: Verified ScanAfterCaughtSignal accurately preserves and restores guest set buffers up to SelectSetBytes(scanned) bytes upon caught signal interruptions, returning Eintr (4) when no descriptors are ready while propagating Ebadf (9) or Efault (14) failures.
    • core/libs/prx/libkernel/Socket/include/SocketPoll.hpp: Verified SelectSetBytes arithmetic and cross-platform type safety across LP64 and LLP64 platforms (std::size_t, std::uint64_t), matching word rounding ((scanned + 63) / 64) * sizeof(uint64_t).
    • core/libs/tests/GuestSelect.cpp and core/libs/tests/GuestKernelSysPselect.cpp: Verified test rigor and coverage for descriptors above 1024 (e.g. descriptor 1500), page boundaries with unmapped protection edges, timeout bit clearing, and caught signal masks.
    • docs/dev/debt/libkernel.md and AGENTS.md: Verified strict compliance with repository rules, including zero code comments added, accurate updates to the technical debt record for select, and conventional commit naming.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5912738174 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19631#pullrequestreview-5912738174). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-15T20:24:10Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `bfd794fa71`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_kernel_sys_pselect_tests`, `guest_sce_net_tests`, `guest_select_tests`, `guest_select_wait_tests` built cleanly. - **CTest** (`guest_kernel_sys_pselect`, `guest_sce_net_linger`, `guest_sce_net_keepalive`, `guest_sce_net_kernel_forwards`, `guest_sce_net`, `guest_sce_net_reuseport_ipv4`, `guest_sce_net_reuseport_ipv6`, `guest_sce_net_listen_ipv4`, `guest_sce_net_listen_ipv6`, `guest_select_wait`, `guest_select`): ``` 1/11 Test #4145: guest_sce_net .................... Passed 1.80 sec 2/11 Test #834: guest_kernel_sys_pselect ......... Passed 0.43 sec 3/11 Test #4128: guest_sce_net_kernel_forwards .... Passed 0.23 sec 4/11 Test #4977: guest_select_wait ................ Passed 0.09 sec 5/11 Test #4147: guest_sce_net_reuseport_ipv6 ..... Passed 0.03 sec 6/11 Test #4151: guest_sce_net_listen_ipv4 ........ Passed 0.03 sec 7/11 Test #4127: guest_sce_net_keepalive .......... Passed 0.03 sec 8/11 Test #4152: guest_sce_net_listen_ipv6 ........ Passed 0.02 sec 9/11 Test #4123: guest_sce_net_linger ............. Passed 0.02 sec 10/11 Test #4146: guest_sce_net_reuseport_ipv4 ..... Passed 0.03 sec 11/11 Test #4978: guest_select ..................... Passed 4.77 sec 100% tests passed, 0 tests failed out of 11 ``` - **Negative control**: with `core/libs/prx/libkernel/Socket/include/SocketPoll.hpp`, `core/libs/prx/libkernel/Socket/src/Pselect.cpp`, `core/libs/prx/libkernel/Socket/src/Socket.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 5/11 Test #4147: guest_sce_net_reuseport_ipv6 ..... Passed 0.03 sec 6/11 Test #4151: guest_sce_net_listen_ipv4 ........ Passed 0.02 sec 7/11 Test #4127: guest_sce_net_keepalive .......... Passed 0.03 sec 8/11 Test #4152: guest_sce_net_listen_ipv6 ........ Passed 0.01 sec 9/11 Test #4146: guest_sce_net_reuseport_ipv4 ..... Passed 0.03 sec 10/11 Test #4123: guest_sce_net_linger ............. Passed 0.02 sec 11/11 Test #4978: guest_select .....................Subprocess aborted***Exception: 5.05 sec 64% tests passed, 4 tests failed out of 11 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckSets_nid_no_patch bounds set reads past descriptor 1024 in 4096-byte chunks with single-byte GuestCopyIn_nid_no_patch fallbacks, returning GuestEfault (14) on inaccessible memory and GuestEbadf (9) on closed descriptors before advancing. - core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckedSets_nid_no_patch correctly allocates stack buffers for sets <= 1024 and vector storage for sets up to scanned descriptors, accurately copying in/out SelectSetBytes(scanned) and clearing unready descriptors without buffer overruns. - core/libs/prx/libkernel/Socket/src/Pselect.cpp: Verified ScanAfterCaughtSignal accurately preserves and restores guest set buffers up to SelectSetBytes(scanned) bytes upon caught signal interruptions, returning Eintr (4) when no descriptors are ready while propagating Ebadf (9) or Efault (14) failures. - core/libs/prx/libkernel/Socket/include/SocketPoll.hpp: Verified SelectSetBytes arithmetic and cross-platform type safety across LP64 and LLP64 platforms (std::size_t, std::uint64_t), matching word rounding ((scanned + 63) / 64) * sizeof(uint64_t). - core/libs/tests/GuestSelect.cpp and core/libs/tests/GuestKernelSysPselect.cpp: Verified test rigor and coverage for descriptors above 1024 (e.g. descriptor 1500), page boundaries with unmapped protection edges, timeout bit clearing, and caught signal masks. - docs/dev/debt/libkernel.md and AGENTS.md: Verified strict compliance with repository rules, including zero code comments added, accurate updates to the technical debt record for select, and conventional commit naming. - Note: the AI-assisted checkbox can stay. Looks Good To Me
PrivacyOnion commented 2026-11-15 20:24:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T20:24:11Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_kernel_sys_pselect_tests, guest_sce_net_tests, guest_select_tests, guest_select_wait_tests built cleanly.
  • CTest (guest_kernel_sys_pselect, guest_sce_net_linger, guest_sce_net_keepalive, guest_sce_net_kernel_forwards, guest_sce_net, guest_sce_net_reuseport_ipv4, guest_sce_net_reuseport_ipv6, guest_sce_net_listen_ipv4, guest_sce_net_listen_ipv6, guest_select_wait, guest_select):
    1/11 Test #4145: guest_sce_net ....................   Passed    1.80 sec
    2/11 Test  #834: guest_kernel_sys_pselect .........   Passed    0.43 sec
    3/11 Test #4128: guest_sce_net_kernel_forwards ....   Passed    0.23 sec
    4/11 Test #4977: guest_select_wait ................   Passed    0.09 sec
    5/11 Test #4147: guest_sce_net_reuseport_ipv6 .....   Passed    0.03 sec
    6/11 Test #4151: guest_sce_net_listen_ipv4 ........   Passed    0.03 sec
    7/11 Test #4127: guest_sce_net_keepalive ..........   Passed    0.03 sec
    8/11 Test #4152: guest_sce_net_listen_ipv6 ........   Passed    0.02 sec
    9/11 Test #4123: guest_sce_net_linger .............   Passed    0.02 sec
    10/11 Test #4146: guest_sce_net_reuseport_ipv4 .....   Passed    0.03 sec
    11/11 Test #4978: guest_select .....................   Passed    4.77 sec
    100% tests passed, 0 tests failed out of 11
    
  • Negative control: with core/libs/prx/libkernel/Socket/include/SocketPoll.hpp, core/libs/prx/libkernel/Socket/src/Pselect.cpp, core/libs/prx/libkernel/Socket/src/Socket.cpp reverted to main and the new tests kept, the suite fails:
    5/11 Test #4147: guest_sce_net_reuseport_ipv6 .....   Passed    0.03 sec
    6/11 Test #4151: guest_sce_net_listen_ipv4 ........   Passed    0.02 sec
    7/11 Test #4127: guest_sce_net_keepalive ..........   Passed    0.03 sec
    8/11 Test #4152: guest_sce_net_listen_ipv6 ........   Passed    0.01 sec
    9/11 Test #4146: guest_sce_net_reuseport_ipv4 .....   Passed    0.03 sec
    10/11 Test #4123: guest_sce_net_linger .............   Passed    0.02 sec
    11/11 Test #4978: guest_select .....................Subprocess aborted***Exception:   5.05 sec
    64% tests passed, 4 tests failed out of 11
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckSets_nid_no_patch bounds set reads past descriptor 1024 in 4096-byte chunks with single-byte GuestCopyIn_nid_no_patch fallbacks, returning GuestEfault (14) on inaccessible memory and GuestEbadf (9) on closed descriptors before advancing.
    • core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckedSets_nid_no_patch correctly allocates stack buffers for sets <= 1024 and vector storage for sets up to scanned descriptors, accurately copying in/out SelectSetBytes(scanned) and clearing unready descriptors without buffer overruns.
    • core/libs/prx/libkernel/Socket/src/Pselect.cpp: Verified ScanAfterCaughtSignal accurately preserves and restores guest set buffers up to SelectSetBytes(scanned) bytes upon caught signal interruptions, returning Eintr (4) when no descriptors are ready while propagating Ebadf (9) or Efault (14) failures.
    • core/libs/prx/libkernel/Socket/include/SocketPoll.hpp: Verified SelectSetBytes arithmetic and cross-platform type safety across LP64 and LLP64 platforms (std::size_t, std::uint64_t), matching word rounding ((scanned + 63) / 64) * sizeof(uint64_t).
    • core/libs/tests/GuestSelect.cpp and core/libs/tests/GuestKernelSysPselect.cpp: Verified test rigor and coverage for descriptors above 1024 (e.g. descriptor 1500), page boundaries with unmapped protection edges, timeout bit clearing, and caught signal masks.
    • docs/dev/debt/libkernel.md and AGENTS.md: Verified strict compliance with repository rules, including zero code comments added, accurate updates to the technical debt record for select, and conventional commit naming.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5912738294 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19631#pullrequestreview-5912738294). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-15T20:24:11Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `bfd794fa71`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_kernel_sys_pselect_tests`, `guest_sce_net_tests`, `guest_select_tests`, `guest_select_wait_tests` built cleanly. - **CTest** (`guest_kernel_sys_pselect`, `guest_sce_net_linger`, `guest_sce_net_keepalive`, `guest_sce_net_kernel_forwards`, `guest_sce_net`, `guest_sce_net_reuseport_ipv4`, `guest_sce_net_reuseport_ipv6`, `guest_sce_net_listen_ipv4`, `guest_sce_net_listen_ipv6`, `guest_select_wait`, `guest_select`): ``` 1/11 Test #4145: guest_sce_net .................... Passed 1.80 sec 2/11 Test #834: guest_kernel_sys_pselect ......... Passed 0.43 sec 3/11 Test #4128: guest_sce_net_kernel_forwards .... Passed 0.23 sec 4/11 Test #4977: guest_select_wait ................ Passed 0.09 sec 5/11 Test #4147: guest_sce_net_reuseport_ipv6 ..... Passed 0.03 sec 6/11 Test #4151: guest_sce_net_listen_ipv4 ........ Passed 0.03 sec 7/11 Test #4127: guest_sce_net_keepalive .......... Passed 0.03 sec 8/11 Test #4152: guest_sce_net_listen_ipv6 ........ Passed 0.02 sec 9/11 Test #4123: guest_sce_net_linger ............. Passed 0.02 sec 10/11 Test #4146: guest_sce_net_reuseport_ipv4 ..... Passed 0.03 sec 11/11 Test #4978: guest_select ..................... Passed 4.77 sec 100% tests passed, 0 tests failed out of 11 ``` - **Negative control**: with `core/libs/prx/libkernel/Socket/include/SocketPoll.hpp`, `core/libs/prx/libkernel/Socket/src/Pselect.cpp`, `core/libs/prx/libkernel/Socket/src/Socket.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 5/11 Test #4147: guest_sce_net_reuseport_ipv6 ..... Passed 0.03 sec 6/11 Test #4151: guest_sce_net_listen_ipv4 ........ Passed 0.02 sec 7/11 Test #4127: guest_sce_net_keepalive .......... Passed 0.03 sec 8/11 Test #4152: guest_sce_net_listen_ipv6 ........ Passed 0.01 sec 9/11 Test #4146: guest_sce_net_reuseport_ipv4 ..... Passed 0.03 sec 10/11 Test #4123: guest_sce_net_linger ............. Passed 0.02 sec 11/11 Test #4978: guest_select .....................Subprocess aborted***Exception: 5.05 sec 64% tests passed, 4 tests failed out of 11 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckSets_nid_no_patch bounds set reads past descriptor 1024 in 4096-byte chunks with single-byte GuestCopyIn_nid_no_patch fallbacks, returning GuestEfault (14) on inaccessible memory and GuestEbadf (9) on closed descriptors before advancing. - core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckedSets_nid_no_patch correctly allocates stack buffers for sets <= 1024 and vector storage for sets up to scanned descriptors, accurately copying in/out SelectSetBytes(scanned) and clearing unready descriptors without buffer overruns. - core/libs/prx/libkernel/Socket/src/Pselect.cpp: Verified ScanAfterCaughtSignal accurately preserves and restores guest set buffers up to SelectSetBytes(scanned) bytes upon caught signal interruptions, returning Eintr (4) when no descriptors are ready while propagating Ebadf (9) or Efault (14) failures. - core/libs/prx/libkernel/Socket/include/SocketPoll.hpp: Verified SelectSetBytes arithmetic and cross-platform type safety across LP64 and LLP64 platforms (std::size_t, std::uint64_t), matching word rounding ((scanned + 63) / 64) * sizeof(uint64_t). - core/libs/tests/GuestSelect.cpp and core/libs/tests/GuestKernelSysPselect.cpp: Verified test rigor and coverage for descriptors above 1024 (e.g. descriptor 1500), page boundaries with unmapped protection edges, timeout bit clearing, and caught signal masks. - docs/dev/debt/libkernel.md and AGENTS.md: Verified strict compliance with repository rules, including zero code comments added, accurate updates to the technical debt record for select, and conventional commit naming. - Note: the AI-assisted checkbox can stay. Looks Good To Me
PrivacyOnion commented 2026-11-16 09:40:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T09:40:46Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_kernel_sys_pselect_tests, guest_sce_net_tests, guest_select_tests, guest_select_wait_tests built cleanly.
  • CTest (guest_kernel_sys_pselect, guest_sce_net, guest_select_wait, guest_select):
    1/4 Test #4453: guest_sce_net ....................   Passed    1.70 sec
    2/4 Test  #871: guest_kernel_sys_pselect .........   Passed    0.41 sec
    3/4 Test #5337: guest_select_wait ................   Passed    0.07 sec
    4/4 Test #5338: guest_select .....................   Passed    4.75 sec
    100% tests passed, 0 tests failed out of 4
    
  • Negative control: with core/libs/prx/libkernel/Socket/include/SocketPoll.hpp, core/libs/prx/libkernel/Socket/src/Pselect.cpp, core/libs/prx/libkernel/Socket/src/Socket.cpp reverted to main and the new tests kept, the suite fails:
    1/4 Test #4453: guest_sce_net ....................Subprocess aborted***Exception:   1.23 sec
    2/4 Test  #871: guest_kernel_sys_pselect .........***Failed    0.21 sec
    3/4 Test #5337: guest_select_wait ................Subprocess aborted***Exception:   0.19 sec
    4/4 Test #5338: guest_select .....................Subprocess aborted***Exception:   4.66 sec
    0% tests passed, 4 tests failed out of 4
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckSets_nid_no_patch scans bitsets past descriptor 1024 up to byte (nfds - 1) / 8 in 4096-byte chunks with per-byte fallback on GuestCopyIn_nid_no_patch failure, masking trailing bits beyond nfds and returning GuestEfault (14) on unmapped memory or GuestEbadf (9) on closed descriptors via SelectDescriptorOpen.
    • core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckedSets_nid_no_patch and select_nid_postfix validate timeout and nfds < 0 (GuestEinval = 22), bound copied set sizes via SelectSetBytes(scanned), keep sets <= 1024 bits on the stack (fixed), and allocate heap buffers (grown) only when scanned > 1024.
    • core/libs/prx/libkernel/Socket/src/Pselect.cpp: Verified ScanAfterCaughtSignal validates nfds and wait, checks sets via KernelSelectCheckSets_nid_no_patch, saves and restores scanned bytes around KernelSelectCheckedSets_nid_no_patch, and preserves EINTR (4) when no descriptors are ready.
    • core/libs/prx/libkernel/Socket/include/SocketPoll.hpp: Verified SelectSetBytes arithmetic ((scanned + 63) / 64) * sizeof(std::uint64_t) and LP64/LLP64 type safety across Linux and Windows builds.
    • core/libs/tests/GuestSceNet.cpp, GuestSelect.cpp, GuestKernelSysPselect.cpp: Verified test coverage for nfds > 1024 (including 1025, 1500, and INT_MAX), EBADF and EFAULT page-boundary behavior, and CTest pass results.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5917849374 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19631#pullrequestreview-5917849374). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T09:40:46Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `715f629a37`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_kernel_sys_pselect_tests`, `guest_sce_net_tests`, `guest_select_tests`, `guest_select_wait_tests` built cleanly. - **CTest** (`guest_kernel_sys_pselect`, `guest_sce_net`, `guest_select_wait`, `guest_select`): ``` 1/4 Test #4453: guest_sce_net .................... Passed 1.70 sec 2/4 Test #871: guest_kernel_sys_pselect ......... Passed 0.41 sec 3/4 Test #5337: guest_select_wait ................ Passed 0.07 sec 4/4 Test #5338: guest_select ..................... Passed 4.75 sec 100% tests passed, 0 tests failed out of 4 ``` - **Negative control**: with `core/libs/prx/libkernel/Socket/include/SocketPoll.hpp`, `core/libs/prx/libkernel/Socket/src/Pselect.cpp`, `core/libs/prx/libkernel/Socket/src/Socket.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/4 Test #4453: guest_sce_net ....................Subprocess aborted***Exception: 1.23 sec 2/4 Test #871: guest_kernel_sys_pselect .........***Failed 0.21 sec 3/4 Test #5337: guest_select_wait ................Subprocess aborted***Exception: 0.19 sec 4/4 Test #5338: guest_select .....................Subprocess aborted***Exception: 4.66 sec 0% tests passed, 4 tests failed out of 4 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckSets_nid_no_patch scans bitsets past descriptor 1024 up to byte (nfds - 1) / 8 in 4096-byte chunks with per-byte fallback on GuestCopyIn_nid_no_patch failure, masking trailing bits beyond nfds and returning GuestEfault (14) on unmapped memory or GuestEbadf (9) on closed descriptors via SelectDescriptorOpen. - core/libs/prx/libkernel/Socket/src/Socket.cpp: Verified KernelSelectCheckedSets_nid_no_patch and select_nid_postfix validate timeout and nfds < 0 (GuestEinval = 22), bound copied set sizes via SelectSetBytes(scanned), keep sets <= 1024 bits on the stack (fixed), and allocate heap buffers (grown) only when scanned > 1024. - core/libs/prx/libkernel/Socket/src/Pselect.cpp: Verified ScanAfterCaughtSignal validates nfds and wait, checks sets via KernelSelectCheckSets_nid_no_patch, saves and restores scanned bytes around KernelSelectCheckedSets_nid_no_patch, and preserves EINTR (4) when no descriptors are ready. - core/libs/prx/libkernel/Socket/include/SocketPoll.hpp: Verified SelectSetBytes arithmetic ((scanned + 63) / 64) * sizeof(std::uint64_t) and LP64/LLP64 type safety across Linux and Windows builds. - core/libs/tests/GuestSceNet.cpp, GuestSelect.cpp, GuestKernelSysPselect.cpp: Verified test coverage for nfds > 1024 (including 1025, 1500, and INT_MAX), EBADF and EFAULT page-boundary behavior, and CTest pass results. Looks Good To Me
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!19631
No description provided.