Skip to content

Commit 25b6def

Browse files
committed
fix(vmm/persist): do not close uffd socket
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. Signed-off-by: Nikita Kalyazin <[email protected]>
1 parent 4f1b59c commit 25b6def

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ and this project adheres to
4444
the `SendCtrlAltDel` command not working for ACPI-enabled guest kernels, by
4545
dropping the i8042.nopnp argument from the default kernel command line
4646
Firecracker constructs.
47+
- [#5122](https://github.com/firecracker-microvm/firecracker/pull/5122): Keep
48+
the UFFD Unix domain socket open to prevent the race condition between the
49+
guest memory mappings message and the shutdown event that was sometimes
50+
causing arrival of an empty message on the UFFD handler side.
4751

4852
## [1.11.0]
4953

src/vmm/src/persist.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use std::fmt::Debug;
77
use std::fs::{File, OpenOptions};
88
use std::io::{self, Write};
9+
use std::mem::forget;
910
use std::os::unix::io::AsRawFd;
1011
use std::os::unix::net::UnixStream;
1112
use std::path::Path;
@@ -657,6 +658,11 @@ fn send_uffd_handshake(
657658
uffd.as_raw_fd(),
658659
)?;
659660

661+
// We prevent Rust from closing the socket file descriptor to avoid a potential race condition
662+
// between the mappings message and the connection shutdown. If the latter arrives at the UFFD
663+
// handler first, the handler never sees the mappings.
664+
forget(socket);
665+
660666
Ok(())
661667
}
662668

0 commit comments

Comments
 (0)