Repository navigation
Conversation
… unreadable pointer Both setters dereferenced the guest's timeval, timespec and timezone directly, so a pointer into unmapped memory crashed the host. Copy each non-null argument in with a checked read before any validation, as FreeBSD 11.4's sys_settimeofday and sys_clock_settime copyin first: an unreadable argument returns EFAULT ahead of EINVAL for a bad clock or value, and settimeofday stores no time zone when either copy fails. Fixes boykopovar#11370 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tsQ2RPv2nbDiPMpehiedc
MarcZX10
left a comment
There was a problem hiding this comment.
This PR appears to duplicate open #11402 (78571ca2fb9f), which already changes these same clock_settime/settimeofday input paths, addresses #11370, and adds EFAULT-before-EINVAL and timezone non-mutation coverage. Please coordinate with that PR’s author/maintainers before keeping parallel implementations; the cross-page fault cases here are useful additional coverage that could be incorporated into the existing fix if appropriate.
The current head also fails Conventions because What and Tested are empty and all required checklist items are unchecked. The branch merge base is 84ffc1ae2d96, while live main is 518d36eaec0a; main has since changed GuestKernelSys.cpp and docs/dev/debt/libkernel.md, both touched here. Please reconcile those changes, complete the required template and dependency/merge-order fields, then rerun the focused clock/kernel tests and conventions on the resulting head. I have not found a distinct behavior change that justifies a second implementation while #11402 remains open.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
Thanks for filling the PR template; the current conventions check passes, so that earlier note no longer applies.
The remaining blocker is overlap with still-open #11402. I compared both heads: each adds the same platform-specific checked guest read to Time.cpp, copies the clock_settime/settimeofday arguments before validation, and returns EFAULT before EINVAL for the unreadable pointers. Both address #11370. This PR's distinct value is its cross-page boundary cases and broader error-order checks, which are useful, but they currently live beside a second implementation of the same setters.
Please coordinate with #11402's author/maintainers and consolidate the extra regression cases into one implementation, or document an agreed merge order and make this PR a non-duplicative follow-up. The current head is also 154 commits behind main; since GuestKernelSys.cpp and docs/dev/debt/libkernel.md changed on both sides, sync and resolve those files before the final focused test/conventions run. The required policy checks currently pass; product jobs are skipped by path policy. The Linux test results in the description are author-reported; I did not run them independently on this head.
|
Windows run of
AI-assisted: yes (Claude Code) |
|
Closing as a duplicate: #11402 was merged this morning and already covers this issue (#11370). It adds the same checked guest read to The part that is not on |
What
settimeofdayandclock_settimeread the guest'stimeval,timespecandtimezonedirectly, so a pointer into unmapped memory crashed the host process (#11370).Both now copy each non-null argument in with a checked read before any validation, as FreeBSD 11.4's
sys_settimeofdayandsys_clock_settimecopyinfirst (kern_time.clines 390, 671 and 678):clock_settimewith an unreadable time returnsEFAULT, also for a clock other thanCLOCK_REALTIME, where it returnedEINVALbefore reading the time.settimeofdaywith an unreadable time or time zone returnsEFAULTahead of theEINVALvalue checks and ahead of the throw for a valid time. A failed copy stores no time zone.The checked read is local to
Time.cpp, as inProcess.cpp. #10975 and #10978 each add a sharedGuestCopyIn_nid_no_patchto libc; whichever lands first, this read can move onto it in a follow-up. This PR does not add a third copy, so it does not conflict with either.The
settimeofdayandclock_settimedebt entries now sayEFAULTfor an unreadable argument instead of only a null one.Tested
Linux (Ubuntu 24.04, GCC 13.3, Release, full build with
BUILD_TESTING=ON,libsrebuilt). No Windows or macOS run; the Windows and macOS branches of the checked read followReadGuestinProcess.cpp.guest_kernel_sys(CheckSettimeofdayUnreadable) andguest_freebsd_clocks(SettimeFaultsBeforeValidation): an unreadable page and an argument that crosses from a readable page into it, for the time and the time zone, with valid and invalid values and with clocks other thanCLOCK_REALTIME. They also check that the time zone set before the faulting calls is still reported.main'sTime.cppwith the new tests: bothguest_kernel_sysandguest_freebsd_clocksend withSegFault. Green with this change.ctest(2335 tests): 2323 passed, 766 of them skipped for lack of a Vulkan device. 12 failed:agc_submit_progress,agc_submit_progress_no_timeline,agc_driver_pipelined_metadata_pass,agc_driver_pipelined_metadata_pass_draw_pipeline(no GPU), andguest_net_protocol,guest_net_buffer_validation,guest_sce_net_keepalive,guest_net_nodelay_readback,guest_socket_options,guest_socket_stream_options,guest_socket_address_length,guest_tcp(the sandbox has no IPv6, errno 47). The same 12 fail withmain'sTime.cppon the same machine.main84ffc1a: the 93 tests matchingguest_freebsd_clocks|guest_kernel_sys|itimer|time|clock|guest_fstat_faultpass exceptagc_submit_progress_no_timeline, which also fails onmain.python3 tools/check_conventions.py --base origin/main: all checks passed.tools/pr_overlap.pycould not run (noghGraphQL access here). By hand: the other open PRs that touchTime.cpp(fix(libkernel): fail gettimeofday, getitimer, setitimer and the sceKernel time getters with EFAULT on an unusable pointer #10975, fix(libkernel): fail the time getters and setitimer with EFAULT on an unmapped pointer #10978) change the getters and libc, not these two setters.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)🤖 Generated with Claude Code