diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ed5a75ef72..0fc97cac00f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ and this project adheres to the `SendCtrlAltDel` command not working for ACPI-enabled guest kernels, by dropping the i8042.nopnp argument from the default kernel command line Firecracker constructs. +- [#5122](https://github.com/firecracker-microvm/firecracker/pull/5122): Keep + the UFFD Unix domain socket open to prevent the race condition between the + guest memory mappings message and the shutdown event that was sometimes + causing arrival of an empty message on the UFFD handler side. ## [1.11.0] diff --git a/src/vmm/src/persist.rs b/src/vmm/src/persist.rs index 3ffc4355f0b..067cb51896b 100644 --- a/src/vmm/src/persist.rs +++ b/src/vmm/src/persist.rs @@ -6,6 +6,7 @@ use std::fmt::Debug; use std::fs::{File, OpenOptions}; use std::io::{self, Write}; +use std::mem::forget; use std::os::unix::io::AsRawFd; use std::os::unix::net::UnixStream; use std::path::Path; @@ -657,6 +658,11 @@ fn send_uffd_handshake( uffd.as_raw_fd(), )?; + // We prevent Rust from closing the socket file descriptor to avoid a potential race condition + // between the mappings message and the connection shutdown. If the latter arrives at the UFFD + // handler first, the handler never sees the mappings. + forget(socket); + Ok(()) }