Commit Graph
1310 Commits
Author SHA1 Message Date
Dean d167c0c362 Merge pull request #7141 from Bonjourcestmatt/fix/clock-gettime-efault
fix(libkernel): return EFAULT from clock_gettime for a null result pointer
2026-10-18 09:45:59 +13:00
Dean 084bd39a08 Merge pull request #7133 from pushkarreddyy/fix/libkernel-write-throttling-null-efault
fix(libkernel): return EFAULT from sceKernelWriteThrottlingStatus for a null status
2026-10-18 09:45:24 +13:00
Dean 64df590f4c Merge pull request #7076 from AlexOfTheForest/fix/socket-write-space
fix(libkernel): report free send space for socket write events on Linux
2026-10-18 09:44:37 +13:00
Dean b95768d1b0 Merge pull request #6540 from JJenkx/fix/kernel-cpuset-thread-id
feat(libkernel): support cpuset affinity by guest thread ID
2026-10-18 09:43:55 +13:00
Dean e0045fb6ef Merge pull request #6518 from qpavyros/codex/mutexattr-invalid-attributes
fix(libkernel): return EINVAL for invalid mutex priority attributes
2026-10-18 09:41:01 +13:00
Dean b5e570d06a Merge pull request #7092 from milescoviello/fix/kevent-note-lowat
fix(libkernel): take NOTE_LOWAT on socket read and write events
2026-10-18 09:40:43 +13:00
Dean ee14990418 Merge pull request #7073 from AlexOfTheForest/fix/getlk-unlock
fix(libkernel): answer F_GETLK with F_UNLCK on Linux and macOS
2026-10-18 09:39:47 +13:00
Dean 13d07428a1 Merge pull request #7035 from milescoviello/fix/timed-locks-null-deadline
fix(libkernel): treat a null deadline as an untimed lock in the timed pthread locks
2026-10-18 04:48:21 +13:00
Dean e0d1f1b2f8 Merge pull request #7114 from pushkarreddyy/fix/libkernel-rename-null-efault
fix(libkernel): return EFAULT from truncate, utimes, mkdir, rmdir, and rename for a null path
2026-10-18 04:46:58 +13:00
Dean 7e58833f4c Merge pull request #7147 from milescoviello/fix/asan-test-suite
fix(build): run the CPU-side tests in an ANYPS5_ENABLE_ASAN build
2026-10-18 03:25:45 +13:00
Dean ba5d2be620 Merge pull request #7108 from pushkarreddyy/fix/libkernel-stat-unlink-null-efault
fix(libkernel): return EFAULT from sceKernelStat and sceKernelUnlink for a null path
2026-10-18 03:23:31 +13:00
pushkarreddyy 7bb76080c6 fix(libkernel): return EFAULT from truncate, utimes, mkdir, rmdir, and rename for a null path 2026-10-17 19:34:28 +05:30
milescovielloandClaude Opus 5.5 1c9d9d6bc5 fix(build): run the CPU-side tests in an ANYPS5_ENABLE_ASAN build
Under -DANYPS5_ENABLE_ASAN=ON with ASAN_OPTIONS=detect_leaks=0, 14 of
the 849 tests outside the AGC driver, shader and VideoOut suites failed
on main for reasons that come from the ASan build itself, not from the
code they test:

- libc copies the main executable's file-backed writable pages before
  remapping them anonymously. In an instrumented test executable those
  pages hold ASan's redzones around globals, so the memcpy reported a
  global-buffer-overflow at load (patched_libraries,
  guest_memory_lifetime). The ASan build copies the pages word by word
  without instrumentation.
- Five tests check that a local variable is on the thread's stack.
  With detect_stack_use_after_return, which is on by default on Linux,
  instrumented locals live on ASan's fake stack. These tests now run
  with it off. guest_kernel_is_stack also bounded the worker stack by
  the application area without the ASan build's arena offset.
- The relinker module tests and loadexec_arguments load instrumented
  libraries into a Python process or a relinked guest, so the ASan
  runtime is not first in the initial library list. They now run with
  verify_asan_link_order=0. Preloading libasan instead put its
  __cxa_throw interceptor ahead of libc.prx's and broke the unwind of
  an exception that LoadExec throws and catches.
- guest_allocator_failures limits RLIMIT_DATA to 128 MiB and then
  commits 300 GiB. ASan maps 37.5 GiB of shadow for that commit, which
  the limit refuses, and aborts. The ASan build skips that section.
- fiber checks the address of a local against the fiber's context too,
  so it runs without fake stacks as well. Its CheckActiveContext then
  reads the fiber stack word by word above that local, through the
  redzones of the frames on that stack, and is no longer instrumented.
