-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bind mounting /etc/resolv.conf fails #1523
Comments
hmm, might not be related to nodev / nosuid. I mounted a tmpfs and it still has the same problem. stracing yields:
if I turn off this in my config.json and manually copy resolv.conf, it works. |
is the mount on which I tried putting bundle and trying, to no avail. I'm on a pretty stock and fairly new Ubuntu Zesty install, running master of all the tools. |
Aha, if I don't make it mount as 'ro' (the default) and only mount it as 'rw', it works! moby/moby#22994 might be related. I see that /etc/resolv.conf is first mounted, which is a successful call, and then there's an attempt to remount - which is what fails. |
Ah, this is what @justincormack was trying to fix with #1222, but it looks like it wasn't fully fixed. /cc @justincormack |
Never mind, his fixes were related but not meant to fix this precise issue. It's quite odd that we're trying to remount a mount without changing any of its flags. |
This is a pretty old issue now, but I stumbled upon it looking for something related.
It does look really odd, but there's a good reason for it. If the initial mount flags include
results in a bind mount that is not read-only. To make it read-only, you have to remount it. Now if the parent mount in a more privileged namespace has nosuid, noexec, nodev, relatime, etc. bits set, then they will get inherited by the new bind mount, and you cannot change those bits. So when you do the remount, you need to figure out which of those bits the mount inherited (e.g. by inspecting /proc/self/mountinfo), then pass them along to the remount syscall. Otherwise, you'll get an "operation not permitted" error like you see here because you aren't allowed to unset those bits. I bet that's what's happening. For debugging, I would recommend comparing that strace to what you see using the |
We've had this discussion previously (in #1603), and decided to add the code handling that to Docker (moby/moby#35205) or cri-o, because at the time it was caused by having a (possibly) invalid OCI configuration. It should be noted that you can get the flags necessary from But yes, you're completely right that we shouldn't be passing So ultimately the fix is either to manually change the |
Hi @cyphar, I am hitting this same problem running runc within a rootless container (user-namespace). In function func remount(m *configs.Mount, rootfs string) error {
var (
dest = m.Destination
)
if !strings.HasPrefix(dest, rootfs) {
dest = filepath.Join(rootfs, dest)
}
return unix.Mount(m.Source, dest, m.Device, uintptr(m.Flags|unix.MS_REMOUNT), "")
} In my specific case, the failure occurs when runc (running inside a rootless container) is setting up a bind mount into the container's rootfs, where the bind-mount has I read the discussion in PR #1603 and it seems the conclusion was that the higher level container manager (in my case Docker + containerd) should be the entity providing the mount flags for the bind mount, and that runc is not allowed to modify those mount flags in any way. Is this correct? Reading the OCI spec on the meaning of mount options, it simply says "Mount options of the filesystem to be used", implying that the higher level container manager should always pass those options (i.e., in my case preserve Any further thoughts on this? We need a fix (either at runc level, the OCI spec, or in the container managers above runc), as this issue will continue to show up as more people start running runc inside the user-ns / rootless containers. Thanks! |
I'm trying to run a rootless container on a Linux machine.
How to reproduce
I suspect that the problem is related to the fact that my $HOME is mounted with encfs and has nodev & nosuid (maybe related to #1247?)
The text was updated successfully, but these errors were encountered: