Skip to content

fix(vmm/persist): do not close uffd socket #5122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
6 changes: 6 additions & 0 deletions src/vmm/src/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
}

Expand Down