Commit Graph
386 Commits
Author SHA1 Message Date
Ondra97 07486d7cfa fix(libkernel): report current thread scheduling policy in attributes 2026-10-20 19:05:08 +02:00
Adrià 10e2cbf648 Merge pull request #7541 from ionut27001/fix/libkernel-sysctl-absent-names
fix(libkernel): return ENOENT for thirteen sysctl names, as measured on a PS5
2026-10-20 18:13:19 +02:00
Adrià 4036fab1b2 Merge pull request #7437 from lucaslima430/fix/libkernel-socket-fcntl-duplication
fix(libkernel): support socket fcntl duplication
2026-10-20 17:40:06 +02:00
Adrià 1e1a19bf48 Merge pull request #7075 from AlexOfTheForest/feat/kevent-pipe-write
feat(libkernel): support EVFILT_WRITE on the write end of a pipe
2026-10-20 17:15:03 +02:00
Dean 44e3389c88 Merge pull request #7807 from mazen320/fix/windows-stderr-dup2
fix(libkernel): keep host stderr off a guest dup2 onto descriptor 2
2026-10-21 01:45:30 +13:00
ionut27001andClaude Opus 5.5 dfa96f1fe6 fix(libkernel): return ENOENT for thirteen sysctl names, as measured on a PS5
In a payload process on a PS5 (firmware 12.70), sysctlbyname returns -1
with ENOENT for thirteen names that threw here, and leaves the buffer and
the length alone, for a read, a size query, a null length and a null
buffer with a null length. sysctl does the same for the fixed MIBs of
seven of them. sysctlnametomib gives those seven MIBs and returns ENOENT
for hw.cacheline_size and hw.usermem, which threw too.

