Repository navigation
sbx: start as the offline account once seclogon is up - #44
Merged
Merged
Conversation
…her run starts it Root cause: a network-deny run starts its command as sbx-offline through CreateProcessWithLogonW, which the Secondary Logon service serves, and seclogon is demand-start. When two runs make that first call at once, the call that arrives while the other's start of seclogon is still in progress is refused with ERROR_SERVICE_ALREADY_RUNNING (1056) and its command is not run. Seen on the windows-latest runner in the escape tests that start several network-deny runs together right after setup-windows (escape_windows.rs:481 and :909). The start is now made again, at most five times 200 ms apart, only when refused with 1056; any other refusal is reported at once, as before.
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.
Fixes the intermittent Windows CI failure in
crates/sandbox/tests/escape_windows.rs:sbx: the command could not be started as sbx-offline, so it was not run: Win32 error 1056. It hit #37, #41 and run 39715329817 (lines 481 and 909).Root cause
A network-deny run starts its command as
sbx-offlinethroughCreateProcessWithLogonW, which the Secondary Logon service (seclogon) serves. seclogon is demand-start: it isn't running until the first such call starts it.When two runs make that first call at once, the one that arrives while the other's start of seclogon is still in progress is refused with
ERROR_SERVICE_ALREADY_RUNNING(1056), and its command never runs. The escape tests start several network-deny runs at once right aftersetup-windows, which is exactly that situation.The race is inferred from the failures; I couldn't reproduce it on a machine where seclogon was already up.
The fix
launch_offlinemakes the start again only when refused with 1056, at most 5 times, 200 ms apart (windows::start_once_seclogon_is_up,SECLOGON_STARTING,SECLOGON_START_WAIT).Tests
windows::tests::a_start_refused_while_seclogon_starts_is_made_again_and_nothing_else_iscovers three cases:Ok;Control: never retrying fails it, with
Err(1056)instead ofOk. It's a pure function, so it runs on every OS. The real proof is the Windows escape suite staying green across CI runs.