virtmgr: Log pVM outputs even if DebugLevel::NONE
The code currently assumes that crosvm FDs related to pVM console I/O
(through the virtual UART or the virtio-console) should not be set up
when running a guest that is marked as non-debuggable. This seems to
have been based on the assumption that Microdroid does not generate logs
when non-debuggable, to avoid leaking secrets.
However, the resulting assumption is too restrictive or unnecessary as
1. it also silences the virtual UART, used by pvmfw, which is not
impacted by the debuggability of the payload it verifies
2. it is based on Microdroid which, being derived from Linux, doesn't
have full trust in its logs not containing sensitive data but other
guest payloads might be comfortable logging when non-debuggable
3. (if that was assumed) it does not contribute to the security of the
pVM as the threat model considers virtmgr an attack vector
Therefore, simply remove this assumption and always pipe the log FDs out
of crosvm, to be logged in the host logcat, as per aosp/2370496.
Test: m virtmgr
Bug: 360152729
Change-Id: I697c414ad25cb6b91d3b8995c41fcdf71c974973
diff --git a/android/virtmgr/src/aidl.rs b/android/virtmgr/src/aidl.rs
index f1bfd8c..144524f 100644
--- a/android/virtmgr/src/aidl.rs
+++ b/android/virtmgr/src/aidl.rs
@@ -411,9 +411,9 @@
let state = &mut *self.state.lock().unwrap();
let console_out_fd =
- clone_or_prepare_logger_fd(&debug_config, console_out_fd, format!("Console({})", cid))?;
+ clone_or_prepare_logger_fd(console_out_fd, format!("Console({})", cid))?;
let console_in_fd = console_in_fd.map(clone_file).transpose()?;
- let log_fd = clone_or_prepare_logger_fd(&debug_config, log_fd, format!("Log({})", cid))?;
+ let log_fd = clone_or_prepare_logger_fd(log_fd, format!("Log({})", cid))?;
// Counter to generate unique IDs for temporary image files.
let mut next_temporary_image_id = 0;
@@ -1563,7 +1563,6 @@
}
fn clone_or_prepare_logger_fd(
- debug_config: &DebugConfig,
fd: Option<&ParcelFileDescriptor>,
tag: String,
) -> Result<Option<File>, Status> {
@@ -1571,10 +1570,6 @@
return Ok(Some(clone_file(fd)?));
}
- if !debug_config.should_prepare_console_output() {
- return Ok(None);
- };
-
let (read_fd, write_fd) =
pipe().context("Failed to create pipe").or_service_specific_exception(-1)?;