Skip to content

Commit 1784041

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 a6c9559 commit 1784041

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
@@ -39,6 +39,10 @@ and this project adheres to
3939
the `SendCtrlAltDel` command not working for ACPI-enabled guest kernels, by
4040
dropping the i8042.nopnp argument from the default kernel command line
4141
Firecracker constructs.
42+
- [#xxxx](https://github.com/firecracker-microvm/firecracker/pull/xxxx): Keep
43+
the UFFD Unix domain socket open to prevent the race condition between the
44+
guest memory mappings message and the shutdown event that was sometimes
45+
causing arrival of an empty message on the UFFD handler side.
4246

4347
## [1.11.0]
4448

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)