fix(libkernel): fail the time getters and setitimer with EFAULT on an unmapped pointer #10978
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10978"
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 AdnanKhan-ak47 on 2026-10-25T11:51:39Z.
What
gettimeofday,sceKernelGettimeofday,sceKernelGettimezone,getitimerandsetitimerfail withEFAULT(0x8002000efor the sceKernel forms) when a pointer argument is unmapped, as FreeBSD'scopyinandcopyoutmakesys_gettimeofday,sys_getitimerandsys_setitimerfail, instead of crashing the host. The null checks already in place stay as they were.The outputs go through
GuestCopyOut_nid_no_patch, whichfstatand the descriptor calls already use.setitimerreads its value through a newGuestCopyIn_nid_no_patchin libc, the read counterpart of the existing checked write:ReadProcessMemoryon Windows,process_vm_readvon Linux andmach_vm_read_overwriteon macOS, afterGuestArenaPrepareHostRead.setitimerkeeps FreeBSD's order, copyin thenEINVALchecks then set then copyout, so apreviouspointer that fails after the timer was set leaves it set, assys_setitimerdoes; the regression probes that path with a disarming value.gettimeofdaycomputes the time once into a local and copies it out, which is what letsceKernelGettimeofdayanswer its own error code.GuestFreebsdClocks.cpp,GuestGetitimer.cppandGuestItimer.cppprobe the issue's two addresses,1and0xfffffffffffff000, on every pointer parameter and check that a failed call writes nothing to the other output.Tested
Arch Linux x86-64, GCC 16.2.1:
ctest -R '^guest_(freebsd_clocks|getitimer|itimer)$'3/3 pass; withmain'sTime.cppandSignals.cpprestored, all three fail withSegFault.tools/check_conventions.py --base origin/mainclean.tools/pr_overlap.pyreports #10499, which changes the body ofsceKernelGettimezoneto report host zone offsets; this PR changes the same two lines to a checked copy-out, so whichever lands second rebases that body. Windows and macOS not run; the copy helpers are the onesGuestCopyOutand thegetrlimitfix (#8986) already exercise there.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 MarcZX10 on 2026-10-25T11:53:17Z.
Review: CHANGES_REQUESTED
Requesting changes for contribution coordination: #10975 was already open and implements the same six time-related exports, adds the same checked
GuestCopyIn/GuestCopyOuthelpers, and also declaresFixes: #10969. This PR independently changes those same exports and fixes the same issue, so the checklist statement that no open PR implements the same functions is no longer accurate. The repository asks authors of overlapping PRs to agree which one goes first and declareDepends onwhen one builds on the other.There is useful distinct work here: this PR adds the checked macOS
mach_vm_read_overwritepath that the current #10975 head is missing. Please coordinate with the #10975 author and maintainers on one implementation path, preserving that macOS fix and its tests without leaving two competing implementations of the same exports. Update the dependency/fix checklist and rebase the selected path once that order is agreed. I have not approved either implementation pending that coordination; the Linux and Windows-focused evidence does not settle the macOS runtime case.Pull request closed