Repository navigation
fix(libkernel): report socket status from fstat on a guest socket - #4903
Merged
oneandonlydean merged 1 commit intoOct 14, 2026
Merged
Conversation
This was referenced Oct 13, 2026
10 tasks done
Contributor
|
Windows test: head AI-assisted (Claude Code). |
Contributor
|
Linux test (Arch, GCC 16.2.1, glibc, Release), this PR merged onto |
This was referenced Oct 13, 2026
ErenYeager1836
force-pushed
the
carry/fstat-guest-socket
branch
from
October 13, 2026 07:44
618bcf3 to
2cd842e
Compare
ErenYeager1836
force-pushed
the
carry/fstat-guest-socket
branch
from
October 13, 2026 12:12
2cd842e to
2cbec36
Compare
This was referenced Oct 13, 2026
This was referenced Oct 13, 2026
This was referenced Oct 14, 2026
fstat on a guest socket descriptor passed the guest number to the host,
which has no such descriptor, and threw ("FillFileStat: fstat failed for
fd 268435460"); sceKernelFstat returned EBADF. FreeBSD fills the stat
buffer for a socket through soo_stat (sys/kern/sys_socket.c):
bzero((caddr_t)ub, sizeof (*ub));
ub->st_mode = S_IFSOCK;
...
if ((sb->sb_state & SBS_CANTRCVMORE) == 0 || sbavail(sb))
ub->st_mode |= S_IRUSR | S_IRGRP | S_IROTH;
ub->st_size = sbavail(sb) - sb->sb_ctl;
...
if ((sb->sb_state & SBS_CANTSENDMORE) == 0)
ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
and pru_sense_null (sys/kern/uipc_socket.c) adds
st_blksize = so->so_snd.sb_hiwat.
fstat and sceKernelFstat now answer a guest socket from the socket
table: S_IFSOCK, the read bits until the receive side is shut down and
drained, the write bits until the send side is shut down, st_size from
the bytes queued and st_blksize from the send buffer size, other fields
zero. shutdown records which side it closed. A closed socket descriptor
returns EBADF. The differences from the console (peer shutdown, the
host's FIONREAD and SO_SNDBUF, socketpair identity) are listed in
TechnicalDebt.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ErenYeager1836
force-pushed
the
carry/fstat-guest-socket
branch
from
October 14, 2026 03:05
2cbec36 to
472437a
Compare
11 tasks done
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carries
milescoviello:fix/fstat-guest-socket@505bc9b9unchanged (rebased onto current main and debt conflict resolved). Fixes #4051.What
fstaton a guest socket descriptor passed the guest number (from0x10000000up) to the host, which has no such descriptor, so it threwFillFileStat: fstat failed for fd 268435460;sceKernelFstatreturnedEBADFfor the same descriptor. FreeBSD fills the stat buffer for a socket throughsoo_stat(sys/kern/sys_socket.c), which reportsS_IFSOCK, read/write mode bits from send/recv state, andst_size = sbavail - sb_ctl.fstat/sceKernelFstatnow answer that way for guest sockets instead of throwing.Tested
guest_socket_pairaborts withmain's sources (theFillFileStatthrow) and passes with the change; allguest_*tests pass (289/289).python tools/check_conventions.py --base upstream/mainpasses with 0 errors.python tools/check_test_registration.pypasses (707 test executables).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)