soreceive_generic returns 0 for a socket whose receive side is shut and for a
zero-length receive on a connected stream socket (ENOTCONN when it is not
connected), without waiting. Winsock fails the first with WSAESHUTDOWN, which
reached the guest as EPIPE, and blocks the second until data arrives. recv and
recvfrom now answer both themselves.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
On Linux sceKernelGetdirentries copied the host d_type, so a directory under app0 that is a host symlink was listed as a link, and a title that only descends into directory entries skipped it. Inside the app0 tree, report a symlink (or an entry of unknown type) as the type of its target; links elsewhere, and dangling links, stay links.
Two unwind queries a title makes went wrong on macOS, so a C++ exception the title would catch ended the process instead: God of War Sons of Sparta (PPSA28997) stops on an IL2CPP exception it normally handles.
- sceKernelGetModuleInfoForUnwind found a relinked image and its PT_GNU_EH_FRAME header but left eh_frame_addr and eh_frame_size at zero, so the title's unwinder found no FDE for its own frame. The tables are now read with EhFrame::ReadTables over the image's load segments, as ModuleInfo does on Linux, and eh_frame_size includes the zero terminator, as on Linux.
- sceSysmoduleGetModuleInfoForUnwind read /proc/self/maps outside Windows and threw on every call on macOS. It now answers from mach_vm_region, with the image path from dladdr, as the Linux branch answers from the mapping.
guest_unwind_module_info now runs on macOS: the test executable carries the __APS5DATA,__meta program headers that the macOS dl_iterate_phdr reads from a relinked image. guest_sysmodule checks the macOS answers against mach_vm_region.
Co-authored-by: mugurc <[email protected]>
Both were missing from libkernel.prx, so a title importing either
(dYv-+If2GPk, RRnSj8h8VR4) failed to load. They take a relative timeout
in microseconds and are scePthreadRwlockTimedrdlock and
scePthreadRwlockTimedwrlock with POSIX error numbers; a zero lock is
initialized as by pthread_rwlock_rdlock. The signature comes from
shadPS4, which registers one function for each NID and its
scePthreadRwlockTimed* twin; FreeBSD 11.4 has no such calls. The throwing
libkernel_sys copies are removed, as an export may live in one library
only. Recorded in the libkernel debt file.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Follow FreeBSD 11.4 sys_setresuid and sys_setresgid (sys/kern/kern_prot.c):
accept real, effective, and saved user and group IDs for the guest process,
which is assumed to run as root with IDs 0. Setting an ID to 0 or -1 (unchanged)
is accepted without changing credentials and returns 0; any other value throws.
Cover both in guest_credentials test and update libkernel debt documentation.
The PS5 libkernel exports _accept, _bind, _connect, _getdirentries,
_getpeername, _getsockname, _getsockopt, _listen, _recvfrom, _recvmsg,
_sendmsg, _sendto, _setsockopt, _sigaction and _sigsuspend (PS5 3.20
export list, DNNDHH/PS5-3.20_Libs b2a77c0 libkernel.c), and main
exports none of them, so a title importing one fails at startup. Each
now forwards to the export without the underscore, as _close, _ioctl
and _nanosleep already do.
In FreeBSD 11.4 (8c639945a4) these are libc's plain system call
entries: lib/libc/amd64/SYS.h makes bind, getdirentries, getpeername,
getsockname, getsockopt, listen and setsockopt one stub under both
names, and lib/libc/sys/Makefile.inc gives accept, connect, recvfrom,
recvmsg, sendmsg, sendto, sigaction and sigsuspend a separate public
name that goes through libthr's interposing table, which adds the
cancellation points and the sigaction wrapper. The exports without the
underscore have no libthr layer here, so forwarding gives the system
call. docs/dev/debt/libkernel.md records what stays unverified: the
console is not measured, _sigaction shares the handler table of
sigaction, and a null set throws in _sigsuspend as in sigsuspend,
where FreeBSD's system call returns EFAULT.
guest_underscore_entries calls every new export: a loopback TCP
connection, UDP datagrams with scatter, truncation and sender
addresses, a directory listing compared with getdirentries, a SIGTERM
handler set by _sigaction, and a pending SIGUSR1 that _sigsuspend
delivers before returning EINTR with the mask restored. It checks the
errors they pass on (EBADF, EINVAL, EFAULT, ENOPROTOOPT, EOPNOTSUPP)
and that outputs stay untouched on failure.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Measured on firmware 13.60: a start whose rounding to 16 KiB overflows
finds nothing, and of two equal free ranges the lowest is returned.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Measured on firmware 13.60: an alignment that is not zero or a power of
two returns EINVAL before anything else; bounds with nothing between
them return ENOMEM, a negative start searches from the bottom, only the
start is rounded up to 16 KiB and the end is used as given; null outputs
are skipped; errors leave both outputs untouched.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Measured on firmware 13.60: attribute 0x100 makes a flag openable by
name, and only such flags can be opened. Each open returns a new handle
on the same flag, which sceKernelCloseEventFlag releases. Closing a
creator handle and deleting through an opened one return EPERM. Two live
shared flags cannot share a name, names of 32 or more bytes return
ENAMETOOLONG, and a missing name returns ESRCH. After the creator
deletes the flag, an opened handle polls and waits with EACCES and sets,
clears and cancels with no effect.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Measured on firmware 13.60: create accepts attribute bits 0x1, 0x2, 0x10,
0x20 and 0x100 and rejects 0x1|0x2; wait and poll ignore mode bits outside
the match and clear fields; EPERM, ECANCELED and EACCES write 0 to the
result pattern.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
On Windows a pair end now reports POLLIN after the peer's shutdown or close.
The console also reports POLLHUP after close; the loopback connection cannot
tell a close from a shutdown.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
FreeBSD 11 kqueue_scan (sys/kern/kern_event.c) re-inserts a reported
knote without EV_CLEAR or EV_DISPATCH at the tail of kq_head, and
knote_enqueue puts a knote that fires again at the tail as well, so the
next scan starts with the events that were not reported yet.
sceKernelWaitEqueue scanned the event list in place, so with num smaller
than the number of ready events the first ones were reported on every
call and the later ones starved. Each reported event that stays
registered now moves to the end of the list, in the order reported.
FreeBSD 11's kern_sigaction (sys/kern/kern_sig.c) calls
sigqueue_delete_proc, which drops the signal from the process queue and
from every thread's queue, whenever the new handler is SIG_IGN, or
SIG_DFL on a signal whose sigprop has SA_IGNORE (SIGURG, SIGCONT,
SIGCHLD, SIGIO, SIGWINCH, SIGINFO). It does so whether or not the
signal is blocked. sigaction and signal now take the signal off the
pending set in those cases, so a later unblock or wait never sees it.
FreeBSD 11.4 getsockaddr sets sa_len to the length argument, and
tcp_usr_bind, tcp_usr_connect, in_pcbbind_setup, in_pcbconnect_setup,
in6_pcbbind and in6_pcbladdr answer EINVAL when it is not the size of
the socket family's address. udp6_bind and udp6_connect pass an
IPv4-mapped address to the IPv4 code without that check when
IPV6_V6ONLY is clear, and udp6_send always checks it. bind and connect
on AF_INET and AF_INET6 sockets, and sendto on AF_INET6 datagram
sockets, now fail a longer address with EINVAL.
WSAPoll reports POLLHUP alone for a stream socket whose peer has closed, so
poll never returned POLLIN for it and a caller waiting for POLLIN did not see
the end of the stream. sopoll_generic reports a socket that can receive no
more as readable and adds POLLHUP only once it can send no more either.
poll now adds the requested read bit and keeps POLLHUP only after the socket
shut its own sending side. A reset or refused connection keeps WSAPoll's flags.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
FreeBSD 11 sendfile checks the file descriptor first, then looks up the
socket with getsock_cap, which answers ENOTSOCK for an open descriptor
that is not a socket and EBADF for one that is not open
(sys/kern/kern_sendfile.c, sys/kern/uipc_syscalls.c).
sendfile replaced the errno that Lookup had already set with EBADF. It
now reports the errno Lookup chose, so an open non-socket gives ENOTSOCK
and a closed descriptor still gives EBADF. The sentence about this gap
is cut from the sendfile debt entry and guest_sendfile covers both cases.
Both threw for a regular file. They now follow FreeBSD 11.4's
filt_vfsread and filt_vfswrite: a read event reports the file size less
the descriptor's offset and fires while that is not 0; a write event
always fires with data 0. A wait holding such an event polls it again
every millisecond, as no host call reports every file change. A size
above 1 and other vnode types still throw.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
FreeBSD 11.4's sys_flock only requires a vnode descriptor, so flock on a directory descriptor succeeds. On Windows the call reached LockFileEx, which rejects a directory handle with ERROR_INVALID_PARAMETER, and flock_nid_postfix turned that into a runtime_error that aborted the process. A directory descriptor now returns 0 without taking a lock; the new guest_file_lock_directory case covers it and the debt entry records that no lock is held.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The call threw for lack of a signature. In the PS5 12.00 libkernel it takes
one int, passes it to syscall 601 (command 29) and returns the raw kernel
result. No dump is produced here, so it returns 0, as
sceCoredumpConfigDumpMode does.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
Follow FreeBSD 11.4 sys_getresuid and sys_getresgid (sys/kern/kern_prot.c):
retrieve real, effective, and saved user and group IDs for the guest process,
which is assumed to run as root with IDs 0. Pointers that are not null receive 0,
null pointers are ignored, and 0 is returned leaving errno unchanged on success.
Cover both in guest_credentials test and update libkernel debt documentation.