Skip to content

Guard against duplicate bbox-init on macOS#31

Merged
JAORMX merged 1 commit intomainfrom
macos/dual-init-guard
Mar 11, 2026
Merged

Guard against duplicate bbox-init on macOS#31
JAORMX merged 1 commit intomainfrom
macos/dual-init-guard

Conversation

@jhrozek
Copy link
Copy Markdown
Contributor

@jhrozek jhrozek commented Mar 11, 2026

On macOS, libkrun spawns two init.krun processes, each of which
fork+execs bbox-init. Without a guard, the duplicate init races
with the primary on tmpfs mounts and network configuration.

Use flock(LOCK_EX|LOCK_NB) on /bbox-init.lock as an atomic guard.
The losing instance blocks on a signal channel forever instead of
exiting, because exit would cause its parent init.krun to call
reboot(POWER_OFF), killing the entire VM.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

On macOS, libkrun's init.krun forks a child for the timesync
clock_worker. When the vsock DGRAM bind fails, clock_worker
returns instead of calling _exit(), so the child falls through
into the main init path and execs a second bbox-init.

Add an flock(LOCK_EX|LOCK_NB) guard so the second instance
blocks forever instead of racing with the first.

Workaround for containers/libkrun#580

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jhrozek jhrozek force-pushed the macos/dual-init-guard branch from ca1d935 to d052d51 Compare March 11, 2026 13:31
@JAORMX JAORMX merged commit b1eca95 into main Mar 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants