fix(libkernel): report socket status from fstat on a guest socket #4903

Merged
ErenYeager1836 merged 1 commit from upstream-pr/4903 into main 2026-10-14 04:26:24 +00:00
ErenYeager1836 commented 2026-10-13 03:14:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-13T03:14:20Z.


Carries milescoviello:fix/fstat-guest-socket@505bc9b9 unchanged (rebased onto current main and debt conflict resolved). Fixes #4051.

What

fstat on a guest socket descriptor passed the guest number (from 0x10000000 up) to the host, which has no such descriptor, so it threw FillFileStat: fstat failed for fd 268435460; sceKernelFstat returned EBADF for the same descriptor. FreeBSD fills the stat buffer for a socket through soo_stat (sys/kern/sys_socket.c), which reports S_IFSOCK, read/write mode bits from send/recv state, and st_size = sbavail - sb_ctl. fstat/sceKernelFstat now answer that way for guest sockets instead of throwing.

Tested

  • From the original issue & carry: Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags: guest_socket_pair aborts with main's sources (the FillFileStat throw) and passes with the change; all guest_* tests pass (289/289).
  • Windows 11: python tools/check_conventions.py --base upstream/main passes with 0 errors. python tools/check_test_registration.py passes (707 test executables).

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 in TechnicalDebt
  • 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: #4796, #4929, #4933
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4837819278 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4903). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-13T03:14:20Z. --- Carries `milescoviello:fix/fstat-guest-socket@505bc9b9` unchanged (rebased onto current main and debt conflict resolved). Fixes #4051. ### What `fstat` on a guest socket descriptor passed the guest number (from `0x10000000` up) to the host, which has no such descriptor, so it threw `FillFileStat: fstat failed for fd 268435460`; `sceKernelFstat` returned `EBADF` for the same descriptor. FreeBSD fills the stat buffer for a socket through `soo_stat` (`sys/kern/sys_socket.c`), which reports `S_IFSOCK`, read/write mode bits from send/recv state, and `st_size = sbavail - sb_ctl`. `fstat`/`sceKernelFstat` now answer that way for guest sockets instead of throwing. ### Tested - From the original issue & carry: Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags: `guest_socket_pair` aborts with `main`'s sources (the `FillFileStat` throw) and passes with the change; all `guest_*` tests pass (289/289). - Windows 11: `python tools/check_conventions.py --base upstream/main` passes with 0 errors. `python tools/check_test_registration.py` passes (707 test executables). ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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: #4796, #4929, #4933 - [x] Unblocks: none - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 06:42:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T06:42:53Z.


Windows test: head 618bcf323 merged onto current main ea2bbefb2 (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest with the filter guest_socket_pair: guest_socket_pair passed (1 test(s), 0 failed); python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6139896460 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4903#issuecomment-6139896460). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T06:42:53Z. --- Windows test: head `618bcf323` merged onto current `main` `ea2bbefb2` (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest with the filter `guest_socket_pair`: guest_socket_pair passed (1 test(s), 0 failed); `python tools/check_conventions.py --base upstream/main` passed. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
nicolasfalesy commented 2026-10-13 07:24:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T07:24:53Z.


Linux test (Arch, GCC 16.2.1, glibc, Release), this PR merged onto main 7e181fcc3 together with #4927, #4903, #4877, #4822 and #4823 (no conflicts): guest_socket_pair passes. With this PR's source change reverted (test kept), guest_socket_pair fails on Linux, so the check guards the change on Linux too.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140512479 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4903#issuecomment-6140512479). Originally posted by [nicolasfalesy](https://github.com/nicolasfalesy) on 2026-10-13T07:24:53Z. --- Linux test (Arch, GCC 16.2.1, glibc, Release), this PR merged onto `main` 7e181fcc3 together with #4927, #4903, #4877, #4822 and #4823 (no conflicts): `guest_socket_pair` passes. With this PR's source change reverted (test kept), `guest_socket_pair` fails on Linux, so the check guards the change on Linux too.
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!4903
No description provided.