idmapped mounts change ownership at the mount boundary, not on the backing file

Containers often need to read or write files whose numeric owner IDs do not match the user IDs inside the container. Changing ownership across a whole filesystem is disruptive, and granting broad access to the host path can defeat isolation. Linux idmapped mounts provide another option: the kernel translates user and group IDs for operations through a particular mount.

The kernel idmapping documentation describes the distinction between userspace IDs, kernel IDs, and the VFS IDs attached to objects through a mount. A file on disk has an on-disk owner. Access through an idmapped mount passes through the mount's ID mapping before permission checks occur. The backing file has not been rewritten merely because a process sees a different owner through the mount.

The mount is part of the security context

A process with a valid descriptor for an idmapped mount is not operating on an abstract file path. Its path resolution, ownership view, and permission checks depend on that mount. Another mount of the same filesystem can present a different mapping. Review tools must therefore record the mount ID and mapping, not only the device and inode.

This becomes security-sensitive when several workloads mount the same storage with different mappings. A backup or administrative process that accesses the backing filesystem directly may bypass assumptions made inside a container. A second idmapped mount can also expose the same data as a different owner if the host authorizes the mapping. The mapping is a policy input, so it needs a controlled owner and a reviewable configuration source.

Capabilities and security modules still apply. An ID translation does not grant an operation that the mount, filesystem, process credentials, or LSM policy denies. Read-only mount attributes remain useful, and nosuid or nodev may be appropriate even when ownership translation is correct.

Deployment checks

Create idmapped mounts through a controlled mount_setattr(2) path, then inspect the actual mount table and mapping. Confirm that the mapping is stable across restarts and that a configuration change cannot silently replace it. Test access as the intended container user and as an unrelated user, including traversal to the parent directory and access through a second host path.

Keep the backing filesystem out of workloads that have no need for host-level storage administration. Backups should copy the data and record mount context without exposing the backup service's credentials to the mounted tree. Audit mount creation, mapping changes, and unmount events.

An idmapped mount can remove the need for recursive chown and broad host bind mounts. It does not make a share safe by itself. The mounting service, mapping, path exposure, and workload all participate in the permission decision.

References