Repository navigation
Conversation
e2cdb1f to
4922d24
Compare
| let descriptors = match fs::read_dir(entry.path().join("fd")) { | ||
| Ok(descriptors) => descriptors, | ||
| Err(error) if error.kind() == io::ErrorKind::NotFound => continue, | ||
| Err(error) => return Err(error).context("Cannot inspect process disk handles"), |
There was a problem hiding this comment.
An unreadable fd directory for any unrelated process aborts every operation that checks a managed disk. The same applies to descriptor iteration and metadata below. This could make setup, new instance creation, commit, restore, disk resize, and instance destroy unavailable on hosts with restricted procfs or process-inspection policy. I did not reproduce such a restriction on the available host. Please keep the fail-closed check, but include the offending PID (and descriptor where applicable) and underlying error in the diagnostic, and exercise this path on a representative Firecracker host.
| Err(error) => return Err(error).context("Cannot inspect process disk handle"), | ||
| }; | ||
| if held.dev() == identity.dev() && held.ino() == identity.ino() { | ||
| bail!("Managed disk is still open by process {pid}"); |
There was a problem hiding this comment.
This also rejects a benign read-only holder such as a backup or indexer. That is a reasonable safety tradeoff, but it can stop routine work until the reader exits. Could the error name the disk and give a concise way to inspect the PID and retry? The current message gives only a PID, so users may not know which host process to resolve.
| return Err(error).context("Cannot inspect loop backing identity"); | ||
| } | ||
| if info.lo_device == identity.dev() && info.lo_inode == identity.ino() { | ||
| bail!("Managed disk is still attached to a host loop device"); |
There was a problem hiding this comment.
When an attachment is found, this message does not identify the loop device. Including its name would let the user inspect and unmount the specific attachment before retrying, without weakening the refusal.
|
UX review of the current draft: I left three inline comments on process-scan failures and holder diagnostics. I found no confirmed broad regression on the available Linux host. A root-equivalent scan of about 146 processes and 1,022 descriptors took about 4 ms; copy, swap, and disk growth repeat the scan, so this should still be measured on a representative Firecracker host. Starting an existing instance does not take this new path; creating one does. Lima behavior is unchanged. The unreadable-unrelated-process case is a conditional availability risk, not a reproduced failure here. Keeping the checks fail closed is appropriate. The requested changes are actionable error context and representative-host validation. Firecracker and Lima VM integration were not run for this PR head; the privileged disk probe and visible CI checks passed. |
Partial hardening for #630.
Summary
Verification
cargo test --workspace --locked --quiet— passed.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings— passed.cargo fmt -- --checkandgit diff --check— passed.tests/privileged-disk.sh— passed on Linux with sudo and loop mounts, including mounted source/destination, foreign loop mount, and open process handle cases.This remains a draft pending a representative Firecracker run and assessment of the hostwide process scan's availability cost. The broader design remains in #630, with implementation and recovery tracked by #633.