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
- 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

2. exec into container check if rootfs mount propagation is rslave

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
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
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.1 nerdctl run -d --mount type=bind,src=/mnt,dst=/app,bind-propagation=rslave --entrypoint sleep
1.2 verify container spec is rootfsPropagation=rslave
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
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