-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dmz-vs-selinux kludge and a way to disable it
Add a workaround for a problem of older container-selinux not allowing runc to use dmz feature. If runc sees that SELinux is in enforced mode and the container's SELinux label is set, it disables dmz. Add a build tag, runc_dmz_selinux_nocompat, which disables the workaround. Newer distros that ship container-selinux >= 2.224.0 (currently CentOS Stream 8 and 9, RHEL 8 and 9, and Fedora 38+) may build runc with this build tag set to benefit from dmz working with SELinux. Document the build tag in the top-level and libct/dmz READMEs. Use the build tag in our CI builds for CentOS Stream 9 and Fedora 38, as they already has container-selinux 2.224.0 available in updates. Add a TODO to use the build tag for CentOS Stream 8 once it has container-selinux updated. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
- Loading branch information
Showing
7 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//go:build runc_dmz_selinux_nocompat || !linux | ||
|
||
package dmz | ||
|
||
import "github.com/opencontainers/runc/libcontainer/configs" | ||
|
||
// WorksWithSELinux tells whether runc-dmz can work with SELinux. | ||
func WorksWithSELinux(*configs.Config) bool { | ||
return true | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//go:build linux && !runc_dmz_selinux_nocompat | ||
|
||
package dmz | ||
|
||
import ( | ||
"github.com/opencontainers/runc/libcontainer/configs" | ||
"github.com/opencontainers/selinux/go-selinux" | ||
) | ||
|
||
// WorksWithSELinux tells whether runc-dmz can work with SELinux. | ||
// | ||
// Older SELinux policy can prevent runc to execute the dmz binary. The issue is | ||
// fixed in container-selinux >= 2.224.0: | ||
// | ||
// - https://github.com/containers/container-selinux/issues/274 | ||
// - https://github.com/containers/container-selinux/pull/280 | ||
// | ||
// Alas, there is is no easy way to do a runtime check if dmz works with | ||
// SELinux, so the below workaround is enabled by default. It results in | ||
// disabling dmz in case container SELinux label is set and the selinux is in | ||
// enforced mode. | ||
// | ||
// Newer distributions that have the sufficiently new container-selinux version | ||
// can build runc with runc_dmz_selinux_nocompat build flag to disable this | ||
// workaround (essentially allowing dmz to be used together with SELinux). | ||
func WorksWithSELinux(c *configs.Config) bool { | ||
return c.ProcessLabel == "" || selinux.EnforceMode() != selinux.Enforcing | ||
} |