- agc_multisample_guest_access passed aligned_alloc a size that is not
  a multiple of the alignment, which C11 does not allow and ASan
  rejects. It now rounds the size up.

add_asan_test_options appends to ASAN_OPTIONS for one test in an ASan
build and does nothing otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 13:55:21 +00:00
mattogepetoandClaude Sonnet 5.5 c17c6a5114 fix(libkernel): return EFAULT from clock_gettime for a null result pointer
clock_gettime threw invalid_argument when the result pointer was null,
before looking at the clock id. FreeBSD 11.4's sys_clock_gettime reads the
clock through kern_clock_gettime, which fails with EINVAL for an unknown
clock, and only then copies the result out, so a null pointer fails with
EFAULT.

Read the clock into a local value first, then fail with -1 and EFAULT when
the pointer is null. A clock that is not supported still throws before the
pointer is looked at. Test the null pointer for the supported clocks.

Written with AI assistance (Claude).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 15:33:47 +02:00
Dean 4827f36cb5 Merge pull request #7029 from milescoviello/fix/condattr-setclock-einval
fix(libkernel): return EINVAL from scePthreadCondattrSetclock and Destroy for a null attribute
2026-10-18 02:22:59 +13:00
pushkarreddyy 274f092e70 fix(libkernel): return EFAULT from sceKernelStat and sceKernelUnlink for a null path 2026-10-17 18:41:29 +05:30
pushkarreddyy a295b771eb fix(libkernel): return EFAULT from sceKernelWriteThrottlingStatus for a null status 2026-10-17 18:31:54 +05:30
Dean c0b37ca726 Merge pull request #7028 from milescoviello/fix/pthread-attr-sched-enotsup
fix(libkernel): return ENOTSUP from pthread_attr_setschedparam and setschedpolicy like libthr
2026-10-18 02:00:22 +13:00
Dean aa819ac74a Merge pull request #6956 from jradic/fix/libkernel-thread-local-slot-first-use
fix(libkernel): allocate the Windows thread-local slot on first use
2026-10-18 00:31:01 +13:00
Dean 4146636d58 Merge pull request #7033 from milescoviello/fix/sce-mprotect-zero-length
fix(libkernel): return 0 from sceKernelMprotect and sceKernelMtypeprotect for a zero length
2026-10-18 00:24:06 +13:00
Dean 12a71f3f59 Merge pull request #7032 from milescoviello/fix/getitimer-cpu-timers-zero
fix(libkernel): read ITIMER_VIRTUAL and ITIMER_PROF as disarmed in getitimer
2026-10-18 00:23:45 +13:00
Dean df377440aa Merge pull request #7027 from milescoviello/fix/rw-count-einval
fix(libkernel): return EINVAL from read and write for a byte count above SSIZE_MAX
2026-10-18 00:23:29 +13:00
Dean a08bdcb309 Merge pull request #7026 from milescoviello/fix/pthread-attr-stack-einval
fix(libkernel): return EINVAL from the scePthreadAttr stack and guard size calls
2026-10-18 00:23:13 +13:00
Dean de056cf06d Merge pull request #7025 from milescoviello/fix/kernel-read-write-null
fix(libkernel): return EFAULT from sceKernelRead and sceKernelWrite for a null buffer
2026-10-18 00:22:57 +13:00
Dean 8c924f12c8 Merge pull request #7024 from milescoviello/fix/fstat-null-efault
fix(libkernel): return EFAULT from fstat for a null stat buffer
2026-10-18 00:22:34 +13:00
Dean 3f57cd430f Merge pull request #7023 from milescoviello/fix/getrusage-errors
fix(libkernel): return EINVAL and EFAULT from getrusage instead of throwing
2026-10-18 00:22:20 +13:00
milescovielloandClaude Opus 5.5 91fbafd94a fix(libkernel): keep refusing a read low-water mark above 1 on non-stream sockets
On Linux, FIONREAD on a datagram socket reports the next datagram only,
where FreeBSD's sbavail counts every queued byte, so a read mark above 1
there could never fire. kevent now throws for it as before; stream
sockets and marks of 1 are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 11:20:03 +00:00
milescovielloandClaude Opus 5.5 e1d4ccba49 fix(libkernel): take NOTE_LOWAT on socket read and write events
kevent threw for NOTE_LOWAT. On a socket's EVFILT_READ it now sets the
low-water mark as FreeBSD 11's filt_soread does: the event fires once the
buffered bytes reach it, or at end of file or on a listening socket, and
a later change of the knote replaces it. EVFILT_WRITE takes a mark of 1,
where the host's writability stands in for a free byte; other write marks
and marks below 1 still throw. A pipe ignores the mark, as filt_piperead
does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 10:58:41 +00:00
Alexej Szpevák f2d3980f5e fix(libkernel): report free send space for socket write events on Linux
A socket's EVFILT_WRITE and sceKernelAddWriteEvent reported the whole SO_SNDBUF in data, however much was already queued. FreeBSD 11.4's filt_sowrite reports sbspace, the space still free. On Linux the queued bytes from SIOCOUTQ are now taken off SO_SNDBUF. Windows has no query for the queued bytes and macOS is not wired up, so both keep reporting SO_SNDBUF; the debt entry says so.
2026-10-17 12:28:11 +02:00
Adrià 673f7406c5 Merge pull request #6103 from Zinebyte/fix/sem-timedwait-cancellation
fix(libkernel): cancel before acquiring a ready timed semaphore
2026-10-17 12:15:32 +02:00
Alexej Szpevák 9ece094515 test(libkernel): cover F_GETLK against another process's record locks
The fcntl tests only ever held locks in the guest's own process, where FreeBSD's lf_blocks never reports a conflict, so the host lock path that answers F_GETLK was not exercised. A forked process now holds a read lock, a write lock and a write lock to the end of the file through the host. F_GETLK with F_UNLCK reports only the write locks, F_RDLCK the same and F_WRLCK the read lock, each with the owner's pid and SEEK_SET; F_SETLK over the read lock fails with EAGAIN, and nothing is reported once the owner exits.
2026-10-17 12:13:54 +02:00
Alexej Szpevák 41ec785705 fix(libkernel): answer F_GETLK with F_UNLCK on Linux and macOS
fcntl threw for F_GETLK with an F_UNLCK request on the hosts that use POSIX locks, as Linux's F_GETLK rejects that type. FreeBSD 11.4's kern_fcntl accepts it and lf_getlock reports the first overlapping lock that lf_blocks lets conflict: another owner's lock, one of the two being a write lock. For an F_UNLCK request that is exactly another owner's write lock, the same set an F_RDLCK request finds, so the host is asked with F_RDLCK and the reply is written back as for the other types.
2026-10-17 12:00:21 +02:00
milescovielloandClaude Opus 5.5 676ee71c34 fix(libkernel): treat a null deadline as an untimed lock in the timed pthread locks
pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock and
pthread_mutex_timedlock threw for a null abstime. FreeBSD's libthr
passes a null abstime on to the untimed kernel lock, so these calls
then wait like pthread_rwlock_rdlock, pthread_rwlock_wrlock and
pthread_mutex_lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:46:25 +00:00
milescovielloandClaude Opus 5.5 62ac8d655f fix(libkernel): return EINVAL from scePthreadCondattrSetclock and Destroy for a null attribute
Both threw std::invalid_argument for a null or uninitialized attribute.
FreeBSD's libthr returns EINVAL for one, as the other scePthread
attribute calls here already do. The clock id is still stored as
given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:42:41 +00:00
milescovielloandClaude Opus 5.5 cbf006cb4b fix(libkernel): return 0 from sceKernelMprotect and sceKernelMtypeprotect for a zero length
mprotect already returns 0 for a zero length. The sceKernel entry
points passed it to DoMprotect, which throws for an empty range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:26:57 +00:00
milescovielloandClaude Opus 5.5 19b236a4c5 fix(libkernel): return EINVAL from the scePthreadAttr stack and guard size calls
scePthreadAttrGetstack, Getstackaddr, Getguardsize, Setguardsize,
Setstack and Setstackaddr threw for a null attribute, a null pointer
argument or a stack below the 16 KiB minimum. FreeBSD's libthr returns
EINVAL for those, as the pthread_attr_* wrappers here and the other
scePthreadAttr calls already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:21:18 +00:00
milescovielloandClaude Opus 5.5 be17961e32 fix(libkernel): return EFAULT from fstat for a null stat buffer
FreeBSD's fstat looks the descriptor up before it copies the result
out, so a bad descriptor still fails with EBADF and an open one fails
with EFAULT when sb is null. fstat and sceKernelFstat threw
std::invalid_argument instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:19:41 +00:00
milescovielloandClaude Opus 5.5 9f704dc1eb fix(libkernel): read ITIMER_VIRTUAL and ITIMER_PROF as disarmed in getitimer
setitimer refuses to arm the CPU interval timers and already reads and
disarms them as zero, so they are never armed. getitimer threw for them
instead of reporting that state, as FreeBSD's kern_getitimer does for a
timer that is not set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:17:58 +00:00
milescovielloandClaude Opus 5.5 01c8cebf8c fix(libkernel): return EINVAL/EFAULT from getrusage instead of throwing
FreeBSD's getrusage rejects an unknown `who` with EINVAL before it
copies anything out and returns EFAULT when the result can't be
written. The HLE threw std::invalid_argument for both, which ends the
title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:10:58 +00:00
milescovielloandClaude Opus 5.5 b693ef2340 fix(libkernel): return ENOTSUP from pthread_attr_setschedparam and setschedpolicy like libthr
FreeBSD's libthr rejects a null sched_param and, under SCHED_FIFO or
SCHED_RR, a priority outside sched_get_priority_min..max with ENOTSUP,
and a policy outside SCHED_FIFO..SCHED_RR with ENOTSUP. The wrappers
returned EINVAL for the null parameter and stored any priority or
policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:05:43 +00:00
milescovielloandClaude Opus 5.5 28acd09977 fix(libkernel): return EINVAL from read and write for a byte count above SSIZE_MAX
FreeBSD's read, write, pread and pwrite reject a byte count above
IOSIZE_MAX with EINVAL before they look up the descriptor. write threw
std::invalid_argument for a negative count, and the others passed the
count on to the host, which reports EFAULT on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:01:09 +00:00
milescovielloandClaude Opus 5.5 b437dc5dba fix(libkernel): return EFAULT from sceKernelRead/sceKernelWrite for a null buffer
read and write already fail with EFAULT for a null buffer and a
non-zero length and treat a zero-length null buffer as empty. The
sceKernel entry points threw std::invalid_argument for both. They now
do the same as read and write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 05:49:06 +00:00
Dean aae9f379ed Merge pull request #6950 from MarcZX100/codex/carry-connect-listener
fix(libkernel): return EOPNOTSUPP when connecting to a listener
2026-10-17 18:00:50 +13:00
Adrià 37f0253ce8 Merge pull request #5980 from Ondra97/codex/fix-ftruncate-invalid-descriptor
fix(libkernel): reject invalid ftruncate descriptors safely
2026-10-17 06:53:47 +02:00
Adrià 8730dde45f Merge pull request #5973 from pipe1os/feat/libkernel-kevent-pipe-read
feat(libkernel): support EVFILT_READ on the read end of a pipe
2026-10-17 06:53:33 +02:00
Adrià a7f27eb352 Merge pull request #6070 from fdfawef324/claude/libkernel-windows-precise-poll-waits
fix(libkernel): use precise waits for select and poll on pipes on Windows
2026-10-17 06:53:29 +02:00
Dean dfdc3dec4d Merge pull request #5280 from santhoshkumar-dev/codex/sandbox-ca-trust
feat(libkernel): serve the sandbox CA bundle from host TLS roots
2026-10-17 16:35:44 +13:00
Dean f99f3d1dca Merge pull request #6694 from MarcZX100/codex/coredump-config-dump-mode-6688
fix(libkernel): export sceCoredumpConfigDumpMode as an explicit stub
2026-10-17 16:34:12 +13:00
Santhosh Kumar eb26fb97f8 fix(libkernel): filter sandbox TLS roots and preserve path overrides 2026-10-17 02:25:41 +00:00
screammandClaude Fable 5.1 9f4a8d6ec5 feat(libkernel): serve the console CA list from the host trust store
Titles that bundle OpenSSL load the console's CA file from the sandbox
directory and fail every HTTPS request without it. ProsperoRadio
(PPSA99001, libcurl 8.18.0 + OpenSSL 3.5.2) on main + #4796 + #4525:

  [ProsperoRadio][http] https://all.api.radio-browser.info/json/servers: Problem with the SSL CA cert (path? access rights?) (error adding trust anchors from file: /gkbHtXc3Wq/common/cert/CA_LIST.cer)