machdep.cacheline_size already returned ENOENT and is now tested with
the others. A write to the new names and MIBs throws, as the console's
answer to a write was not tried. The hw.realmem and vm.overcommit debt
entries now say that a payload process gets ENOENT for them as well.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 13:46:29 +02:00
Queuze bbcce1736e fix(libkernel): support socket fcntl duplication 2026-10-20 13:40:22 +02:00
Adrià FranchandClaude Sonnet 5.5 99e56464a1 fix(libkernel): keep the PipeWrite full-pipe case off Windows and start its clock before the reader
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 13:35:07 +02:00
Alexej Szpevák bd8ee518c4 feat(libkernel): support EVFILT_WRITE on the write end of a pipe
kevent threw for EVFILT_WRITE on any descriptor that is not a socket. On the write end of a pipe it now follows FreeBSD 11's filt_pipewrite: data is the free buffer space, and once the read end is closed the event reports EV_EOF with data 0. Adding the event after the read end is closed fails with EPIPE, as in pipe_kqfilter. EVFILT_WRITE on the read end still throws, because FreeBSD's pipe ends are bidirectional and host pipes are not.
2026-10-20 13:34:50 +02:00
Adrià b9a097353c Merge pull request #7556 from MarcZX10/codex/libkernel-sysctl-mib-enoent
fix(libkernel): return ENOENT for measured absent sysctl MIBs
2026-10-20 13:23:08 +02:00
Adrià 437de6392f Merge pull request #7652 from billythemenace2/fix/kernel-raise-outside-host-code
fix(libkernel): redirect a raise only once the target leaves host code
2026-10-20 13:16:49 +02:00
MarcZX100 7b05271abb fix(libkernel): support kern.rng_pseudo MIB access 2026-10-20 12:29:39 +02:00
Adrià 9299e6fd8a Merge pull request #7542 from ionut27001/fix/libkernel-rng-pseudo-block
fix(libkernel): return kern.rng_pseudo in 64-byte blocks as measured on a PS5
2026-10-20 12:24:51 +02:00
Adrià a0e0985288 Merge pull request #7551 from mazen320/fix/open-nofollow-junction
fix(libkernel): stop O_NOFOLLOW from opening a Windows directory junction
2026-10-20 12:20:01 +02:00
MarcZX10 e054c83eea Merge upstream main into measured absent sysctl MIBs 2026-10-20 10:12:56 +00:00
mazen c03168fb47 fix(libc): keep guest stdio on a dup2 of descriptors 1 and 2
Host logging opens its own FILE on the saved descriptor. The guest FILE stays on the replaced descriptor, so guest printf, puts and fprintf still reach the pipe.
2026-10-20 13:38:07 +04:00
mazen 715fe9ca26 fix(libkernel): keep host stdout off a guest dup2 onto descriptor 1
The same guest dup2 that fills the stderr pipe also replaces descriptor 1, so host stdout was still writing into the guest pipe.
2026-10-20 13:38:07 +04:00
mazen 2d1c18410f fix(libkernel): keep host stderr off a guest dup2 onto descriptor 2
Guest dup2 onto 2 replaces the CRT descriptor fprintf(stderr) still uses, so host logs fill the 4 KiB guest pipe.
2026-10-20 13:38:06 +04:00
SebastianandClaude Opus 5.5 cfdaf2dbb8 feat(libkernel): implement fchflags
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QnkpF2oEMofseVz9Z7WEAC
2026-10-20 07:28:54 +00:00
Dean bec309f4d4 Merge pull request #8057 from HQasper/feat/kernel-pipe-read-event
feat(libkernel): accept pipe read ends in sceKernelAddReadEvent
2026-10-20 18:31:06 +13:00
Dean 1ae9833228 Merge pull request #8035 from pushkarreddyy/feat/libkernel-pthread-mutexattr-getprotocol
feat(libkernel): implement pthread_mutexattr_getprotocol
2026-10-20 17:55:35 +13:00
Dean 564c75b289 Merge pull request #7956 from Lindamea1/fix/libkernel-ioctl-malformed-enotty
fix(libkernel): fail a malformed ioctl request with ENOTTY
2026-10-20 17:49:59 +13:00
Dean 2a04b63d1e Merge pull request #8176 from xXPBSXx/fix/ftruncate-no-zero-fill-fb
fix(libkernel): extend a file with ftruncate without writing zero bytes on Windows
2026-10-20 17:47:32 +13:00
Dean 49fd13a741 Merge pull request #7958 from Lindamea1/fix/libkernel-available-direct-memory-enomem
fix(libkernel): return ENOMEM from sceKernelAvailableDirectMemorySize when the range has no free block
2026-10-20 17:40:24 +13:00
Dean 56a0be39dd Merge pull request #7957 from Lindamea1/fix/libkernel-attrget-esrch-ended-thread
fix(libkernel): return ESRCH from scePthreadAttrGet for a thread that has ended
2026-10-20 17:40:20 +13:00
Dean cb3f18fda8 Merge pull request #7940 from pushkarreddyy/feat/libkernel-setgid
feat(libkernel): implement setgid
2026-10-20 17:05:47 +13:00
xXPBSXxandClaude Sonnet 5.5 bcbcf55b5b fix(libkernel): extend a file with ftruncate without writing zero bytes on Windows
ftruncate, truncate and sceKernelFtruncate extended a file through _chsize_s,
which writes the whole new length as zero bytes. FreeBSD extends the file
without writing data (kern_ftruncate -> ffs_truncate) and fails a length the
file system cannot hold with EFBIG. NativeFtruncate now sets the end of file
with SetFileInformationByHandle and maps ERROR_DISK_FULL to ENOSPC and
ERROR_FILE_TOO_LARGE/ERROR_INVALID_PARAMETER to EFBIG.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 05:58:22 +02:00
Dean 4405703fa6 Merge pull request #8186 from xXPBSXx/fix/socket-dontwait-windows-fb
fix(libkernel): honour MSG_DONTWAIT in the socket send and receive calls on Windows
2026-10-20 16:22:35 +13:00
xXPBSXxandClaude Sonnet 5.5 45940f27cc fix(libkernel): honour MSG_DONTWAIT in the socket send and receive calls on Windows
send, sendto, sendmsg, recv, recvfrom and recvmsg failed with EOPNOTSUPP for
MSG_DONTWAIT on Windows, where FreeBSD 11.4 sosend_generic and
soreceive_generic make the one call non-blocking and fail with EWOULDBLOCK
when it would wait. Winsock has no per-call flag, so the call now asks WSAPoll
with a zero timeout whether the socket is ready and fails with EAGAIN when it
is not. The Windows branches of the socket tests that expected EOPNOTSUPP now
run the same checks as the other hosts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 03:43:59 +02:00
xXPBSXxandClaude Sonnet 5.5 cd09badb2b fix(libkernel): fail a short or long socket address like FreeBSD
bind, connect and sendto answered EFAULT for an address length below 2 and EAFNOSUPPORT for an AF_INET address below 16 or an AF_INET6 address below 28 bytes. FreeBSD 11.4's getsockaddr fails a length below 2 with EINVAL and above SOCK_MAXADDRLEN (255) with ENAMETOOLONG, and the protocols compare the length with sizeof(struct sockaddr_in) or sockaddr_in6 and fail with EINVAL.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 02:30:55 +02:00
Adrià 5253446882 Merge pull request #7543 from ionut27001/fix/libkernel-getrlimit-console
fix(libkernel): report the getrlimit values measured on a PS5 for RLIMIT_STACK, RSS, MEMLOCK and NPROC
2026-10-20 02:07:39 +02:00
Adrià 88fb5592c6 Merge pull request #7611 from Lindamea1/fix/kernel-pthread-attr-sched-getters
feat(libkernel): implement scePthreadAttrGetschedpolicy and scePthreadAttrGetinheritsched
2026-10-20 01:23:13 +02:00
Adrià 309ab11eaf Merge pull request #7539 from ionut27001/fix/libkernel-inet-ntop-pad
fix(libkernel): match inet_ntop and inet_pton padding and null pointers as measured on a PS5
2026-10-20 00:51:02 +02:00
Claude 25434db37d docs(libkernel): mark pipe read events as the exception to sockets-only
The entry before it still says sceKernelAddReadEvent and
sceKernelAddWriteEvent take only guest sockets. The pipe entry now says it
is the exception, without editing that entry, which an open change to the
shared-memory entry next to it would conflict with.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 21:41:26 +00:00
Dean 6b981a212c Merge pull request #7675 from valenciana-nc/fix/recvmsg-guest-validation
fix(libkernel): fail recvmsg with EFAULT on guest memory it cannot read or write
2026-10-20 09:21:54 +13:00
Adrià 67e5c8a48f Merge pull request #7403 from milescoviello/fix/fcntl-host-socket
fix(libkernel): handle fcntl and FIONREAD on a host socket descriptor
2026-10-19 21:30:50 +02:00
Claude 5c6f6da7dc feat(libkernel): accept pipe read ends in sceKernelAddReadEvent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 18:30:55 +00:00
pushkarreddyy 4ea1c112bb feat(libkernel): implement pthread_mutexattr_getprotocol 2026-10-19 23:48:09 +05:30
Adrià 38de0a470b Merge pull request #7129 from AlexOfTheForest/feat/kevent-ev-clear
feat(libkernel): support EV_CLEAR on sockets and pipes in kevent on Linux
2026-10-19 19:56:35 +02:00
Adrià a77e40f93f Merge pull request #7070 from milescoviello/feat/kern-proc-vmmap
feat(libkernel): report the guest address-space map through kern.proc.vmmap
2026-10-19 19:36:11 +02:00
Dean c66a207ddd Merge pull request #7842 from ionut27001/fix/libkernel-umtx-op1-eopnotsupp
fix(libkernel): fail _umtx_op operation 1 with EOPNOTSUPP as measured on a PS5
2026-10-20 05:53:50 +13:00
billythemenace2andClaude Opus 5.5 d2657b9750 fix(libkernel): classify the raise target's code without loader calls while it is suspended
GetModuleHandleExW and GetModuleFileNameW take loader locks the suspended
target may hold. While the target is suspended only VirtualQuery and a
lock-free cache of image bases are consulted; an image not yet cached is
classified after the target is resumed, and the target is sampled again.
The statics the checks use are initialized before the first suspend. The
host-code wait is recorded in the libkernel debt file, and the test raises
100 times so it fails on every run without the change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 17:22:50 +01:00
ionut27001andClaude Opus 5.5 ad9772edd1 fix(libkernel): report the getrlimit values measured on a PS5 for RLIMIT_STACK, RSS, MEMLOCK and NPROC
In a payload process on a PS5 (firmware 12.70), getrlimit returns
0x200000 for RLIMIT_STACK, infinity for RLIMIT_RSS and RLIMIT_MEMLOCK,
and 1604 for RLIMIT_NPROC, each as both soft and hard limit. These four
threw here. Whether a title process reads the same limits is not
measured.

