-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add cgroup v2 support #3
Conversation
@jprendes just in case that you're interested |
Cargo.toml
Outdated
@@ -30,6 +30,7 @@ bollard = "0.16" | |||
futures = "0.3" | |||
rustix = { version = "0.38", features = ["fs", "stdio", "termios"] } | |||
bitflags = "2" | |||
aya = { git = "https://github.com/nbdd0121/aya.git" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either merge changes upstream or fork the repo under lowRISC I think. Seems like your changes could be upstreamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was actually upstreamed one hour ago! Good timing :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, I have never really used eBPF programs so I might have missed something.
This is a simple program which allows mknod, a standard list of devices to be allowed inside the container, and a hashmap mapping a list of devices to allwoed accesses. This allows runtime update on whether a device is allowed inside a container. It is automatically compiled with build.rs.
cgroup v1 uses two special files to determine access, where cgroup v2 uses eBPF programs to control access. The code will attach a custom eBPF program which allows run-time reconfiguration and detach docker's default. eBPF programs will be detached when the attaching program dies, which can be dangerous if container-hotplug exits unexpectedly while the program is running, so we instead pin it (so it stays when the program exits) and unpin it after the docker container is down. In this case we might have garbage eBPF programs pinned when container-hotplug exits unexpectedly but it is safe.
cgroup v1 uses two special files to determine access, where cgroup v2 uses eBPF programs to control access. The code will attach a custom eBPF program which allows run-time reconfiguration and detach docker's default.
eBPF programs will be detached when the attaching program dies, which can be dangerous if container-hotplug exits unexpectedly while the program is running, so we instead pin it (so it stays when the program exits) and unpin it after the docker container is down. In this case we might have garbage eBPF programs pinned when container-hotplug exits unexpectedly but it is safe.