Commit Graph
417 Commits
Author SHA1 Message Date
Yunus Shaikh 20ae347f6a Merge main into fix/libkernel-lstat-relinked-prx
Main's #9618 has lstat fill a local FileStat and copy it out to the guest.
The merge keeps that and this branch's module lookup in the same call, so an
original .prx name still resolves to its relinked .guest.prx.
2026-10-25 03:56:39 -07:00
Adrià 35d22d88f9 Merge pull request #9618 from xXPBSXx/fix/output-structs-efault
fix(libkernel): fail the stat family with EFAULT when the output struct is not writable guest memory
2026-10-25 11:52:20 +01:00
Adrià 16025845e5 Merge pull request #9423 from AliZedan1A/fix/guest-path-efault
fix(kernel): safely copy guest path arguments
2026-10-25 10:48:00 +01:00
ali zedan 2c5fcf6406 fix(kernel): safely copy guest path arguments 2026-10-25 08:28:09 +01:00
xXPBSXxandClaude Sonnet 5.5 6457edc2fb fix(libkernel): fail fcntl F_DUPFD with EINVAL when the minimum descriptor is beyond the open file limit on Windows
fcntl(fd, F_DUPFD, min) with min at or above RLIMIT_NOFILE duplicated the
descriptor repeatedly until the CRT table was full and then failed with
EMFILE, after opening thousands of descriptors. FreeBSD checks the minimum
first: kern_dup returns EINVAL for FDDUP_FCNTL when new < 0 or
new >= maxfd (sys/kern/kern_descrip.c:836-840). Linux already answers
EINVAL through the host fcntl. Check the minimum against the guest
RLIMIT_NOFILE before the Windows loop.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-25 01:52:31 +02:00
xXPBSXxandClaude Sonnet 5.5 83f28bd67f fix(libkernel): fail the stat family with EFAULT when the output struct is not writable guest memory
fstat, _fstat, sceKernelFstat, stat, lstat, sceKernelStat and _fstatfs
filled the caller's struct in place, or copied into it after a check that
only tests for null, so a pointer into unmapped memory crashed the host.
Fill a local struct and copy it out with a checked write that fails with
EFAULT. FreeBSD 11.4 does the same after the lookup has succeeded:
copyout(&ub, uap->sb) in sys_fstat (sys/kern/kern_descrip.c:1328),
copyout(&sb, uap->ub) in sys_stat (sys/kern/vfs_syscalls.c:2066) and
copyout(sfp, uap->buf) in sys_fstatfs (sys/kern/vfs_syscalls.c:337).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-25 01:08:01 +02:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Adrià 6b496aa1d1 Merge pull request #7299 from qpavyros/codex/windows-named-shm
feat(libkernel): support named shared memory on Windows
2026-10-24 19:42:16 +02:00
Dean d003e64fcf Merge pull request #9099 from aarushkha/feat/libkernel-equeue-regular-file-events-v2
feat(libkernel): answer sceKernelAddReadEvent and sceKernelAddWriteEvent on regular files
2026-10-25 06:33:30 +13:00
Dean 68871895d4 Merge pull request #9256 from Dom3005/fix/windows-fcntl-append
fix(libkernel): change O_APPEND on a Windows file through fcntl
2026-10-24 16:37:06 +13:00
Dean 88d4f1662c Merge pull request #10020 from Queuse/codex/keep-host-diagnostics-unbuffered
fix(libc): isolate host diagnostics from guest buffering
2026-10-24 15:22:01 +13:00
Dom3005andClaude Opus 5.5 dd6220698a fix(libkernel): change O_APPEND on a Windows file through fcntl
fcntl(F_SETFL) threw when it changed O_APPEND on a Windows file. The
guest flag already chooses WriteAtEnd, but a descriptor opened with
O_APPEND also carries the CRT's append flag, so _write kept appending
after the guest cleared it. F_SETFL now replaces the CRT descriptor of
every descriptor sharing the open file's status with a duplicate handle
opened with or without _O_APPEND, as libc fdopen does for append mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 02:28:14 +02:00
Dean a3cf44c558 Merge pull request #10111 from xXPBSXx/fix/fchflags-kqueue-einval
fix(libkernel): fail fchflags on a kqueue descriptor with EINVAL
2026-10-24 12:54:38 +13:00
Queuze d43043b6e5 chore: sync contribution #10020 with main 2026-10-23 20:02:15 -03:00
Dean Galvin a2ee2958a5 Merge main into fix/fcntl-getfl-pipe-rdwr 2026-10-24 09:07:08 +13:00
Dean 4f3087c677 Merge pull request #10136 from orezraey/fix/libkernel-close-standard-descriptors-measured-ps5
fix(libkernel): refuse closing the standard descriptors with EPERM as measured on a PS5
2026-10-24 03:23:15 +13:00
Dean Galvin 6747c5b996 Merge main into fix/fcntl-getfl-pipe-rdwr 2026-10-24 02:10:48 +13:00
Dean 06fd07ab4a Merge pull request #8700 from nikowolf123/feat/libkernel-underscore-socket-signal-entries
feat(libkernel): export the underscore entry points of the socket, directory and signal calls
2026-10-24 00:53:04 +13:00
xXPBSXxandClaude Sonnet 5.5 5b739d2b56 fix(libkernel): fail fchflags on a kqueue descriptor with EINVAL
FreeBSD resolves the descriptor with getvnode in sys_fchflags
(vfs_syscalls.c:2403), which fails with EINVAL for a descriptor that has no
vnode. fchflags threw for a kqueue descriptor instead.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-23 12:28:27 +02:00
orezraey 5c7cdfda26 Merge remote-tracking branch 'origin/main' into fix/libkernel-close-standard-descriptors-measured-ps5 2026-10-23 06:55:14 -03:00
Dean b3e42bd1eb Merge pull request #8359 from Ragbie/fix/windows-pwrite-append
fix(libkernel): append positioned writes on an O_APPEND descriptor on Windows
2026-10-23 22:23:57 +13:00
Dean Galvin 2f741e737f Merge main into feat/libkernel-underscore-socket-signal-entries 2026-10-23 22:00:32 +13:00
Dean fef15751e6 Merge pull request #8641 from Danigamer05/fix/libkernel-windows-birthtime
fix(libkernel): clamp Windows birth time when setting earlier timestamps
2026-10-23 21:49:21 +13:00
Dean a75292c7b3 Merge pull request #8687 from cadenasynyster/fix/win-loop-errors
fix(libkernel): report ELOOP from unlink, mkdir, rmdir, truncate on Windows
2026-10-23 21:08:52 +13:00
Queuze 7358bec9ff fix(libc): isolate host stream buffering 2026-10-23 01:22:23 -03:00
orezraeyandClaude Opus 5.5 2c92b0f662 fix(libkernel): refuse closing the standard descriptors with EPERM as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 21:26:24 -03:00
Dom3005andClaude Opus 5.5 93ab8d3514 fix(libkernel): answer fstatfs on a character device as devfs does
FreeBSD keeps every character device on devfs, whose devfs_statfs reports
512-byte blocks, 2 blocks and nothing free. Windows threw for any console,
NUL or the guest random device, and Linux described the host's /dev mount.
A kqueue now returns EINVAL, as getvnode does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 23:06:03 +02:00
Adrià a6fc8a467d Merge pull request #8797 from xXPBSXx/fix/unlink-rmdir-dot-component
fix(libkernel): fail unlink and rmdir of a path that ends in a dot component with EINVAL
2026-10-22 20:40:44 +02:00
Adrià 2e2ea5e697 Merge pull request #9131 from xXPBSXx/fix/fchdir-non-vnode
fix(libkernel_sys): fail fchdir on a pipe or socket with EINVAL
2026-10-22 20:32:29 +02:00
Adrià 9b1ed888d1 Merge pull request #9206 from xXPBSXx/fix/lseek-eoverflow
fix(libkernel): fail lseek with EOVERFLOW when the new offset exceeds the 64-bit range
2026-10-22 20:16:30 +02:00
Adrià FranchandClaude 093a5ba195 fix(libkernel_sys): reach the fchdir vnode check through a _nid_no_patch export
Co-Authored-By: Claude <[email protected]>
2026-10-22 20:15:39 +02:00
xXPBSXxandClaude Sonnet 5.5 e56c6d2ba8 fix(libkernel_sys): keep ENOTDIR from fchdir on a character device
The EINVAL for a descriptor without a vnode now applies only to a pipe or socket. A character device is a vnode on FreeBSD, so getvnode succeeds and change_dir fails with ENOTDIR; File::IsCharacterDevice keeps that answer for the host character devices (a tty, NUL or /dev/null) and the guest random device. guest_kernel_sys pins it with /dev/random.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-22 20:15:26 +02:00
Adrià 29b25aaf4a Merge pull request #9101 from xXPBSXx/fix/flock-directory-windows
fix(libkernel): accept flock on a directory descriptor on Windows
2026-10-22 19:42:03 +02:00
Dean 830ccd121f Merge pull request #9303 from oneandonlydean/fix/getdents-app0-symlink-type
fix(libkernel): report app0 symlinks as their target type in getdirentries
2026-10-23 02:19:24 +13:00
Yunus Shaikh 82bd36d74b Merge main into fix/libkernel-lstat-relinked-prx 2026-10-21 22:26:58 -07:00
Dean ab347d144d Merge pull request #8534 from ycbuzi/pr/windows-reparse-non-link
fix(libkernel): answer Windows reparse points that are not links
2026-10-22 17:22:28 +13:00
Dean 746bdd8041 Merge pull request #8550 from Retr0G28/fix/fopen-directory-read-windows
fix(libc): open a directory with fopen in a read mode on Windows
2026-10-22 17:22:22 +13:00
blu 9897260c6e Merge branch 'boykopovar:main' into pr/windows-reparse-non-link 2026-10-21 19:08:16 -07:00
qpavyros 82be5c28f8 fix(libkernel): honor named shm mode for administrators 2026-10-22 01:45:44 +03:00
qpavyros f9cd3ba1ce chore: merge current main into named shared memory 2026-10-22 01:44:14 +03:00
Yunus Shaikh 6e9768f618 Merge main into fix/libkernel-lstat-relinked-prx 2026-10-21 15:22:31 -07:00
xXPBSXxandClaude Sonnet 5.5 00bb8aa409 fix(libkernel): fail lseek with EOVERFLOW when the new offset exceeds the 64-bit range
FreeBSD 11.4's vn_seek fails SEEK_CUR and SEEK_END with EOVERFLOW when the base offset plus a positive offset does not fit in an off_t, and with EINVAL only when the result is negative. The host lseek reports EINVAL for the overflow, so the guest saw EINVAL. When the host call fails with EINVAL for a positive offset on SEEK_CUR or SEEK_END, the base position is read back and the call fails with EOVERFLOW if the sum would overflow; the file position is left unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 20:56:02 +02:00
Adrià ee67ebcf2d Merge pull request #8663 from xXPBSXx/fix/transfer-descriptor-first-fb
fix(libkernel): look up the descriptor of read, write, pread and pwrite before their buffer and offset
2026-10-21 20:35:28 +02:00
aarushkha 8cb0d985d7 Merge upstream main into feat/libkernel-equeue-regular-file-events-v2
Merge upstream main into feat/libkernel-equeue-regular-file-events-v2
2026-10-21 23:46:24 +05:30
Dean Galvin 58ad4eda77 fix(libkernel): report app0 symlinks as their target type in getdirentries
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.
2026-10-22 06:20:04 +13:00
NikoandClaude Opus 5.5 0ac2b0bc6f feat(libkernel): export the underscore entry points of the socket, directory and signal calls
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]>
2026-10-21 17:02:54 +02:00
aarushkhaandClaude Opus 5.5 3e48fb5f5e fix(libkernel): remove equeue events before taking the position lock on close
A wait polling a regular-file event holds the equeue mutex and calls
sceKernelLseek, which takes the descriptor's position lock on Windows.
sceKernelClose and close took that lock first and then the equeue mutex
in EqueueDescriptorClosed, so a close racing such a wait deadlocked. Both
now remove the descriptor's events before taking the position lock, as
dup2 already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 17:40:45 +05:30
Retr0 36226741f5 fix(libc): open a directory with fopen in a read mode on Windows
FreeBSD 11 fopen opens the path with _open, and vn_open_vnode refuses a
directory only for FWRITE or O_TRUNC, so fopen of a directory in a read
mode succeeds; Linux hosts already open it. On Windows CreateFileW
without FILE_FLAG_BACKUP_SEMANTICS refused it with EACCES.

fopen now opens such a path as a libkernel directory descriptor, which
libkernel registers in libc when it loads, and fclose and freopen remove
it from libkernel's table. Reads on the stream fail with EISDIR and set
the error indicator, as on a Linux host and FreeBSD's tmpfs: the Windows
CRT fails them already but reports EINVAL. Writes fail with EBADF, and
fseek, ftell and ungetc work, as on any read-only stream.
2026-10-21 14:48:37 +03:00
xXPBSXxandClaude Sonnet 5.5 0e2252f638 fix(libkernel): accept flock on a directory descriptor on Windows
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]>
2026-10-21 13:35:39 +02:00
Dean 3e91c8edf5 Merge pull request #8850 from UnhealthyKraken/feat/libkernel-cfsetspeed
feat(libkernel): implement cfsetspeed
2026-10-22 00:13:16 +13:00