[Bug]: rootfsPropagation "rslave" (and rshared/rprivate/runbindable) is rejected; Podman containers with --device fail
Bug Description
youki fails linux.rootfsPropagation values other than shared, slave, private and unbindable with UnknownRootfsPropagation, reported as failed to prepare rootfs.
Podman writes "rootfsPropagation": "rslave" whenever one of its mounts asks for slave propagation. Rootless Podman does that for every --device, because devices become bind mounts with slave, and for volumes with mountPropagation: HostToContainer. So podman --runtime youki run --device /dev/kvm ... fails.
At eb07b60173fca880e4287d5bc0de2580edec2c91, RootFS::mount_to_rootfs() (crates/libcontainer/src/rootfs/rootfs.rs:47-54) matches the four values and errors on anything else. adjust_root_mount_propagation() (:134-140) handles only shared and unbindable.
The spec and the other runtimes:
- The runtime spec (v1.2.1, config-linux.md, "Rootfs Mount Propagation") says the value "is either
shared,slave,privateorunbindable". So Podman'srslaveis outside the letter of the spec. This report is about compatibility with the other runtimes. - runc (v1.4.1,
libcontainer/specconv/spec_linux.go:62-71, used at:439-442) maps all eight spellings, the r-forms withMS_REC. It applies the flag again after pivot_root unless it is private (libcontainer/rootfs_linux.go:227-228). - crun (1.30,
src/libcrun/linux.c:4020-4021) parses the value with its general mount-flag parser, which knows the r-forms.
Steps to Reproduce
#!/bin/sh
# repro.sh <runtime> <rootfsPropagation> [workdir]
set -eu
RT=$1; PROP=$2; W=${3:-$(pwd)/work-$RT-$PROP}
here=$(cd "$(dirname "$0")" && pwd)
rm -rf "$W"; mkdir -p "$W/bundle/rootfs"
tar -xzf "$here/alpine-minirootfs-3.24.2-x86_64.tar.gz" -C "$W/bundle/rootfs" 2>/dev/null
cd "$W/bundle"
"$RT" spec --rootless
python3 - "$PROP" <<'P'
import json, sys
s = json.load(open('config.json'))
s['process']['terminal'] = False
s['process']['args'] = ['true']
s['linux']['rootfsPropagation'] = sys.argv[1]
json.dump(s, open('config.json', 'w'), indent=2)
P
"$RT" --root "$W/state" run --bundle "$W/bundle" "repro-$$" && echo ok(The attached repro.sh does the same. Run as root, it also checks that a host mount made after the container starts shows up inside it.)
- Put
alpine-minirootfs-3.24.2-x86_64.tar.gz(sha256c5ca053cfe1d85c5b96dff8b9bc57045f7f184a30ffb6b65776409ca90388677) next to the script. ./repro.sh youki slaveprintsok../repro.sh youki rslave,rsharedandrprivateeach fail:ERROR libcontainer::process::init::process: failed to prepare rootfs err=UnknownRootfsPropagation("rslave") ERROR libcontainer::process::container_intermediate_process: failed to initialize container process: failed to prepare rootfs ERROR youki: error in executing command: failed to create container: exec process failed with error failed to prepare rootfs- With crun, all four values print
ok.
What Podman writes, taken from its bundle for podman create --device /dev/kvm alpine true:
rootfsPropagation = 'rslave'
/dev/kvm mount options: ['slave', 'nosuid', 'noexec', 'rw', 'rbind']podman --runtime youki run --rm --device /dev/kvm alpine true fails with failed to prepare rootfs.
Expectation
The r-forms are accepted, as by runc and crun.
System and Setup Info
youki version: 0.7.0
commit: 0.7.0-eb07b60173fca880e4287d5bc0de2580edec2c91
Kernel-Release 7.2.7-1-cachyos
Operating System CachyOSPodman 6.1.2 rootless; crun 1.30.1.
Additional Context
- #3604 (per-mount propagation options, closed via #3699) is about per-mount options; this is the rootfs-level field.
- #3733 (rootfs propagation applied without a mount namespace) is about the same code but a different problem.
Source: youki-dev/youki