macOS KVM: guard the IPC socket sinks against a stopped user LaunchAgent - #402
Open
PTR-inc wants to merge 1 commit into
Open
macOS KVM: guard the IPC socket sinks against a stopped user LaunchAgent#402PTR-inc wants to merge 1 commit into
PTR-inc wants to merge 1 commit into
Conversation
kvm_relay_setup() returns NULL when /tmp/meshagent-kvm-<uid>.sock is still on disk but the user LaunchAgent is stopped, so nothing accepts on it. getRemoteDesktop() kept that NULL in ptrs->kvmPipe, and KVM_IPC_SOCKET is only set for the LoginWindow case, so the first desktop byte read "write" off undefined in the write sink. No protected call sits above a sink, so Duktape made it fatal and the root service exited 254 (ILIBCRITICALEXITMSG) with: uncaught: 'cannot read property write of undefined' The pause and resume sinks had the same unguarded dereference. Check that KVM_IPC_SOCKET is an object in all three, return ILibTransport_DoneState_ERROR from the write sink, and report the failed connect to the MeshCentral console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One of the test setups is running the root and user agent through terminal sessions, which showed the uncaught: 'cannot read property write of undefined' error after the user agent died and I tried to connect to the desktop.
What's happening is kvm_relay_setup() returns NULL when /tmp/meshagent-kvm-.sock is still on disk but the user agent is stopped, so nothing accepts on it. getRemoteDesktop() kept that NULL in ptrs->kvmPipe, and KVM_IPC_SOCKET is only set for the LoginWindow case, so the first desktop byte read "write" off undefined in the write sink. No protected call sits above a sink, so Duktape made it fatal and the root service exited 254 (ILIBCRITICALEXITMSG) with: uncaught: 'cannot read property write of undefined'
The pause and resume sinks had the same unguarded dereference.
Fixed by checking that KVM_IPC_SOCKET is an object in all three, return ILibTransport_DoneState_ERROR from the write sink, and report the failed connect to the MeshCentral console.
Details
I understand that I am responsible for and able to explain every line of code I submit.
the impact on platforms and architectures I could not test.
modules/, I re-embedded them so the compiled-in copies inmicroscript/ILibDuktape_Polyfills.cmatch (the agent runs the embedded copies, not the files on disk)..mshoptions table in readme.md.Testing
Tested on macos arm and x64