{{ message }}
Repository navigation
Conversation
Assisted-by: Kimi K3
Assisted-by: Kimi K3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

I've been interested in using gVisor on my k8s cluster for a while, most particularly since the vulnpocalypse has gone underway. But the lack of SELinux support is quite tricky to get around, because there's no equivalent there for
--security-opt label=disable. You can set the context tospc_tfor a conceptual equivalent...but that's still filling in the fields in the spec, so gVisor sees it and bails.This led me to an experiment where I created this horrid Python wrapper script that would check if a container was using
spc_tand, if so, set that to the exec context, clear it from the spec file, and run gVisor. This "worked" because, again,spc_tis effectively unprivileged, so runsc could just run like normal.But then I wondered...can runsc support SELinux? No no I don't mean inside the container (that would be cool but is definitely far beyond my current abilities!). Rather, can we apply the given label to runsc itself, so that the sentry and gofer are both confined within the label?
And thus, we have this RFC. Although it's very WIP, but it does work, well enough for me to test it out on my actual cluster. There are some...notable quirks here:
make docker-testsand some manual smoke tests.docker-teststo run, I automatically rewrite all mounts to use binds instead with:Z(because the mount API doesn't support relabeling), with some manual exclusions. Obviously very ugly, but I'm not sure what the desired result would look like./proc/PID/attr/currentusescontainer_t).:Z/:z), with directfs enabled, runsc will fail to start. This appears to be the existing behavior of runsc when-vhas a path it does not have read access to, but it's a bit weird in the SELinux case, since it's more likely someone will accidentally pass a path without relabeling it. lisafs does not have this problem. I'm not really sure what the ideal solution would be here.why is it significant that the binary is opened nowcomment in particular, as well as the semantics around restarting (there's just a lot of edge cases there, so it's hard to tell if I missed one).Is SELinux support necessary? gVisor does of course have its own quite durable sandbox, but I think having more defense-in-depth is always useful, and this would make it pretty hard for even a sandbox hole to turn into e.g. more arbitrary forms of filesystem access, as well as limit the ability for any arbitrary-code-execution vulns to use sketchy syscalls that somehow get through seccomp (e.g. SELinux can block AF_ALG system-wide, without any seccomp changes).
That leads me to: does the project want this? I outlined many gaps above, but these are all very fixable things. I just don't want to start committing to making this production-ready if it's wholly undesired. But personally I do think it would be useful! (If not deemed useful enough, there probably should be a better story in using gVisor in an SELinux-enabled cluster, e.g. just only allowing
spc_tor similar, but that's for another day I guess.)If anyone wants to test this, you can just use the binaries and
chcon system_u:object_r:container_runtime_exec_t:s0on runsc itself + the sidecar binaries (the containerd shim doesn't need it), like the makefile does. It's unclear to me if I broke CI somewhere here, though (I didn't really look too hard for extra linters and such that I was supposed to be running), so getting the binaries might require building yourself.Assisted-by: Kimi K3