Skip to content

fix(minimald): guest pid-1 robustness — no panic on SSH disconnect; set guest PATH - #449

Merged
norrietaylor merged 2 commits into
mainfrom
fix/minimald-guest-robustness
Jun 17, 2026
Merged

fix(minimald): guest pid-1 robustness — no panic on SSH disconnect; set guest PATH#449
norrietaylor merged 2 commits into
mainfrom
fix/minimald-guest-robustness

Conversation

@norrietaylor

Copy link
Copy Markdown
Member

Two independent guest-daemon (pid-1) robustness fixes on the boot/connection path.

1. Don't panic pid-1 on SSH handshake failure

Connection::from_stream unwrapped russh::server::run_stream, so a client that connects then drops during the handshake yields Err(Protocol(Disconnect)) and panics. In the guest, minimald is the initramfs pid-1, so the panic kills init and brings down the whole VM:

called `Result::unwrap()` on an `Err` value: Protocol(Disconnect)
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00006500

Any failed handshake was a full-VM DoS — a minimal ls/activate that opens an RPC channel and drops trips it. from_stream now returns the error and the accept loop logs + drops the connection (mirroring how it already handles a failed session future).

2. Set a guest PATH after chroot

The guest pid-1 inherits no PATH from the kernel, so minimald's own subprocess lookups (command_exists / Command::new) failed against the rootfs userland even when the tool was installed — notably the session context init shelling out to git (checkouts), failing with "The git command was not found in path" despite /usr/bin/git existing. enter_rootfs now sets the conventional guest PATH right after chroot.

Validation

Reproduced and fixed on a real macOS libkrun VM: pre-fix, minimal ls against the guest panicked init (kernel panic above); post-fix the VM survives repeated ls/activate/attach cycles, and with git in the rootfs the session context init resolves git and proceeds. Daemon unit tests run on Linux CI (the crate doesn't build on the macOS host).

🤖 Generated with Claude Code

norrietaylor and others added 2 commits June 17, 2026 16:26
`Connection::from_stream` unwrapped the result of
`russh::server::run_stream`, so a client that connects then drops during
the SSH handshake yields `Err(Protocol(Disconnect))` and panics the
task. In the guest, minimald is the initramfs pid-1, so that panic kills
init and takes down the whole VM:

    called `Result::unwrap()` on an `Err` value: Protocol(Disconnect)
    Kernel panic - not syncing: Attempted to kill init! exitcode=0x00006500

Any failed handshake was a full-VM DoS — e.g. a `minimal ls`/`activate`
that opens an RPC channel and drops trips it. Return the error from
`from_stream` and have the accept loop log it and drop the connection,
matching how it already handles a failed session future.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The guest pid-1 inherits no PATH from the kernel, so minimald's own
subprocess lookups via `command_exists`/`Command::new` failed against the
rootfs userland even when the tool was installed. Notably the session
context init shells out to `git` (`checkouts`), failing with "The git
command was not found in path" despite `/usr/bin/git` existing.

Set the conventional guest PATH in `enter_rootfs` right after chroot.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@norrietaylor, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 21 minutes and 46 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ad8a0af9-f1af-4756-9f03-959ab3c72416

📥 Commits

Reviewing files that changed from the base of the PR and between b1ea627 and c134cbe.

📒 Files selected for processing (4)
  • crates/minimald/src/connection.rs
  • crates/minimald/src/guest.rs
  • crates/minimald/src/server.rs
  • crates/minimald/src/test_harness.rs

Comment @coderabbitai help to get the list of available commands and usage tips.

@norrietaylor
norrietaylor enabled auto-merge (squash) June 17, 2026 23:42
@norrietaylor
norrietaylor merged commit ccd3213 into main Jun 17, 2026
30 checks passed
@norrietaylor
norrietaylor deleted the fix/minimald-guest-robustness branch June 17, 2026 23:43
norrietaylor added a commit that referenced this pull request Jun 18, 2026
PR branch reverted commit ccd3213 (#449) while adding the
minimal-verify spec. Restore connection.rs, guest.rs, server.rs, and
test_harness.rs to main so the PR contains only the spec doc.

Refs: #449
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