setrlimit reads getrlimit first, so it now accepts RLIMIT_STACK,
RLIMIT_RSS and RLIMIT_MEMLOCK when the values do not change, as the
payload process does. RLIMIT_NPROC throws: in the payload process
setting it to its current value succeeds, but getrlimit then reads 1443,
and the limit is not stored here. Any other change still throws. The
getrlimit and setrlimit debt entries also record the payload process's
RLIMIT_DATA and RLIMIT_NOFILE readings, its 12555 clamp of RLIMIT_NOFILE
and its RLIMIT_NPROC reading after a same-value set.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 18:21:34 +02:00
Lindamea1andClaude Opus 5.5 5fafbef246 test(libkernel): check the Linux TIOCGWINSZ word and the ioctl request boundaries
The OpenOrbis net_http sample stops on 0x5413, the Linux TIOCGWINSZ
that musl sends to standard output; the carried cases covered 0x5401
but not that word, so the test adds it to the malformed words. It also
pins the two boundary words the check takes as well-formed, 0x20046601
(IOC_VOID, length 4) and 0x80006601 (IOC_IN, length 0): on a guest
socket with a null argument they fail with EFAULT, not ENOTTY.

The debt sentence now states the open gap: an input request with
length 0 is not rejected as malformed, while sys_ioctl rejects it in a
kernel built without COMPAT_FREEBSD4, COMPAT_FREEBSD5 and COMPAT_43,
and which of these the PS5 kernel has is unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:25:42 +01:00
Hussein Kadhim baa6d4aeee fix(libkernel): fail a malformed ioctl request with ENOTTY before the descriptor is looked at
FreeBSD's sys_ioctl rejects a request with no direction bit, an output request with no length, or a void request whose length is not an int before it reads the argument or resolves the descriptor. ioctl threw on such a request for a file, pipe or directory, failed with EBADF for a closed descriptor and with EFAULT for a socket given no argument.

