Skip to content

Commit

Permalink
release: label overlayfs state directories
Browse files Browse the repository at this point in the history
Using `state_t` as the label makes the directories read-only for all
unprivileged containers, even if they have access via a host mount.

Signed-off-by: Ben Cressey <[email protected]>
  • Loading branch information
bcressey committed Dec 17, 2021
1 parent 4c7912f commit 29de89f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/release/prepare-local.service
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ ExecStart=/usr/bin/mkdir -p \
${LOCAL_DIR}/var/lib/kernel-devel/.overlay/work \
${LOCAL_DIR}/var/lib/kernel-modules/.overlay/upper \
${LOCAL_DIR}/var/lib/kernel-modules/.overlay/work
ExecStart=/usr/sbin/setfiles -r ${LOCAL_DIR} \
-F /etc/selinux/fortified/contexts/files/file_contexts \
${LOCAL_DIR}/var/lib/kernel-devel \
${LOCAL_DIR}/var/lib/kernel-modules

# Create the directories we need to set up a read-write overlayfs for any CNI
# plugin binaries.
Expand All @@ -31,6 +35,9 @@ ExecStart=/usr/bin/mkdir -p \
${LOCAL_DIR}/opt/cni/bin \
${LOCAL_DIR}/var/lib/cni-plugins/.overlay/upper \
${LOCAL_DIR}/var/lib/cni-plugins/.overlay/work
ExecStart=/usr/sbin/setfiles -r ${LOCAL_DIR} \
-F /etc/selinux/fortified/contexts/files/file_contexts \
${LOCAL_DIR}/var/lib/cni-plugins

RemainAfterExit=true
StandardError=journal+console
Expand Down
8 changes: 8 additions & 0 deletions packages/selinux-policy/fs.cil
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
(filecon "/var/lib/netdog" any lease)
(filecon "/var/lib/netdog/.*" any lease)

; Label local directories for overlayfs mounts.
(filecon "/var/lib/cni-plugins" any state)
(filecon "/var/lib/cni-plugins/.*" any state)
(filecon "/var/lib/kernel-devel" any state)
(filecon "/var/lib/kernel-devel/.*" any state)
(filecon "/var/lib/kernel-modules" any state)
(filecon "/var/lib/kernel-modules/.*" any state)

; Label kernel filesystem mounts.
(filecon "/proc" any proc)
(filecon "/proc/.*" any ())
Expand Down

0 comments on commit 29de89f

Please sign in to comment.