Skip to content

Commit f64cc0f

Browse files
committed
fix(install): prevent dm semaphore deadlock in container IPC namespace
Add --ipc=host to the documented podman invocations for bootc install. Without IPC namespace sharing, libdevmapper's udev cookie semaphores cannot reach udevd on the host, causing cryptsetup luksOpen/luksClose to deadlock on semop(). As defense-in-depth, also set DM_DISABLE_UDEV=1 in global_init() to catch cases where IPC sharing is not configured. This tells libdevmapper to skip udev synchronization entirely. Fixes: #2089 Related: #421 Signed-off-by: Andrew Dunn <andrew@dunn.dev>
1 parent 5cbb111 commit f64cc0f

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

docs/src/bootc-install.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ to an existing system and install your container image. Failure to run
6060
Here's an example of using `bootc install` (root/elevated permission required):
6161

6262
```bash
63-
podman run --rm --privileged --pid=host -v /var/lib/containers:/var/lib/containers -v /dev:/dev --security-opt label=type:unconfined_t <image> bootc install to-disk /path/to/disk
63+
podman run --rm --privileged --pid=host --ipc=host -v /var/lib/containers:/var/lib/containers -v /dev:/dev --security-opt label=type:unconfined_t <image> bootc install to-disk /path/to/disk
6464
```
6565

6666
Note that while `--privileged` is used, this command will not perform any
6767
destructive action on the host system. Among other things, `--privileged`
6868
makes sure that all host devices are mounted into container. `/path/to/disk` is
6969
the host's block device where `<image>` will be installed on.
7070

71-
The `--pid=host --security-opt label=type:unconfined_t` today
71+
The `--pid=host --ipc=host --security-opt label=type:unconfined_t` today
7272
make it more convenient for bootc to perform some privileged
7373
operations; in the future these requirements may be dropped.
7474

@@ -191,7 +191,7 @@ process, you can create a raw disk image that you can boot via virtualization. R
191191

192192
```bash
193193
truncate -s 10G myimage.raw
194-
podman run --rm --privileged --pid=host --security-opt label=type:unconfined_t -v /dev:/dev -v /var/lib/containers:/var/lib/containers -v .:/output <yourimage> bootc install to-disk --generic-image --via-loopback /output/myimage.raw
194+
podman run --rm --privileged --pid=host --ipc=host --security-opt label=type:unconfined_t -v /dev:/dev -v /var/lib/containers:/var/lib/containers -v .:/output <yourimage> bootc install to-disk --generic-image --via-loopback /output/myimage.raw
195195
```
196196

197197
Notice that we use `--generic-image` for this use case.

0 commit comments

Comments
 (0)