Skip to content

rootfs mount propagation cannot be restored to rslave after being made private in prepareRootfs #5192

@xujihui1985

Description

@xujihui1985

Description

While testing mount propagation with runc, I noticed that rootfs propagation behaves incorrectly when the intended propagation is rslave.

During container setup, prepareRootfs() first changes the rootfs mount propagation to MS_PRIVATE | MS_REC, and after pivot_root, it attempts to restore the user-specified propagation.

Relevant code:
https://github.com/opencontainers/runc/blob/main/libcontainer/rootfs_linux.go#L1052

This works correctly when the intended propagation is rshared, but does not work for rslave.

Steps to reproduce the issue

  1. create a container with rootfsPropagation=rslave
    1.1 nerdctl run -d --mount type=bind,src=/mnt,dst=/app,bind-propagation=rslave --entrypoint sleep 600
    1.2 verify container spec is rootfsPropagation=rslave
Image 2. exec into container check if rootfs mount propagation is rslave Image 3. we expect to see the mount propagation is rslave which is rprivate

Describe the results you received and expected

we expect to see the mount propagation is rslave, which should be same if mount propagation is rshared

Image

What version of runc are you using?

affect version from 1.3.1 to 1.5.1-rc

Host OS information

No response

Host kernel information

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions