Skip to content

Commit 040c7f4

Browse files
committed
fix(launcher): absorb the first-touch AV scan window on staged-copy secure open
Dry run 30206811293: windows-11-arm (both variants) and windows-2025 smoke failed in the update/uninstall E2E phases with 'private staged copy failed secure open (error 32)' — ERROR_SHARING_VIOLATION. On the newer hosted images a first-touch scanner transiently holds the just-staged executable without FILE_SHARE_DELETE, so the launcher's GENERIC_READ|DELETE retirement open collides on cold images. Absorb the scan window with the same bounded backoff the staged RENAME path already uses (<=~2.5s, exponential); every retry re-runs the full secure-open validation, so no TOCTOU surface changes. No deterministic local repro exists (the VM passes this phase with Defender active; the collision is image-specific) — the next dry run on the same three jobs is the arbiter. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent a20a50d commit 040c7f4

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎src/launcher/windows_launcher.c‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,8 +1178,21 @@ static int launcher_spawn_payload(const wchar_t *execution_path, const wchar_t *
11781178
if (payload_ready && private_activation) {
11791179
/* DELETE only, never GENERIC_WRITE: the payload is RUNNING from this
11801180
* staged image, and the image section always denies write sharing
1181-
* (ERROR_SHARING_VIOLATION). */
1182-
private_file = launcher_open_regular(execution_path, GENERIC_READ | DELETE, true);
1181+
* (ERROR_SHARING_VIOLATION). First-touch antivirus scanners also hold
1182+
* a just-staged executable without FILE_SHARE_DELETE, so this
1183+
* DELETE-access open transiently collides as ERROR_SHARING_VIOLATION
1184+
* on cold images (observed on hosted-runner images) — the same scan
1185+
* window the staged rename above absorbs. Bounded backoff; every
1186+
* retry re-runs the full secure-open validation. */
1187+
for (DWORD wait_ms = 0U, waited_ms = 0U;; waited_ms += wait_ms) {
1188+
private_file = launcher_open_regular(execution_path, GENERIC_READ | DELETE, true);
1189+
if (private_file != INVALID_HANDLE_VALUE || GetLastError() != ERROR_SHARING_VIOLATION ||
1190+
waited_ms >= 2000U) {
1191+
break;
1192+
}
1193+
wait_ms = wait_ms == 0U ? 100U : (wait_ms < 1000U ? wait_ms * 2U : wait_ms);
1194+
Sleep(wait_ms);
1195+
}
11831196
if (private_file == INVALID_HANDLE_VALUE) {
11841197
/* Surfaced on the inherited stderr: the payload's generic
11851198
* completion error cannot say WHICH launcher-side step refused. */

0 commit comments

Comments
 (0)