Files
AnyPS5/docs/dev/debt/changes/fix-libkernel-pread-random-negative-offset.md
brajankwandClaude Opus 5.5 e020155b90 fix(libkernel): let pread on /dev/random and /dev/urandom take a negative offset, as FreeBSD 11.4 does
The positioned reads refused a negative offset with EINVAL on every
descriptor. FreeBSD 11.4's kern_preadv refuses it only when the file is
not a character device; for a character device it passes the offset to
the driver, and random(4) ignores it. pread, preadv, sceKernelPread and
sceKernelPreadv on the modelled random devices now read whatever the
offset; a null buffer still fails with EFAULT. On Windows, the vector
path's offset overflow check now skips a negative offset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:03:11 +01:00

1.1 KiB

libkernel

change [readv, writev, preadv, pwritev and their sceKernel forms]

  • readv, writev, preadv, pwritev and their sceKernel forms (libkernel) - unreadable iovec-table errors follow FreeBSD 11.4's copyinuio, not console measurements. The table is copied before inspecting its entries; payload-buffer validation is unchanged. A total length above SSIZE_MAX fails with EINVAL before the descriptor is looked up, and the positioned forms, pread and pwrite included, report EBADF for a descriptor not open in that direction, then ESPIPE for a pipe, socket or kqueue, before EINVAL or EFAULT, as kern_preadv does. FreeBSD passes a negative offset on a character device to the driver; here only the random devices take it. A Linux process_vm_readv failure other than EFAULT throws, including when the host denies that API.