fix(minimald): guest pid-1 robustness — no panic on SSH disconnect; set guest PATH - #449
Conversation
`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>
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
Comment |
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_streamunwrappedrussh::server::run_stream, so a client that connects then drops during the handshake yieldsErr(Protocol(Disconnect))and panics. In the guest, minimald is the initramfs pid-1, so the panic kills init and brings down the whole VM:Any failed handshake was a full-VM DoS — a
minimal ls/activatethat opens an RPC channel and drops trips it.from_streamnow 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
PATHfrom 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 togit(checkouts), failing with "The git command was not found in path" despite/usr/bin/gitexisting.enter_rootfsnow sets the conventional guest PATH right after chroot.Validation
Reproduced and fixed on a real macOS libkrun VM: pre-fix,
minimal lsagainst the guest panicked init (kernel panic above); post-fix the VM survives repeatedls/activate/attachcycles, and withgitin the rootfs the session context init resolvesgitand proceeds. Daemon unit tests run on Linux CI (the crate doesn't build on the macOS host).🤖 Generated with Claude Code