Commit Graph
378 Commits
Author SHA1 Message Date
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
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
Adrià e01d909086 Merge pull request #6915 from Nixitov/feat/physhm
feat(libkernel): declare physhm_open and physhm_unlink
2026-10-19 15:18:41 +02:00
Alexej Szpevák cb9a4c7417 feat(libkernel): support EV_CLEAR on sockets and pipes in kevent on Linux
kevent threw for EV_CLEAR on a socket or the read end of a pipe; Boost.Asio's kqueue reactor, among others, registers every socket that way. On Linux such a knote now watches its host descriptor through an edge watch. It is armed when added, on every later EV_ADD or EV_ENABLE while enabled, and by each host wakeup; when armed it is checked with the level-triggered readiness test and reported with the current data and EV_EOF, or disarmed if no longer ready, as kqueue_scan re-runs the filter; reporting it disarms it until the next edge. Waits block on the watch's epoll descriptor, so a socket that stays readable does not wake them. Windows and macOS still throw. GuestSockets::NativeDescriptor exposes the host socket behind a guest one for the watch.
2026-10-19 15:05:28 +02:00
valenciana-nc f7fd9dbf9f fix(libkernel): check recvmsg guest copies on macOS 2026-10-19 06:33:13 -06:00
valenciana-nc 7ef31e91cf fix(libkernel): check only the guest bytes recvmsg reads and writes 2026-10-19 06:33:13 -06:00
Dean 8982791bc3 Merge pull request #7654 from ionut27001/fix/libkernel-sysarch-i386-bases
fix(libkernel): answer sysarch I386_GET_FSBASE, I386_GET_GSBASE and undefined operations as measured on a PS5
2026-10-20 01:22:09 +13:00
Adrià ebf1a90270 Merge pull request #6825 from hugodearaujo/fix/report-implied-read-protection
fix(libkernel): report the read bit of every write bit in a mapping's protection
2026-10-19 14:04:45 +02:00
ionut27001andClaude Opus 5.5 dca67ae477 fix(libkernel): return kern.rng_pseudo in 64-byte blocks as measured on a PS5
In a payload process on a PS5 (firmware 12.70),
sysctlbyname("kern.rng_pseudo") answers a size query with 64 and gives
at most 64 bytes per call, up to a 65536-byte buffer. A buffer smaller
than 64 bytes gets as many bytes as its length and a null length gets
none, both with -1 and ENOMEM; a null buffer with a null length returns
0, and errno is kept when the call succeeds. Here the whole buffer was
filled, a size query threw and the length was never changed. The 64
random bytes are now drawn only for a read that passes both a buffer
and a length.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 14:49:39 +03:00
Adrià 62e946f114 Merge pull request #6833 from ErenYeager1836/feat/libkernel-sysconf-limits
feat(libkernel): support _SC_ARG_MAX, _SC_OPEN_MAX and _SC_IOV_MAX in sysconf
2026-10-19 13:37:44 +02:00