fix(libkernel): fail write with EINVAL for a size above SSIZE_MAX #4818
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4818"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Gashrod1 on 2026-10-12T22:51:37Z.
What
write_nid_postfixthrewstd::invalid_argumentwhen the byte count did not fit inssize_t, which ends the process. FreeBSD'ssys_writereturns EINVAL for it before looking up the descriptor (sys/kern/sys_generic.c:if (uap->nbyte > IOSIZE_MAX) return (EINVAL);, whereIOSIZE_MAXisSSIZE_MAXwith the defaultdebug.iosize_max_clamp=0).writenow returns -1 with errno 22 for such a count, for any descriptor.guest_filesystemcheckswritewithSIZE_MAXon a pipe and withSSIZE_MAX + 1on descriptor -1 (EINVAL, not EBADF). It fails onmainand passes with the change.Tested
Linux (Arch, GCC), Release,
BUILD_TESTING=ON, based onmainee4962190:guest_filesystemaborts onmainand passes with the change (3 runs); full build and fullctestpass. Windows (WinLibs MinGW-w64 GCC 15.2.0 r7, NVIDIA RTX 5060), Release,BUILD_TESTING=ON: full build and fullctestpass (1018 tests, the same 7 skipped as onmain). No title or homebrew run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T01:14:16Z.
Review: COMMENTED
The change matches FreeBSD's
sys_write. Note that #4929 makes the samesize < 0→EINVALchange inwrite_nid_postfix(as part of a three-call fix inStdio.cpp), so the two will conflict on that line. Agreeing with its author which one carries it, and listing it underDepends on, would save a rebase. Your test ofSSIZE_MAX + 1on descriptor -1 (EINVALbeforeEBADF) is a case #4929 doesn't cover, so it's worth keeping either way.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:37:37Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed