From 0110fb4edc9ffa13d33f1c41c708f4bd844b0aee Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Tue, 14 Feb 2023 16:15:46 -0800 Subject: [PATCH] vmm: config: Don't close reserved FDs from `NetConfig::drop()` Fixes: #5203 Signed-off-by: Bo Chen --- vmm/src/config.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 49d906d31..03e5ba1a2 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -1154,6 +1154,11 @@ impl Drop for NetConfig { fn drop(&mut self) { if let Some(mut fds) = self.fds.take() { for fd in fds.drain(..) { + // Skip reserved FDs + if fd <= 2 { + continue; + } + // SAFETY: Safe as the fd was given to the config by the API unsafe { libc::close(fd) }; }