Repository navigation
fix(libkernel): check settimeofday and clock_settime pointers - #11402
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
The overlap check's manual review found real integration work here. This head is based on |
MarcZX10
left a comment
There was a problem hiding this comment.
Changes requested for the stale base and unresolved file-level integrations described in my comment. I have not run a full review vote on the merged behavior until the branch is current and the overlapping clock_settime edits are coordinated.
Both read their caller's structures in place before validation, so an unreadable pointer crashed the host. Copy them in with a checked read first and return EFAULT, as FreeBSD 11.4 does. Fixes boykopovar#11370
|
@00xDisaster Hi, a merge-order note: our #11042 conflicts with this PR in |
3fbd4b4 to
78571ca
Compare
|
@MarcZX10 Rebased onto current Merge order for the overlap report: I propose this PR first, then #9677, #11042 and #9713 rebase; no code dependency from this PR. The merged Could you re-review |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 78571ca against current main 4b1a9a3. The checked copies happen before clock/value validation, preserving EFAULT precedence; settimeofday only updates the stored timezone after both requested structures are readable, and the added cases cover unreadable time/zone pointers and unchanged state. The author reports guest_freebsd_clocks and guest_kernel_sys passing 2/2 on Linux, plus a negative control that segfaults on the same pointers with main. Hosted product jobs are skipped by path policy. I independently inspected the Linux, Windows, and macOS checked-copy branches and the existing GuestArena read hook. No blocking correctness issue found. Integration note: #11042 author agreed to rebase after this PR and keep the NotImplemented path for valid clock_settime; #9677 and #9713 make separate edits in shared files, so preserve their additions when they rebase.
|
A native Windows run of
AI-assisted: yes (Claude Code) |
What
clock_settimeread the caller'stimespecin place, andsettimeofdayread itstimevalandtimezonein place, so a pointer into unmapped memory crashed the host. Both now copy the structures in with a checked read first, as FreeBSD 11.4'ssys_clock_settimeandsys_settimeofdaydo, and returnEFAULTbefore validation when a non-null pointer is unreadable.clock_settimestill returnsEFAULTfor a null time, andsettimeofdaystill treats a null argument as omitted. This keepsEFAULTahead ofEINVALand keeps an unreadable time zone from being stored.The checked read is independent of #10975, which adds a shared
GuestCopyInhelper for the getters andsetitimerbut not these setters.clock_settimeoverlaps #11042, which replaces the valid-time descriptive throw withNotImplemented_nid_no_patchand changes the same clock test. The merged function keeps this PR's copy,EFAULTandEINVALorder, then #11042'sNotImplementedpath for a valid request; neither change replaces the other. #9677 adds aGuestTime.hppinclude inTime.cpp; #9713 adds includes andThreadAndSessionTestsinGuestKernelSys.cpp. Those are merge-order conflicts only.Merge order proposal: this PR first, then #9677, #11042 and #9713 rebase and keep both sides. No code dependency is required.
Tested
Linux x86_64, GCC 16.2.1, Release build, base
upstream/main4b1a9a3b2f; head78571ca2fb.guest_freebsd_clocksandguest_kernel_syspass 2/2 with new cases that pass1as the time, time zone, or both pointers:clock_settimereturns-1/EFAULTfor an unreadable time with both a valid and an invalid clock.settimeofdayreturns-1/EFAULTfor an unreadable time, an unreadable zone, both, and a valid time with an unreadable zone.EFAULTbefore invalid time values returnEINVAL.Negative control with
upstream/main4b1a9a3b2fTime.cppand the tests from this head:guest_freebsd_clocksandguest_kernel_sysboth fail withException: SegFaultat the first unreadable pointer. Tests were not run on Windows, macOS, the console, or a title.Checklist
main; no other open PR adds the checked reads; fix: report five always-throwing network and kernel exports as not implemented #11042 changes the validclock_settimetail and is preserved on rebaseNotImplemented_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)