libkernel: a null buffer or negative offset hides EBADF and ESPIPE in read, write, pread and pwrite #8662

Closed
opened 2026-10-20 20:17:48 +00:00 by xXPBSXx · 0 comments
xXPBSXx commented 2026-10-20 20:17:48 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T20:17:48Z.


Repro

read(-1, NULL, 1), write(-1, NULL, 1), sceKernelRead(-1, NULL, 1), pread(-1, buf, 1, -1), pread(pipe_read_end, buf, 1, -1).
Expected (FreeBSD 11.4 sys/kern/sys_generic.c:288, :332-341): EBADF for a descriptor that is not open, ESPIPE for a descriptor that cannot seek, EINVAL for a negative offset on a seekable one; a null buffer is only noticed when the data is copied (EFAULT).
Actual: EFAULT for the null buffer, EINVAL for the negative offset, before the descriptor is looked at.
Test: core/libs/tests/GuestFilesystem.cpp. Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/transfer-descriptor-first-fb. AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5948960081 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8662). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T20:17:48Z. --- ### Repro `read(-1, NULL, 1)`, `write(-1, NULL, 1)`, `sceKernelRead(-1, NULL, 1)`, `pread(-1, buf, 1, -1)`, `pread(pipe_read_end, buf, 1, -1)`. Expected (FreeBSD 11.4 sys/kern/sys_generic.c:288, :332-341): EBADF for a descriptor that is not open, ESPIPE for a descriptor that cannot seek, EINVAL for a negative offset on a seekable one; a null buffer is only noticed when the data is copied (EFAULT). Actual: EFAULT for the null buffer, EINVAL for the negative offset, before the descriptor is looked at. Test: core/libs/tests/GuestFilesystem.cpp. Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/transfer-descriptor-first-fb. AI-assisted (Claude Code).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#8662
No description provided.