Skip to content

Commit 2cf4256

Browse files
bfjeldsCopilot
andauthored
tests: [workaround] containerd 2.2 SELinux mmap denial for container images (#676)
## Summary containerd 2.2+ introduces a MountManager plugin that `mmap()`s a bbolt DB under `/run/containerd/`. The AZL 3.0 SELinux policy (refpolicy `RELEASE_2_20240226`) grants `manage_file_perms` on `container_runtime_t:file` which does **not** include the `map` permission, causing a cascade failure that surfaces as: \\\ docker: Error response from daemon: failed to create task for container: unknown service containerd.services.tasks.v1.Tasks: not implemented \\\ Upstream refpolicy fixed this in commit [\7876e51510\](SELinuxProject/refpolicy@7876e51510) (May 2024), but AZL's pinned version predates it. ## Validation https://dev.azure.com/mariner-org/ECF/_build/results?buildId=1134778 ## AZL bug https://microsoft.visualstudio.com/OS/_workitems/edit/62602180 ## Changes - Add a CIL policy module (`containerd-mmap-fix.cil`) that grants the missing `map` permission on `container_runtime_t:file` for `container_engine_system_domain` - Add `selinux-policy` package to both container images - Load the CIL module during image build via a `postCustomization` script - Applied to both `trident-container-installer` and `trident-container-testimage` > **Note:** Existing workarounds (`enforcing=0` kernel param on installer, `setenforce 0` in testimage service) are intentionally kept in place. They should be removed in a follow-up PR after this fix is validated. ## Related - Upstream fix: SELinuxProject/refpolicy@7876e51510 - Pipeline bugs: #20870, #20884, #20879, #20905 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent db2e11c commit 2cf4256

6 files changed

Lines changed: 32 additions & 0 deletions

File tree

tests/images/trident-container-installer/base/baseimg.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ os:
4040
- mdadm
4141
- moby-engine
4242
- openssh-server
43+
- selinux-policy
4344
- squashfs-tools
4445
- tar
4546
- vim
@@ -53,6 +54,8 @@ os:
5354
destination: /root/.profile
5455
- source: files/trident-container.service
5556
destination: /usr/lib/systemd/system/trident-container.service
57+
- source: files/containerd-mmap-fix.cil
58+
destination: /usr/share/selinux/packages/containerd-mmap-fix.cil
5659

5760
services:
5861
enable:
@@ -62,6 +65,7 @@ os:
6265
scripts:
6366
postCustomization:
6467
- path: scripts/post-install.sh
68+
- path: scripts/load-containerd-selinux-fix.sh
6569

6670
iso:
6771
additionalFiles:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; Fix for containerd 2.2+ MountManager plugin SELinux denial.
2+
; containerd 2.2 introduces a MountManager that opens a bbolt DB under
3+
; /run/containerd/ using mmap(). The base refpolicy (RELEASE_2_20240226)
4+
; grants manage_file_perms on container_runtime_t:file but that set does
5+
; not include 'map'. Upstream fixed this in commit 7876e51510 (May 2024).
6+
; This module backports the missing permission.
7+
(allow container_engine_system_domain container_runtime_t (file (map)))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# Load SELinux policy module that grants the 'map' permission on
3+
# container_runtime_t:file for container engines. This fixes containerd
4+
# 2.2+ MountManager bbolt mmap() denials under enforcing mode.
5+
semodule -i /usr/share/selinux/packages/containerd-mmap-fix.cil

tests/images/trident-container-testimage/base/baseimg.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ os:
6666

6767
- docker-cli
6868
- moby-engine
69+
- selinux-policy
6970
- squashfs-tools
7071
- tar
7172

7273
additionalFiles:
7374
- source: files/trident-container.service
7475
destination: /usr/lib/systemd/system/trident-container.service
76+
- source: files/containerd-mmap-fix.cil
77+
destination: /usr/share/selinux/packages/containerd-mmap-fix.cil
7578

7679
services:
7780
enable:
@@ -81,3 +84,4 @@ os:
8184
scripts:
8285
postCustomization:
8386
- path: scripts/post-install.sh
87+
- path: scripts/load-containerd-selinux-fix.sh
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; Fix for containerd 2.2+ MountManager plugin SELinux denial.
2+
; containerd 2.2 introduces a MountManager that opens a bbolt DB under
3+
; /run/containerd/ using mmap(). The base refpolicy (RELEASE_2_20240226)
4+
; grants manage_file_perms on container_runtime_t:file but that set does
5+
; not include 'map'. Upstream fixed this in commit 7876e51510 (May 2024).
6+
; This module backports the missing permission.
7+
(allow container_engine_system_domain container_runtime_t (file (map)))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# Load SELinux policy module that grants the 'map' permission on
3+
# container_runtime_t:file for container engines. This fixes containerd
4+
# 2.2+ MountManager bbolt mmap() denials under enforcing mode.
5+
semodule -i /usr/share/selinux/packages/containerd-mmap-fix.cil

0 commit comments

Comments
 (0)