fix(libkernel_sys): record EINVAL in the aiocb for oversized and unsigned-signal aio requests #16191
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16191"
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 MarcZX10 on 2026-11-05T20:35:49Z.
What
Queue()incore/libs/prx/libkernel_sys/Aio.cpprejects two requests withFail(GuestEinval), which sets errno but does not store the error in the guestaiocb. The request is never queued, butstatusstays -1 anderrorstays 0 (set on entry), so a followingaio_error()reports the rejected request as completed without error. The other rejection paths in the same function go through the localfail()helper, which records the error in the aiocb.Affected checks:
nbytes > INT_MAX: fixe3cebfb6a2, testdd23eece9dSIGEV_SIGNAL/SIGEV_THREAD_IDwithsignooutside1..SignalMax: fix2ce12e4318, test8c10407b0eThe fix only changes the two
returnstatements tofail(GuestEinval). The call still returns -1 with EINVAL; the aiocb now carries the same EINVAL thataio_error()reports.The existing validation test asserted
huge.error == 0for the oversized request, which pinned the defect; it now expects EINVAL.Overlap and interaction: open PR #14403 adds a copy-in line directly above the
nbytescheck inQueue(). It does not change the lines this PR changes, but the hunks are adjacent. Merging this branch with #14403 produces a textual conflict incore/libs/prx/libkernel_sys/Aio.cpp(checked withgit merge-tree). This PR does not depend on #14403 and is based onupstream/main. #15115 touchesaio_suspendand is not affected.Tested
Linux host (kernel 6.1), throwaway archive build with the CPU startup gate patched.
guest_kernel_sys_aio(guest_kernel_sys_aio_tests) on the fixed head8c10407b0e: build exit 0, 1/1 passed.check failed at line 91(thenbytescase), as expected.python3 tools/check_conventions.py --base upstream/main: passed.git diff --check upstream/main: clean.tools/pr_precheck.py(no-build): conventions and ABI audit passed; build-dependent C++ tests reported not run by that tool, which the build above covers.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-10T11:12:15Z.
Review: COMMENTED
Read
4b9daae4afagainstmain.Correctness. The two
Fail(GuestEinval)returns inQueue(core/libs/prx/libkernel_sys/Aio.cpp) are not an oversight: they reproduce FreeBSD 11.4aio_aqueue_job(sys/kern/vfs_aio.c), which storesstatus = -1anderror = 0on entry, then callsops->store_error(ujob, ...)for the queue limit, the copy-in failure and a badsigev_notify, but returnsEINVALwithoutstore_errorforaio_nbytes > IOSIZE_MAXand for an invalidsigev_signo. FreeBSD'skern_aio_errorthen takes the "failure of aio_aqueue" path (fetch_status == -1) and returns the stored error, which is 0 for those two cases. Somain'saio_errorresult of 0 for the oversized and bad-signal requests is the reference behaviour, and thehuge.error == 0assertion was pinning it on purpose, next to thenotify.error == Einvalassertion for the case where FreeBSD does store it. Switching both tofailmakes AnyPS5 diverge from FreeBSD with no PS5 measurement given.Test. The updated assertions fail on
main(it leaveserrorat 0), so they exercise the change, but they encode the non-FreeBSD result. Unless there is console evidence that the PS5 kernel stores EINVAL here, this should stay as it is onmain; if there is, cite it and add alibkernel_sys.mdentry recording the departure from FreeBSD.Not run here; this is from reading the code.
AI-assisted: yes.
Pull request closed