SwanStation (PPSA98510) stops on the same file (#5001).

The guest path resolver now accepts exact-path providers, and libkernel
registers one for /<sceKernelGetFsSandboxRandomWord()>/common/cert/CA_LIST.cer.
On first use it writes a PEM bundle once per process to
cert_cache/CA_LIST.cer in the run directory, read-only: on Windows the
current user's ROOT and CA system stores, elsewhere SSL_CERT_FILE or the
first distro bundle that exists. Without a certificate the path keeps
resolving under the guest root and does not exist, as before. Every other
path under the sandbox word is unchanged. The console file's format and
the rest of its common/cert directory are unverified and recorded in
docs/dev/debt/libkernel.md.

With this change, #4796, #4525 and #5025 on Windows 11, 60 s each:

  [ProsperoRadio][http] 11846160 bytes in 1458 ms: 1161 passes, 803 waits (679 woken) for 1428 ms
  [ProsperoRadio][catalog] page offset=0 bytes=11846160 objects=10000 accepted=9549 total=9549
  ...
  [ProsperoRadio][catalog] page offset=60000 bytes=1712035 objects=1494 accepted=1436 total=59371

  [SwanStationPS5] update: latest 1.2.5, this 1.1.3, available
  [SwanStationPS5] gamedb: index written

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-17 02:24:02 +00:00