fix(libkernel): keep the F_SETFL status flags of a socket, as FreeBSD 11.4 does #22573

Merged
brajankw merged 1 commit from upstream-pr/22573 into main 2026-11-27 15:55:17 +00:00
brajankw commented 2026-11-17 21:51:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by brajankw on 2026-11-17T21:51:04Z.


What

fcntl(F_SETFL) on a guest socket or a sceNetSocket socket failed with EOPNOTSUPP for any bit other than the access mode and O_NONBLOCK, and F_GETFL reported only O_RDWR and O_NONBLOCK. In FreeBSD 11.4, kern_fcntl takes the argument's FCNTLFLAGS bits into the file's f_flag and drops the rest. F_GETFL returns OFLAGS(f_flag), the access mode as O_RDWR plus those bits. soo_ioctl accepts the FIONBIO and FIOASYNC calls that follow, so F_SETFL on a socket does not fail.

  • The settable bits are O_APPEND, O_ASYNC, O_FSYNC, O_DIRECT and the read-ahead bit (O_CREAT), besides O_NONBLOCK. Files, directories and pipes already take that set (SettableStatusFlags in DescriptorControl.cpp).
  • O_NOFOLLOW still fails with EOPNOTSUPP and changes nothing. FreeBSD never fails it: it adds it to FCNTLFLAGS as FPOSIXSHM in a kernel built with COMPAT_FREEBSD4 to COMPAT_FREEBSD7 and drops it otherwise. The amd64 GENERIC config has those options; the console's are unknown, so O_NOFOLLOW keeps the error a title already handles, and the debt entry records the difference.
  • Socket/src/Udp.cpp:
    • a guest socket keeps the bits in statusFlags, under its modeMutex. F_SETFL replaces them and ignores other bits, and F_GETFL reports them after O_RDWR;
    • a dup shares them, since the duplicate shares the Socket;
    • accept copies the listener's bits, as kern_accept4 gives the new file the listener's f_flag for accept (ACCEPT4_INHERIT).
  • libSceNet/Export.cpp: a sceNetSocket socket keeps the bits on its native handle the same way, through the status control libkernel's fcntl calls, and sceNetAccept copies them. A per-handle mutex covers F_SETFL, F_GETFL and the sceNetAccept copy. F_SETFL sets the host non-blocking mode on the handle it looked up, through the helper sceNetSetsockopt's SO_NBIO now uses, not by descriptor number again. sceNetSetsockopt's SO_NBIO, which sceNetIoctl(FIONBIO) and the sceNetAccept inheritance use, now takes the same mutex. It also stores the mode on its own handle, not on whatever socket the number names when it finishes. So the host non-blocking mode, nonblock and the other bits change together, on one socket, as f_flag does.
  • Nothing else reads these bits, and on a socket they change nothing:
    • O_APPEND, O_FSYNC, O_DIRECT and read-ahead have no effect on a socket in FreeBSD;
    • O_ASYNC raises SIGIO only for an owner, as sowakeup shows. No socket here can get one: F_SETOWN fails with EINVAL, FIOSETOWN with ENOTTY and SIOCSPGRP with EADDRNOTAVAIL or ENOTTY.
  • Tests:
    • GuestSocketDescriptorFlags.cpp: F_SETFL keeps the five bits and ignores O_WRONLY and O_NOCTTY. A dup shares the bits both ways, accept copies them, and F_SETFL 0 clears them on the listener only;
    • GuestSceNet.cpp: the same on a sceNetSocket socket and through sceNetAccept. O_NOFOLLOW with O_NONBLOCK fails with EOPNOTSUPP there and leaves the flags as they were. Two threads also set different flag sets from a common start while the main thread reads them; every call must succeed, and every read and the final state must be one whole set. A third check toggles SO_NBIO from one thread while the main thread changes the kept bits with F_SETFL. Each F_GETFL must show the bits just set, and on Linux and macOS the host socket's O_NONBLOCK must match F_GETFL at the end;
    • GuestKernelFcntl.cpp: sceKernelFcntl keeps O_ASYNC and ignores O_NOCTTY, and O_NOFOLLOW with O_ASYNC fails with EOPNOTSUPP and sets neither.
  • Two earlier expectations that F_SETFL fails for an unknown bit are replaced: 0x8000 in GuestUdp.cpp (-1, #3) and GuestKernelFcntl.cpp (EOPNOTSUPP, #3078). They pinned the earlier behaviour; neither was measured, and the sceKernelFcntl debt entry lists F_SETFL as not measured on a console. The 0x100 check in GuestSceNet.cpp (#4924) still expects EOPNOTSUPP.
  • Debt fragment: the fcntl entry drops "with O_NONBLOCK", and a new F_SETFL on a socket entry states the O_NOFOLLOW error first.
  • Unchanged:
    • ioctl(FIOASYNC) on a guest socket still fails with ENOTTY, as the ioctl, _ioctl entry says. #22395 changes the lines next to it, so that stays for a follow-up;
    • O_ASYNC on a host socket that is not a guest socket still throws;
    • files keep dropping O_NOFOLLOW through SettableStatusFlags.

Tested

Linux (Debian 13, GCC 14.2.0, Release), on main 6b4e58a503, then rebased onto 8dbb3bf68d for the SO_NBIO change; there guest_sce_net passed 10 of 10 repeated runs. After review, O_NOFOLLOW went back to EOPNOTSUPP, and the branch was rebased onto 6286d36449. That brings in #19824, which also changes Udp.cpp (poll on standard descriptors) and merges cleanly with this change. The 50 focused tests below pass there.

  • Negative control: before the change, guest_socket_descriptor_flags, guest_udp and guest_sce_net abort on their new F_SETFL checks (EOPNOTSUPP). With the version that threw on O_NOFOLLOW, guest_sce_net and guest_kernel_fcntl abort on that throw.
  • ctest over the 36 socket, fcntl and accept test executables (guest_socket_*, guest_net_*, guest_sce_net*, guest_tcp, guest_udp, guest_kernel_fcntl*, guest_poll, guest_curl_sockets and others, 50 tests): 49 passed; guest_socket_options_multicast skips without a network.
  • On 6286d36449, guest_sce_net needs a standard input that is not a pipe. Since #19824, its select check on descriptors 0 to 2 fails with EBADF when standard input is a pipe, on main too. These runs use /dev/null.
  • Full ctest (6040 tests, -j 12) on the first version of this branch: 6025 passed. The 15 failures also fail on main in the same environment:
    • nine need a .git directory, network access or a passwd entry for the user: conventions_git_errors, test_script_registration, web_library_assets, title_run, title_run_identity, guest_kernel_sys_login, guest_net_ctl, guest_getlogin and guest_getlogin_no_session;
    • six are agc_driver GPU cases.
  • python3 tools/check_conventions.py --base origin/main: passed, with the length warning on the fcntl entry. That entry was over 4000 characters before; this change only shortens it.
  • python3 tools/pr_overlap.py --branch failed closed on PRs that conflict with main. #16826 changes the first lines of ControlSocketStatusForKernel and CheckKernelStatusFlags for F_GETFD and F_SETFD. #12688 and #12965 change the Windows FIONBIO line next to the changed check. #11896 changes Udp.cpp for MSG_WAITALL, and #18457 edits the same fcntl debt entry for F_GETOWN on a pipe. None of them changes the status flags.
  • Not tested on Windows or 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 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:5365631020 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22573). Originally posted by [brajankw](https://github.com/brajankw) on 2026-11-17T21:51:04Z. --- ### What `fcntl(F_SETFL)` on a guest socket or a `sceNetSocket` socket failed with `EOPNOTSUPP` for any bit other than the access mode and `O_NONBLOCK`, and `F_GETFL` reported only `O_RDWR` and `O_NONBLOCK`. In FreeBSD 11.4, [`kern_fcntl`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/kern_descrip.c#L551-L577) takes the argument's [`FCNTLFLAGS`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/sys/fcntl.h#L157-L170) bits into the file's `f_flag` and drops the rest. `F_GETFL` returns `OFLAGS(f_flag)`, the access mode as `O_RDWR` plus those bits. `soo_ioctl` accepts the `FIONBIO` and `FIOASYNC` calls that follow, so `F_SETFL` on a socket does not fail. - The settable bits are `O_APPEND`, `O_ASYNC`, `O_FSYNC`, `O_DIRECT` and the read-ahead bit (`O_CREAT`), besides `O_NONBLOCK`. Files, directories and pipes already take that set (`SettableStatusFlags` in `DescriptorControl.cpp`). - `O_NOFOLLOW` still fails with `EOPNOTSUPP` and changes nothing. FreeBSD never fails it: it adds it to `FCNTLFLAGS` as `FPOSIXSHM` in a kernel built with `COMPAT_FREEBSD4` to `COMPAT_FREEBSD7` and drops it otherwise. The amd64 `GENERIC` config has those options; the console's are unknown, so `O_NOFOLLOW` keeps the error a title already handles, and the debt entry records the difference. - `Socket/src/Udp.cpp`: - a guest socket keeps the bits in `statusFlags`, under its `modeMutex`. `F_SETFL` replaces them and ignores other bits, and `F_GETFL` reports them after `O_RDWR`; - a `dup` shares them, since the duplicate shares the `Socket`; - `accept` copies the listener's bits, as [`kern_accept4`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/uipc_syscalls.c#L436-L451) gives the new file the listener's `f_flag` for `accept` (`ACCEPT4_INHERIT`). - `libSceNet/Export.cpp`: a `sceNetSocket` socket keeps the bits on its native handle the same way, through the status control libkernel's `fcntl` calls, and `sceNetAccept` copies them. A per-handle mutex covers `F_SETFL`, `F_GETFL` and the `sceNetAccept` copy. `F_SETFL` sets the host non-blocking mode on the handle it looked up, through the helper `sceNetSetsockopt`'s `SO_NBIO` now uses, not by descriptor number again. `sceNetSetsockopt`'s `SO_NBIO`, which `sceNetIoctl(FIONBIO)` and the `sceNetAccept` inheritance use, now takes the same mutex. It also stores the mode on its own handle, not on whatever socket the number names when it finishes. So the host non-blocking mode, `nonblock` and the other bits change together, on one socket, as `f_flag` does. - Nothing else reads these bits, and on a socket they change nothing: - `O_APPEND`, `O_FSYNC`, `O_DIRECT` and read-ahead have no effect on a socket in FreeBSD; - `O_ASYNC` raises `SIGIO` only for an owner, as [`sowakeup`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/uipc_sockbuf.c#L339-L340) shows. No socket here can get one: `F_SETOWN` fails with `EINVAL`, `FIOSETOWN` with `ENOTTY` and `SIOCSPGRP` with `EADDRNOTAVAIL` or `ENOTTY`. - Tests: - `GuestSocketDescriptorFlags.cpp`: `F_SETFL` keeps the five bits and ignores `O_WRONLY` and `O_NOCTTY`. A `dup` shares the bits both ways, `accept` copies them, and `F_SETFL 0` clears them on the listener only; - `GuestSceNet.cpp`: the same on a `sceNetSocket` socket and through `sceNetAccept`. `O_NOFOLLOW` with `O_NONBLOCK` fails with `EOPNOTSUPP` there and leaves the flags as they were. Two threads also set different flag sets from a common start while the main thread reads them; every call must succeed, and every read and the final state must be one whole set. A third check toggles `SO_NBIO` from one thread while the main thread changes the kept bits with `F_SETFL`. Each `F_GETFL` must show the bits just set, and on Linux and macOS the host socket's `O_NONBLOCK` must match `F_GETFL` at the end; - `GuestKernelFcntl.cpp`: `sceKernelFcntl` keeps `O_ASYNC` and ignores `O_NOCTTY`, and `O_NOFOLLOW` with `O_ASYNC` fails with `EOPNOTSUPP` and sets neither. - Two earlier expectations that `F_SETFL` fails for an unknown bit are replaced: `0x8000` in `GuestUdp.cpp` (`-1`, #3) and `GuestKernelFcntl.cpp` (`EOPNOTSUPP`, #3078). They pinned the earlier behaviour; neither was measured, and the `sceKernelFcntl` debt entry lists `F_SETFL` as not measured on a console. The `0x100` check in `GuestSceNet.cpp` (#4924) still expects `EOPNOTSUPP`. - Debt fragment: the `fcntl` entry drops "with `O_NONBLOCK`", and a new `F_SETFL on a socket` entry states the `O_NOFOLLOW` error first. - Unchanged: - `ioctl(FIOASYNC)` on a guest socket still fails with `ENOTTY`, as the `ioctl, _ioctl` entry says. #22395 changes the lines next to it, so that stays for a follow-up; - `O_ASYNC` on a host socket that is not a guest socket still throws; - files keep dropping `O_NOFOLLOW` through `SettableStatusFlags`. ### 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` `6b4e58a503`, then rebased onto `8dbb3bf68d` for the `SO_NBIO` change; there `guest_sce_net` passed 10 of 10 repeated runs. After review, `O_NOFOLLOW` went back to `EOPNOTSUPP`, and the branch was rebased onto `6286d36449`. That brings in #19824, which also changes `Udp.cpp` (`poll` on standard descriptors) and merges cleanly with this change. The 50 focused tests below pass there. - Negative control: before the change, `guest_socket_descriptor_flags`, `guest_udp` and `guest_sce_net` abort on their new `F_SETFL` checks (`EOPNOTSUPP`). With the version that threw on `O_NOFOLLOW`, `guest_sce_net` and `guest_kernel_fcntl` abort on that throw. - `ctest` over the 36 socket, `fcntl` and `accept` test executables (`guest_socket_*`, `guest_net_*`, `guest_sce_net*`, `guest_tcp`, `guest_udp`, `guest_kernel_fcntl*`, `guest_poll`, `guest_curl_sockets` and others, 50 tests): 49 passed; `guest_socket_options_multicast` skips without a network. - On `6286d36449`, `guest_sce_net` needs a standard input that is not a pipe. Since #19824, its `select` check on descriptors 0 to 2 fails with `EBADF` when standard input is a pipe, on `main` too. These runs use `/dev/null`. - Full `ctest` (6040 tests, `-j 12`) on the first version of this branch: 6025 passed. The 15 failures also fail on `main` in the same environment: - nine need a `.git` directory, network access or a passwd entry for the user: `conventions_git_errors`, `test_script_registration`, `web_library_assets`, `title_run`, `title_run_identity`, `guest_kernel_sys_login`, `guest_net_ctl`, `guest_getlogin` and `guest_getlogin_no_session`; - six are `agc_driver` GPU cases. - `python3 tools/check_conventions.py --base origin/main`: passed, with the length warning on the `fcntl` entry. That entry was over 4000 characters before; this change only shortens it. - `python3 tools/pr_overlap.py --branch` failed closed on PRs that conflict with `main`. #16826 changes the first lines of `ControlSocketStatusForKernel` and `CheckKernelStatusFlags` for `F_GETFD` and `F_SETFD`. #12688 and #12965 change the Windows `FIONBIO` line next to the changed check. #11896 changes `Udp.cpp` for `MSG_WAITALL`, and #18457 edits the same `fcntl` debt entry for `F_GETOWN` on a pipe. None of them changes the status flags. - Not tested on Windows or 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) 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
PrivacyOnion commented 2026-11-17 21:52:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T21:52:09Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_kernel_fcntl_tests, guest_sce_net_tests, guest_socket_descriptor_flags_tests, guest_udp_tests built cleanly.
  • CTest (guest_sce_net, guest_socket_descriptor_flags, guest_udp, guest_kernel_fcntl):
    1/4 Test #5604: guest_kernel_fcntl ...............   Passed    0.01 sec
    2/4 Test #5396: guest_socket_descriptor_flags ....   Passed    0.00 sec
    3/4 Test #5526: guest_udp ........................   Passed    0.56 sec
    4/4 Test #4629: guest_sce_net ....................   Passed    1.70 sec
    100% tests passed, 0 tests failed out of 4
    
  • Negative control: with core/libs/prx/libSceNet/Export.cpp, core/libs/prx/libkernel/Socket/src/Udp.cpp reverted to main and the new tests kept, the suite fails:
    1/4 Test #5526: guest_udp ........................Subprocess aborted***Exception:   0.49 sec
    2/4 Test #5604: guest_kernel_fcntl ...............Subprocess aborted***Exception:   0.12 sec
    3/4 Test #5396: guest_socket_descriptor_flags ....Subprocess aborted***Exception:   0.12 sec
    4/4 Test #4629: guest_sce_net ....................Subprocess aborted***Exception:   1.10 sec
    0% tests passed, 4 tests failed out of 4
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified fcntl(F_GETFL) and fcntl(F_SETFL) handling in core/libs/prx/libSceNet/Export.cpp:ControlSocketStatusForKernel and core/libs/prx/libkernel/Socket/src/Udp.cpp:fcntl_nid_postfix for flag preservation, masking against GuestKeptStatusFlags, and rejection of O_NOFOLLOW (GuestPosixSharedMemoryFlag).
    • Audited concurrency and synchronization: verified mutex protection of status and nonblock flags in NativeSocketHandle::statusMutex and Socket::modeMutex during F_GETFL, F_SETFL, and accept operations.
    • Checked inheritance semantics in sceNetAccept and accept_nid_postfix to ensure listener status flags and non-blocking settings are correctly propagated to accepted child sockets.
    • Verified POSIX and FreeBSD 11.4 compliance regarding settable file status flags (O_APPEND, O_ASYNC, O_FSYNC, O_DIRECT, O_CREAT/read-ahead) and error reporting.
    • Inspected technical debt fragment docs/dev/debt/changes/fix-libkernel-socket-status-flags.md and AGENTS.md compliance, confirming absence of prohibited comments, proper formatting, and appropriate test coverage across changed tests.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5947217534 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22573#pullrequestreview-5947217534). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-17T21:52:09Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `f9985ccbb1`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_kernel_fcntl_tests`, `guest_sce_net_tests`, `guest_socket_descriptor_flags_tests`, `guest_udp_tests` built cleanly. - **CTest** (`guest_sce_net`, `guest_socket_descriptor_flags`, `guest_udp`, `guest_kernel_fcntl`): ``` 1/4 Test #5604: guest_kernel_fcntl ............... Passed 0.01 sec 2/4 Test #5396: guest_socket_descriptor_flags .... Passed 0.00 sec 3/4 Test #5526: guest_udp ........................ Passed 0.56 sec 4/4 Test #4629: guest_sce_net .................... Passed 1.70 sec 100% tests passed, 0 tests failed out of 4 ``` - **Negative control**: with `core/libs/prx/libSceNet/Export.cpp`, `core/libs/prx/libkernel/Socket/src/Udp.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/4 Test #5526: guest_udp ........................Subprocess aborted***Exception: 0.49 sec 2/4 Test #5604: guest_kernel_fcntl ...............Subprocess aborted***Exception: 0.12 sec 3/4 Test #5396: guest_socket_descriptor_flags ....Subprocess aborted***Exception: 0.12 sec 4/4 Test #4629: guest_sce_net ....................Subprocess aborted***Exception: 1.10 sec 0% tests passed, 4 tests failed out of 4 ``` Restoring the change makes it pass again. - **Code reading**: - Verified fcntl(F_GETFL) and fcntl(F_SETFL) handling in core/libs/prx/libSceNet/Export.cpp:ControlSocketStatusForKernel and core/libs/prx/libkernel/Socket/src/Udp.cpp:fcntl_nid_postfix for flag preservation, masking against GuestKeptStatusFlags, and rejection of O_NOFOLLOW (GuestPosixSharedMemoryFlag). - Audited concurrency and synchronization: verified mutex protection of status and nonblock flags in NativeSocketHandle::statusMutex and Socket::modeMutex during F_GETFL, F_SETFL, and accept operations. - Checked inheritance semantics in sceNetAccept and accept_nid_postfix to ensure listener status flags and non-blocking settings are correctly propagated to accepted child sockets. - Verified POSIX and FreeBSD 11.4 compliance regarding settable file status flags (O_APPEND, O_ASYNC, O_FSYNC, O_DIRECT, O_CREAT/read-ahead) and error reporting. - Inspected technical debt fragment docs/dev/debt/changes/fix-libkernel-socket-status-flags.md and AGENTS.md compliance, confirming absence of prohibited comments, proper formatting, and appropriate test coverage across changed tests. Looks Good To Me
MarcZX10 commented 2026-11-18 00:40:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T00:40:52Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: synchronize the SO_NBIO state updates with the new status mutex so F_GETFL and F_SETFL observe consistent socket state.

What I ran

Reviewed head f9985ccbb12c1d0319f53f188c9257f5ed0d967f against the prepared diff and repository source through repo_read.py. No test commands were run. The author reports Linux tests and convention checks in the PR description; those results were not independently verified.

Results

Check Result Note
Source review failed SO_NBIO bypasses status mutex
Tests not run Author-reported results only
Other changed code reviewed Prepared diff and added lines checked

Findings

Blocking

  • core/libs/prx/libSceNet/Export.cpp:2133 updates NativeSocketHandle::nonblock without statusMutex, while F_GETFL reads it under that mutex at core/libs/prx/libSceNet/Export.cpp:1234-1236 and F_SETFL changes the host nonblocking mode and stored status flags under it at core/libs/prx/libSceNet/Export.cpp:1234-1251. A concurrent sceNetSetsockopt(NET_SO_NBIO) and F_GETFL/F_SETFL therefore race on the host socket state; the std::atomic on nonblock prevents a C++ data race on that field but does not serialize the host fcntl operation with F_SETFL. Take the status mutex around the SO_NBIO host-mode change and state update (or otherwise coordinate it with F_SETFL).

Non-blocking

None.

Not verified

  • No tests or builds were run in this review; the Linux test, negative-control, and convention-check results are author-reported only.
  • Windows, macOS, and console behavior was not verified.
  • All seven changed files listed in manifest.json were read at their changed lines; no changed file was excluded.

To get this to a good state

  • Synchronize the NET_SO_NBIO update with statusMutex, then rerun the relevant libSceNet socket status-flag tests, including the concurrency case.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5949050383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22573#pullrequestreview-5949050383). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T00:40:52Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: synchronize the `SO_NBIO` state updates with the new status mutex so `F_GETFL` and `F_SETFL` observe consistent socket state. ## What I ran Reviewed head `f9985ccbb12c1d0319f53f188c9257f5ed0d967f` against the prepared diff and repository source through `repo_read.py`. No test commands were run. The author reports Linux tests and convention checks in the PR description; those results were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | `SO_NBIO` bypasses status mutex | | Tests | not run | Author-reported results only | | Other changed code | reviewed | Prepared diff and added lines checked | ## Findings ### Blocking - `core/libs/prx/libSceNet/Export.cpp:2133` updates `NativeSocketHandle::nonblock` without `statusMutex`, while `F_GETFL` reads it under that mutex at `core/libs/prx/libSceNet/Export.cpp:1234-1236` and `F_SETFL` changes the host nonblocking mode and stored status flags under it at `core/libs/prx/libSceNet/Export.cpp:1234-1251`. A concurrent `sceNetSetsockopt(NET_SO_NBIO)` and `F_GETFL`/`F_SETFL` therefore race on the host socket state; the `std::atomic` on `nonblock` prevents a C++ data race on that field but does not serialize the host `fcntl` operation with `F_SETFL`. Take the status mutex around the `SO_NBIO` host-mode change and state update (or otherwise coordinate it with `F_SETFL`). ### Non-blocking None. ## Not verified - No tests or builds were run in this review; the Linux test, negative-control, and convention-check results are author-reported only. - Windows, macOS, and console behavior was not verified. - All seven changed files listed in `manifest.json` were read at their changed lines; no changed file was excluded. ## To get this to a good state - Synchronize the `NET_SO_NBIO` update with `statusMutex`, then rerun the relevant `libSceNet` socket status-flag tests, including the concurrency case.
MarcZX10 commented 2026-11-18 16:02:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T16:02:29Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected changes consistently retain socket status flags, synchronize the libSceNet nonblocking state, and add focused coverage; I did not run the reported checks, so approval is not justified.

What I ran

Read the prepared description, commit list, manifest, and full diff at head fca824409d0b7fe75cf5246d284af8372d25257d, then inspected changed code and nearby context with repo_read.py. No tests or prechecks were run in this review.

Results

Check Result Note
Diff and targeted source review passed No concrete defect found in inspected changes
Tests and prechecks not run Results in the description are author-reported
File inventory passed Manifest lists seven changed files as included

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read the changed regions and relevant context in core/libs/prx/libSceNet/Export.cpp, core/libs/prx/libkernel/Socket/src/Udp.cpp, core/libs/tests/GuestKernelFcntl.cpp, core/libs/tests/GuestSceNet.cpp, core/libs/tests/GuestSocketDescriptorFlags.cpp, core/libs/tests/GuestUdp.cpp, and docs/dev/debt/changes/fix-libkernel-socket-status-flags.md. I did not read the complete contents of the two large implementation files or the test files beyond the relevant regions. The files.json inventory was unavailable through the reader; the manifest marks all seven changed files included with no exclusions. Tests, prechecks, Windows/macOS behavior, and console behavior were not independently verified.

To get this to a good state

Nothing is required. The reported test and precheck results remain author-reported and were not independently confirmed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5960318782 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22573#pullrequestreview-5960318782). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T16:02:29Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected changes consistently retain socket status flags, synchronize the libSceNet nonblocking state, and add focused coverage; I did not run the reported checks, so approval is not justified. ## What I ran Read the prepared description, commit list, manifest, and full diff at head `fca824409d0b7fe75cf5246d284af8372d25257d`, then inspected changed code and nearby context with `repo_read.py`. No tests or prechecks were run in this review. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | No concrete defect found in inspected changes | | Tests and prechecks | not run | Results in the description are author-reported | | File inventory | passed | Manifest lists seven changed files as included | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I read the changed regions and relevant context in `core/libs/prx/libSceNet/Export.cpp`, `core/libs/prx/libkernel/Socket/src/Udp.cpp`, `core/libs/tests/GuestKernelFcntl.cpp`, `core/libs/tests/GuestSceNet.cpp`, `core/libs/tests/GuestSocketDescriptorFlags.cpp`, `core/libs/tests/GuestUdp.cpp`, and `docs/dev/debt/changes/fix-libkernel-socket-status-flags.md`. I did not read the complete contents of the two large implementation files or the test files beyond the relevant regions. The `files.json` inventory was unavailable through the reader; the manifest marks all seven changed files included with no exclusions. Tests, prechecks, Windows/macOS behavior, and console behavior were not independently verified. ## To get this to a good state Nothing is required. The reported test and precheck results remain author-reported and were not independently confirmed.
MarcZX10 commented 2026-11-18 19:37:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T19:37:15Z.

Review: APPROVED


Reviewed — looks good

The prepared evidence supports the socket status flag change; I reviewed all seven changed files at head 3a5a64a869b91fe4de6cd3cbc54b6ea2bb79e96f, while checks were reported by the author and were not run in this review.

What I ran

No commands were run. I read the prepared description, commit summary, manifest and diff, and inspected changed code and relevant callers through repo_read.py at the pinned head. The author reports Linux focused tests, a full ctest run on an earlier branch revision, and convention checks; these are author-reported, not runs performed here.

Results

Check Result Note
Source review passed Seven changed files read
Tests and prechecks not run Results in the description are author-reported
Windows, macOS, console not run No platform or title verification here

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run tests, build the change, or verify behavior on Windows, macOS, or console hardware. The prepared bundle excluded no changed files; all seven files listed in the manifest were read. Targeted context read included DescriptorControl.cpp and Socket.cpp.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5963719670 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22573#pullrequestreview-5963719670). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T19:37:15Z. **Review:** APPROVED --- # Reviewed — looks good The prepared evidence supports the socket status flag change; I reviewed all seven changed files at head `3a5a64a869b91fe4de6cd3cbc54b6ea2bb79e96f`, while checks were reported by the author and were not run in this review. ## What I ran No commands were run. I read the prepared description, commit summary, manifest and diff, and inspected changed code and relevant callers through `repo_read.py` at the pinned head. The author reports Linux focused tests, a full `ctest` run on an earlier branch revision, and convention checks; these are author-reported, not runs performed here. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Seven changed files read | | Tests and prechecks | not run | Results in the description are author-reported | | Windows, macOS, console | not run | No platform or title verification here | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run tests, build the change, or verify behavior on Windows, macOS, or console hardware. The prepared bundle excluded no changed files; all seven files listed in the manifest were read. Targeted context read included `DescriptorControl.cpp` and `Socket.cpp`. ## 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!22573
No description provided.