Skip to content

Commit 23d3fbe

Browse files
committed
fix(install): set DM_DISABLE_UDEV=1 in global_init as defense-in-depth for dm semaphore deadlock
Move DM_DISABLE_UDEV=1 from a standalone function in baseline.rs to global_init() in cli.rs, alongside the existing HOME workaround. This is defense-in-depth for the IPC namespace semaphore deadlock that causes cryptsetup luksOpen/luksClose to hang inside containers with isolated IPC namespaces. The primary fix is to run the install container with --ipc=host, which shares the host IPC namespace and allows libdevmapper's udev cookie semaphores to reach udevd. The env var catches cases where IPC sharing is not configured. Fixes: #2089 Related: #421, #477 Signed-off-by: Andrew Dunn <andrew@dunn.dev> AI-Assisted: yes AI-Tools: GitLab Duo, OpenCode
1 parent adab93e commit 23d3fbe

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

crates/lib/src/cli.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,15 @@ pub fn global_init() -> Result<()> {
14931493
std::env::set_var("HOME", "/root");
14941494
}
14951495
}
1496+
// Disable libdevmapper's udev synchronization. Inside a container with an
1497+
// isolated IPC namespace (the podman/docker default), udevd on the host
1498+
// cannot see the container's semaphores, causing cryptsetup luksOpen and
1499+
// luksClose to deadlock on semop(). This is a defense-in-depth measure;
1500+
// the primary fix is to run the install container with --ipc=host.
1501+
// SAFETY: Called early in main() before any threads are spawned.
1502+
unsafe {
1503+
std::env::set_var("DM_DISABLE_UDEV", "1");
1504+
}
14961505
Ok(())
14971506
}
14981507

crates/lib/src/install/baseline.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ use clap::ValueEnum;
2323
use fn_error_context::context;
2424
use serde::{Deserialize, Serialize};
2525

26+
use super::config::Filesystem;
2627
use super::MountSpec;
27-
use super::RUN_BOOTC;
28-
use super::RW_KARG;
2928
use super::RootSetup;
3029
use super::State;
31-
use super::config::Filesystem;
30+
use super::RUN_BOOTC;
31+
use super::RW_KARG;
3232
use crate::task::Task;
3333
use bootc_kernel_cmdline::utf8::Cmdline;
3434
#[cfg(feature = "install-to-disk")]

0 commit comments

Comments
 (0)