#3762·youki

[Bug]: overlay mount fails with EINVAL when the lowerdir option is longer than 255 bytes (breaks Podman `--mount type=image`)

Author: ItzExoticalCreated Sep 28, 2026Updated Oct 2, 2026

Bug Description

youki fails to create a container that has an overlay mount when the lowerdir= option value is longer than 255 bytes. The error is failed to prepare rootfs / Mount(Syscall(Nix(EINVAL))). crun runs the same bundle.

Podman creates exactly this kind of mount for image volumes (podman run --mount type=image,...): a read-only overlay with only lower layers, options ["lowerdir=<image>/merged:<container>/lower", "private", "userxattr"]. For rootless Podman the lowerdir value is usually close to 300 bytes (287 bytes on the machine below), so every --mount type=image fails with youki.

Cause: since v0.5.7, non-bind mounts go through fsopen/fsconfig/fsmount, and each option is passed with fsconfig(FSCONFIG_SET_STRING). The kernel copies that value with strndup_user(_value, 256) and returns EINVAL when it is longer than 255 bytes (fs/fsopen.c, SYSCALL_DEFINE5(fsconfig, ...), case FSCONFIG_SET_STRING). mount(2) takes the whole data string, up to a page, so the same option works there.

  • youki: crates/libcontainer/src/rootfs/mount.rs at eb07b60173fca880e4287d5bc0de2580edec2c91, lines 718-727. Every key=value option becomes one FSCONFIG_SET_STRING call. The EINVAL retry at line 793 calls mount_fn() a second time, which fails the same way.
  • Linux v6.12 fs/fsopen.c: param.string = strndup_user(_value, 256);. mm/util.c strndup_user() returns ERR_PTR(-EINVAL) when length > n, and the length includes the NUL.
  • The runtime spec (config.md, "Mounts") says unknown options SHOULD be passed as a comma-separated string to mount(2)'s data argument, and sets no length limit, so the config is valid.
  • crun (1.30, src/libcrun/linux.c around lines 1816-1824) tries fsopen_mount() first and falls back to mount(2) with the full data string when that fails, so the long lowerdir works there.

strace of youki run on the bundle below, as root:

fsopen("overlay", 0)              = 12
fsconfig(12, FSCONFIG_SET_STRING, "source", "overlay", 0) = 0
fsconfig(12, FSCONFIG_SET_STRING, "lowerdir", "/w/youki-stock/xxx.../layer1:/w/youki-stock/xxx..."..., 0) = -1 EINVAL (Invalid argument)
fsopen("overlay", 0)              = 12
fsconfig(12, FSCONFIG_SET_STRING, "source", "overlay", 0) = 0
fsconfig(12, FSCONFIG_SET_STRING, "lowerdir", "/w/youki-stock/xxx.../layer1:/w/youki-stock/xxx..."..., 0) = -1 EINVAL (Invalid argument)

Steps to Reproduce

No Podman needed. The script builds a bundle from an Alpine minirootfs and adds one mount:

json
{"destination": "/guest", "type": "overlay", "source": "overlay",
 "options": ["lowerdir=<layer1>:<layer2>", "private", "userxattr"]}
bash
#!/bin/sh
# repro.sh <runtime> <short|long> [workdir]
set -eu
RT=$1; CASE=$2; W=${3:-$(pwd)/work}
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
if [ "$CASE" = long ]; then n=110; else n=40; fi
pad=$(printf "%${n}s" | tr ' ' x)
L1="$W/$pad/layer1"; L2="$W/$pad/layer2"
mkdir -p "$L1" "$L2"; echo one > "$L1/one"; echo two > "$L2/two"
cd "$W/bundle"
if [ "$(id -u)" = 0 ]; then "$RT" spec; else "$RT" spec --rootless; fi
python3 - "$L1:$L2" <<'P'
import json, sys
s = json.load(open('config.json'))
s['process']['terminal'] = False
s['process']['args'] = ['cat', '/guest/one', '/guest/two']
s['mounts'].append({'destination': '/guest', 'type': 'overlay', 'source': 'overlay',
                    'options': ['lowerdir=' + sys.argv[1], 'private', 'userxattr']})
json.dump(s, open('config.json', 'w'), indent=2)
print(f"lowerdir value: {len(sys.argv[1])} bytes")
P
"$RT" --root "$W/state" run --bundle "$W/bundle" "repro-$CASE"
  1. Download alpine-minirootfs-3.24.2-x86_64.tar.gz (sha256 c5ca053cfe1d85c5b96dff8b9bc57045f7f184a30ffb6b65776409ca90388677) next to the script.
  2. ./repro.sh youki short ~/yr/short prints one and two (lowerdir value 177 bytes).
  3. ./repro.sh youki long ~/yr/long fails (lowerdir value 315 bytes):
ERROR libcontainer::rootfs::mount: failed to mount Mount { destination: "/guest", typ: Some("overlay"), source: Some("overlay"), options: Some(["lowerdir=~/.cache/yr/youki-stock-long/xxx.../layer1:~/.cache/yr/youki-stock-long/xxx.../layer2", "private", "userxattr"]), uid_mappings: None, gid_mappings: None }: syscall
ERROR libcontainer::process::init::process: failed to prepare rootfs err=Mount(Syscall(Nix(EINVAL)))
ERROR libcontainer::process::container_intermediate_process: failed to initialize container process: failed to prepare rootfs
ERROR libcontainer::container::builder_impl: failed to run container process exec process failed with error failed to prepare rootfs
ERROR youki: error in executing command: failed to create container: exec process failed with error failed to prepare rootfs
  1. ./repro.sh crun long ~/yr/crun-long prints one and two.

With Podman: podman --runtime youki run --rm --mount type=image,source=docker.io/library/python:3.13-alpine,destination=/guest docker.io/library/alpine:3 ls /guest fails with failed to prepare rootfs. The same command with crun lists the image.

Results:

where user youki (eb07b601) short / long crun short / long
CachyOS, Linux 7.2.7 rootless (an unprivileged user) ok / EINVAL ok / ok
AlmaLinux 10.2, Linux 6.12.0-211.56.1.el10_2, SELinux enforcing root ok / EINVAL ok / ok (crun 1.27)
same rootless ok / EINVAL ok / ok

Expectation

The container starts and /guest shows both layers, as with crun, and as with youki when the lowerdir value is under 256 bytes.

System and Setup Info

youki version: 0.7.0
commit: 0.7.0-eb07b60173fca880e4287d5bc0de2580edec2c91
spec: 1.1.0
rustc: 1.96.0
libseccomp: 2.6.0
Kernel-Release    7.2.7-1-cachyos
Operating System  CachyOS
Cgroup setup      unified

Built with cargo build --release --bin youki --no-default-features --features systemd,v2,seccomp --target x86_64-unknown-linux-musl. v0.7.0 behaves the same.

Podman 6.1.2 (CachyOS) and 5.8.2 (AlmaLinux 10.2), rootless, cgroup v2 with the systemd cgroup manager.

Additional Context

The fd-based flow came in with 5886c910 (v0.5.7). v0.5.6 mounted with mount(2), which has no 255-byte limit per option.

Other key=value options have the same limit (a long upperdir, workdir, or a single lower layer path over 255 bytes). The lowerdir list is the one Podman runs into in practice.