(cherry picked from commit 501518f321ac5d0b45ce1090af39c680927edf49)
(cherry picked from commit 3eb7edd9cf)
2026-10-19 16:25:42 +01:00
Lindamea1andClaude Opus 5.5 3237083172 fix(libkernel): return ESRCH from scePthreadAttrGet for a thread that has ended
scePthreadAttrGet copied the attributes of any non-null handle, so a
thread that was joined or had finished still answered 0, and a thread
that ended detached was read after its object had been freed. FreeBSD
11.4's _pthread_attr_get_np returns ESRCH for a dead or reclaimed thread,
and Monster Hunter Wilds (PPSA24191) reuses a slot of its thread table
only when scePthreadAttrGet returns 0x80020003.

After the EINVAL checks it now returns ESRCH unless the handle is a live
guest thread, and copies the fields while holding the thread registry
lock (LockLiveGuestThread), so a detached thread exiting during the call
is not freed under the copy. GuestThreadIsLive uses the same lookup.
pthread_attr_get_np, which the title does not import, is left as it is;
the debt entry records the difference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:25:14 +01:00
Lindamea1andClaude Opus 5.5 179316c452 fix(libkernel): return ENOMEM from sceKernelAvailableDirectMemorySize when the range has no free block
A search range with no free direct memory returned EAGAIN (0x80020023).
A PS5 returns ENOMEM (0x8002000c) for an occupied range, as the
PS5_RetroArch author's console capture records, and PS5_PayloadSDK's
ps5_memory_query, which RetroArch uses for its memory status, gives up
on any other error.

LargestFree now returns the error: ENOMEM when no block is found, and
EAGAIN as before for a negative start, an end at or below the start and
an alignment that overflows when rounded to a page. guest_memory expects
ENOMEM for an occupied range and EAGAIN for those arguments. The
unmeasured argument handling is recorded in the libkernel debt file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:24:55 +01:00
pushkarreddyy a1b6caaf0a feat(libkernel): implement setgid 2026-10-19 20:41:52 +05:30
Adrià 863486cc32 Merge pull request #6836 from DavidSamir/fix/libkernel-open-file-limit-macos
fix(libkernel): set the open file limit at load on macOS
2026-10-19 16:38:18 +02:00
Adrià f4366753aa Merge pull request #6908 from Zinebyte/fix/posix-sleep-cancellation
fix(libkernel): wake POSIX sleep for thread cancellation
2026-10-19 15:39:43 +02:00