Closed elezar closed 5 months ago
/cc @klueska
/cc @kad @klihub
@elezar The problem was solved for the CRI runtimes earlier https://kubernetes.io/blog/2021/11/09/non-root-containers-and-devices/
there's also a potential conflict/overlap: if device_ownership_from_security_context
boolean is enabled and a device plugin picks up the device host GID into AdditionalGIDs
via CDI, the host GID does not exist in the container anymore. Right?
@mythi thanks for the feedback and for the linked blog post. The addition of the GIDs to the list comes from the workaround that was required to get this working on non-CRI-based runtimes such as podman or docker. There is also no device_ownership_from_security_context
that can be enabled.
There is also the question of rootless containers which as far as I was able to tell from runc
's implementation bind mount devices instead of creating the device nodes using mknod
.
Maybe this indicates that we need to reopen this issue (possibly reverting #179) to investigate this further.
From our testing the existence of the GID in the container does not seem to affect behaviour, but I could spend more time on this.
The addition of the GIDs to the list comes from the workaround that was required to get this working on non-CRI-based runtimes such as podman or docker.
Yeah I thought so too based on the issue description but wanted share what containerd/CRI-O can do if you had plans to get this to your device plugin too.
I played with rootless containers and devices just before the holidays. See my "summary" in https://github.com/containers/podman/issues/20974#issuecomment-1862599848. I did not try rootless docker/runc but at least crun w/ podman allows you to preserve the host GID using --group-add keep-groups
. AFAIK, there's an old RFC topic for runtime-spec for how this should be handled officially but I've not studied where the conversation is atm.
This issue is stale because it has been open 90 days with no activity. This issue will be closed in 30 days unless new comments are made or the stale label is removed.
This issue was automatically closed due to inactivity.
Consider the following conditions. A device nodes with the following properties
If we inject these two devices into a container using the command line:
we see:
Note that both device nodes have their file mode set to
xx0
meaning that users not in thevideo
orrender
group can access the device. This means that if we start the container with a non-root user, we would no be able to read from or write to the devices.A workaround is to add the numeric group ID for the required group(s) (
video
orrender
in this case) to thedocker
commandline:Meaning that the device nodes are readable by the container process.
What Docker does is add the IDs for the groups to the
field in the OCI Runtime Specification. As confirmed by inspecting the
config.json
generated for the container:The proposal here is that we extend the CDI specification to allow AdditionalGIDs to be specified as
ContainerEdits
:We can decide whether we want to add a struct type instead to allow for future extensions.
With this extension, the modifications to the OCI Spec will include appending the set of
RequiredGroupIDs
to theProcess.User.AdditionalGIDs
slice.