Repository navigation
fix(libkernel): fail the time getters and setitimer with EFAULT on an unmapped pointer - #10978
AdnanKhan-ak47 wants to merge 1 commit into
Conversation
… unmapped pointer
MarcZX10
left a comment
There was a problem hiding this comment.
Requesting changes for contribution coordination: #10975 was already open and implements the same six time-related exports, adds the same checked GuestCopyIn/GuestCopyOut helpers, and also declares Fixes: #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 declare Depends on when one builds on the other.
There is useful distinct work here: this PR adds the checked macOS mach_vm_read_overwrite path 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.
|
Agreed, #10975 was first and is the issue author's; withdrawing this one. @xXPBSXx the only piece here that #10975's current head lacks is the macOS branch of #elif defined(__APPLE__)
mach_vm_size_t copied = 0;
return ::mach_vm_read_overwrite(::mach_task_self(), reinterpret_cast<mach_vm_address_t>(source), bytes,
reinterpret_cast<mach_vm_address_t>(destination), &copied) == KERN_SUCCESS && copied == bytes;Free to take anything else from |
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)