-
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
process_linux.go:297: applying cgroup configuration for process: read-only file system #2639
Comments
That's strange, we should already be allowing this for rootless containers: // isIgnorableError returns whether err is a permission error (in the loose
// sense of the word). This includes EROFS (which for an unprivileged user is
// basically a permission error) and EACCES (for similar reasons) as well as
// the normal EPERM.
func isIgnorableError(rootless bool, err error) bool {
// We do not ignore errors if we are root.
if !rootless {
return false
}
// TODO: rm errors.Cause once we switch to %w everywhere
err = errors.Cause(err)
// Is it an ordinary EPERM?
if errors.Is(err, os.ErrPermission) {
return true
}
// Handle some specific syscall errors.
var errno unix.Errno
if errors.As(err, &errno) {
return errno == unix.EROFS || errno == unix.EPERM || errno == unix.EACCES
}
return false
} (Note the |
AFAIK those are synonyms. Yes indeed, x/sys/unix defines it as type Errno = syscall.Errno |
So, you think you're using rc92 but it's not true. From your link:
I guess you're not using runc from Anyway, using the same runc version as you used, the code is slightly different, but it still should ignore Might be an actual bug. For now, I suggest you to retry with rc92 or latest git HEAD. @AkihiroSuda PTAL? |
I modified their example to correctly use
I think there might be something wrong with how we implemented the |
That was my primary suspect as well but since it's not working in rc10 either, it is probably not the case. It works for me on cgroupv2 + systemd (Fedora 32), as well as cgroupv1 + systemd (CentOS 8) -- with both fs[2] and systemd[2] cgroup drivers. It's probably not working on colab because the host has cgroupfs readonly already. I think the error is not ignored in this particular setup is because Indeed, if I run it as
I get a different error:
So, it's a peculiarity of a particular environment -- it reports as if you're root ( I'm inclined to close this one. |
This is what I mean:
Now, if we look into the implementation of Line 12 in 2b31437
we'll see it will return |
One thing I found out that I don't really like is "rootless" flag handling in runc. Filed issue #2645. |
Thanks for addressing the issue. I've checked, and using the
which after remounting it is shown as:
But I haven't found the way to remount the other cgroup sub-dirs (such as However after the above and below code:
the error is:
I'm not quiet sure what the above error is about, as I'm able to successfully mount
Output:
So I think the relevant permission to mount proc is there. |
I have yet to see the software that mounts something read-only first and then remounts it read-write. What you try to achieve is interesting nevertheless; please keep digging and inform us about your progress. |
@kolyshkin Oh right, I didn't notice they were running as root -- so you're quite right that all of the rootless handling will not be exercised. 🤦♂️ I tested this on my box and if you run as an unprivileged user it works but as root it (as expected) does not. I agree that rootless handling is a bit hairy (and always has been), but I'll comment on the issue you opened to give some more context and hopefully we can improve the situation. |
@kenorb The kernel has several protections against mounting pseudo-filesystems in certain contexts, one of which is that you cannot mount a filesystem like
(As an aside, this looks very similar to what we do in runc containers.) This means that you are in a situation where you wouldn't be able to mount a proper procfs inside a user namespace.
This will create a
So there's something going on inside the
So it looks like the culprit is the masking code in func msMoveRoot(rootfs string) error {
mountinfos, err := mountinfo.GetMounts(func(info *mountinfo.Info) (skip, stop bool) {
skip = false
stop = false
// Collect every sysfs and proc file systems, except those under the container rootfs
if (info.FSType != "proc" && info.FSType != "sysfs") || strings.HasPrefix(info.Mountpoint, rootfs) {
skip = true
return
}
return
})
if err != nil {
return err
}
for _, info := range mountinfos {
p := info.Mountpoint
// Be sure umount events are not propagated to the host.
if err := unix.Mount("", p, "", unix.MS_SLAVE|unix.MS_REC, ""); err != nil {
return err
}
if err := unix.Unmount(p, unix.MNT_DETACH); err != nil {
if err != unix.EINVAL && err != unix.EPERM {
return err
} else {
// If we have not privileges for umounting (e.g. rootless), then
// cover the path.
if err := unix.Mount("tmpfs", p, "tmpfs", 0, ""); err != nil {
return err
}
}
}
}
if err := unix.Mount(rootfs, "/", "", unix.MS_MOVE, ""); err != nil {
return err
}
return chroot()
} The bug is that it will try to umount subdirectories of the filesystem after unmounting the parent (which will obviously result in |
Okay, after applying #2647 I managed to get it to work in your environment @kenorb. @kolyshkin can you review #2647? |
I'm trying to run
busybox
container in Colab, however I've got the following error:Here are the steps:
busybox/rootfs
:Demo: https://colab.research.google.com/drive/19hVpEODrL8kb7KvyWrA9vE6Pd7ZKMA4G#scrollTo=VhgKc1a6zMTq
Is there any way to run the container having read-only access to cgroup configuration?
The text was updated successfully, but these errors were encountered: