Skip to content

Commit c46f8fa

Browse files
committed
fix: allow CNI SELinux runtime operations
Allow pod domains to perform CNI/BPF operations currently required by Cilium/Multus-style networking, including BPF filesystem writes, CNI state access, CNI socket connectto, and bounded runtime relabel/read cases. Also allow initramfs/udev startup handoff operations observed during CNI/plugin execution. Signed-off-by: howdude230 <47754786+howdude230@users.noreply.github.com>
1 parent f0a5842 commit c46f8fa

5 files changed

Lines changed: 20 additions & 2 deletions

File tree

492 Bytes
Binary file not shown.

internal/pkg/selinux/policy/selinux/common/processes.cil

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,14 @@
128128

129129
; ; cilium-agent
130130
; (allow any_p self (perf_event (all)))
131-
; (allow any_p bpf_t (fs_classes (rw)))
131+
(allow any_p bpf_t (fs_classes (rw)))
132132

133133
; fio
134134
(allow any_p self (shm (all)))
135135

136136
; /run/flannel, created by containerd
137137
(allow any_p pod_containerd_run_t (fs_classes (rw)))
138+
(allow pod_p pod_containerd_run_t (fs_classes (relabelfrom relabelto)))
138139

139140
; Mayastor
140141
(allow any_p hugetlbfs_t (fs_classes (rw)))

internal/pkg/selinux/policy/selinux/services/cri.cil

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
(allow pod_containerd_t bin_exec_t (fs_classes (ro)))
4747
; (allow pod_p cni_conf_t (fs_classes (rw)))
4848
(allow pod_containerd_t cni_state_t (fs_classes (rw)))
49+
(allow pod_p cni_state_t (fs_classes (rw)))
4950

5051
; Logs
5152
(allow pod_containerd_t pods_log_t (fs_classes (rw)))
@@ -163,7 +164,7 @@
163164
(allow pod_p devpts_t (fs_classes (rw)))
164165

165166
; ; cilium
166-
; (allow pod_containerd_t pod_p (unix_stream_socket (connectto)))
167+
(allow pod_containerd_t pod_p (unix_stream_socket (connectto)))
167168

168169
; pkg/flannel
169170
(allow pod_p cni_conf_t (fs_classes (rw)))
@@ -211,6 +212,16 @@
211212
; `install` also seems to test the plugin
212213
(allow pod_t cni_plugin_t (file (execute execute_no_trans)))
213214

215+
; CNI agents manage pinned BPF programs/maps owned by containerd processes.
216+
(allow pod_p pod_containerd_t (bpf (prog_run)))
217+
(allow pod_p sys_containerd_t (bpf (prog_run)))
218+
219+
; Host diagnostics mounted into pods can expose proc entries labelled with the
220+
; owning process domain instead of procfs_t.
221+
(allow pod_p init_t (file (getattr open read)))
222+
(allow pod_p rootfs_t (filesystem (getattr)))
223+
(allow pod_p udev_run_t (fs_classes (ro)))
224+
214225
; TinK is an example of what needs this. Docker in a pod will also require this.
215226
(allow pod_p cgroup_t (fs_classes (rw)))
216227
(allow pod_p nsfs_t (fs_classes (ro)))

internal/pkg/selinux/policy/selinux/services/machined.cil

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@
9494
(allow kernel_t initramfs_t (fd (use)))
9595
; Make machined go into proper context
9696
(allow initramfs_t bin_exec_t (fs_classes (ro))) ; Find init
97+
(allow initramfs_t bin_exec_t (file (execute execute_no_trans)))
9798
(allow initramfs_t init_exec_t (fs_classes (ro)))
9899
(allow initramfs_t init_exec_t (file (execute)))
100+
(allow initramfs_t cni_plugin_t (fs_classes (ro)))
101+
(allow initramfs_t cni_plugin_t (file (execute execute_no_trans)))
102+
(allow initramfs_t modprobe_exec_t (fs_classes (ro)))
103+
(allow initramfs_t modprobe_exec_t (file (execute execute_no_trans)))
99104
(typetransition initramfs_t init_exec_t process init_t)
100105
(allow initramfs_t init_t (process_classes (full)))
101106
(allow init_t initramfs_t (fd (use)))

internal/pkg/selinux/policy/selinux/services/udev.cil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,4 @@
112112
(allow udev_t bin_exec_t (file (execute execute_no_trans)))
113113
(allow udev_t kernel_t (system (ipc_info)))
114114
(allow udev_t any_p (sem (all)))
115+
(allow udev_t initramfs_t (fd (use)))

0 commit comments

Comments
 (0)