-
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
libct/cg: openat2 optimization not working across container boundaries #3026
Comments
It seems that the issue is that (As an aside @kolyshkin I think that the error message in the openat2 code should be changed to better describe the path being opened -- |
Hi, it seems that you've opened an issue that is in relation to using The reason for this policy is that runc has fairly complicated behaviour that is shared between the
NOTE: This is a saved reply. Sorry if it reads as a cookie-cutter response, it was written to explain the situation around libcontainer. If you are already aware of this, and are fine accepting the risks of using libcontainer directly, you can ignore this message. |
Hi @cyphar thank you very much for both of the replies. So to test the hypothesis I changed I don't believe we're messing around with anything, duping or otherwise, aside from running the container root in an overlayfs which is maybe related. |
What happens if you apply this patch? diff --git a/libcontainer/cgroups/fscommon/open.go b/libcontainer/cgroups/fscommon/open.go
index e95876a21769..2ef1e15cfae8 100644
--- a/libcontainer/cgroups/fscommon/open.go
+++ b/libcontainer/cgroups/fscommon/open.go
@@ -1,6 +1,7 @@
package fscommon
import (
+ "fmt"
"os"
"strings"
"sync"
@@ -86,7 +87,13 @@ func OpenFile(dir, file string, flags int) (*os.File, error) {
Mode: uint64(mode),
})
if err != nil {
- return nil, &os.PathError{Op: "openat2", Path: dir + "/" + file, Err: err}
+ procpath := fmt.Sprintf("/proc/self/fd/%d", cgroupFd)
+ realdir, _ := os.Readlink(procpath)
+ path := dir + "/" + file
+ if realdir != dir {
+ path = fmt.Sprintf("[%s=%d!=%s]/%s", procpath, realdir, dir, file)
+ }
+ return nil, &os.PathError{Op: "openat2", Path: path, Err: err}
}
return os.NewFile(uintptr(fd), cgroupfsPrefix+relname), nil |
So apparently what should be the cgroup path is actually |
Hmm, so it seems that fd 30 is being swapped with a handle to |
Thank you so much Aleksa, I don't want to take up more of your valuable time with this. Your pointer to look at the openat2 call certainly saved hours of work, so thank you for that! I'll keep looking into it, but worst case we just use the fallback path without openat2 which seems like it should be fine. I'd suspect the FD is getting messed up either in entering the mount namespace or mounting the overlayfs. |
Apparently we did not have such a use case in mind. runc works with cgroup files before entering any namespaces. I guess we can check on error if @MikeDombo If the source code is available, I will be happy to help resolve this. |
Thank you for looking Kir. Sadly our usage isn't open source at this time. Hopefully when we do open source it we'll have moved to using runc properly instead of going directly to libcontainer. |
Hi,
I'm using libcontainer to create my container and I found a regression when Ubuntu updated from kernel 5.4 to kernel 5.8 on Thursday/Friday. I'm currently seeing
process_linux.go:385: applying cgroup configuration for process caused: openat2 /sys/fs/cgroup/cpuset/<container id>/cpuset.cpus: no such file or directory
. On kernel 5.4 using the exact same code it work fine. I edited libcontainer to do a directory listing and I can verify that thecpuset.cpus
"file" does exist as it should, however it is unable to be opened by libcontainer. I am able to runcat
on the path without error from outside the container.Any pointers would be incredibly helpful, thank you very much.
The text was updated successfully, but these errors were encountered: