Skip to content

Commit

Permalink
processes: cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Sharshakov <[email protected]>
  • Loading branch information
dsseng committed Oct 5, 2024
1 parent 5dd6921 commit 617f296
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 39 deletions.
13 changes: 3 additions & 10 deletions selinux/common/processes.cil
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
; BPF, observability
(allow any_p self (bpf (map_create map_read map_write prog_load prog_run)))

; TODO: check if sys_admin is ok
; All caps
; All caps, except sys_boot and sys_modules
(allow any_p self (capability (
audit_control
audit_write
Expand All @@ -66,9 +65,7 @@
setpcap
setuid
sys_admin
sys_boot
sys_chroot
sys_module
sys_nice
sys_pacct
sys_ptrace
Expand Down Expand Up @@ -100,9 +97,7 @@
setpcap
setuid
sys_admin
sys_boot
sys_chroot
sys_module
sys_nice
sys_pacct
sys_ptrace
Expand Down Expand Up @@ -185,10 +180,8 @@
(allow any_p self (perf_event (open cpu kernel tracepoint read write)))
; Used by chromium, wine, other. Might be useful to disable to protect from kernel null-deref exploits
(allow any_p self (memprotect (mmap_zero)))
; TODO: kernel_service
; TODO: anon_inode
; TODO: override_creds?
(allow any_p self (io_uring (sqpoll cmd)))
; TODO: kernel_service, anon_inode
(allow any_p self (io_uring (sqpoll cmd override_creds)))
(allow any_p self (user_namespace (create)))

(allow pod_t pod_t (fs_classes (rw)))
Expand Down
1 change: 0 additions & 1 deletion selinux/services/cri.cil
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
(allow pod_p self (unix_stream_socket (connectto)))

; kube-proxy demands
; TODO: specifically /proc/sys/net
(allow pod_p proc_sysctl_t (fs_classes (rw)))
; comm="loopback"
(allow pod_p nsfs_t (fs_classes (ro)))
Expand Down
30 changes: 2 additions & 28 deletions selinux/services/kubelet.cil
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
(allow kubelet_t dbus_client_socket_t (sock_file (append getattr open write)))
(allow kubelet_t init_t (unix_stream_socket (connectto getattr)))

; D-Bus socket used for shutdown notification, owned by machined
; CRI socket
(allow kubelet_t pod_containerd_socket_t (sock_file (append getattr open write)))
(allow kubelet_t pod_containerd_t (unix_stream_socket (connectto getattr)))

; Read misc kernel properties
(allow kubelet_t proc_sysctl_t (fs_classes (ro)))

(allow kubelet_t self (capability2 (syslog)))

; Manage filesystem quotas and mounts
(allow kubelet_t filesystem_f (filesystem (
associate
Expand All @@ -43,33 +41,9 @@

; syslog
(allow kubelet_t kernel_t (system (syslog_read)))
(allow kubelet_t self (capability2 (syslog)))

; TODO: constrain
(allow kubelet_t device_f (fs_classes (rw)))
(allow kubelet_t sysfs_t (fs_classes (ro)))
(allow kubelet_t securityfs_t (fs_classes (ro)))

(allow kubelet_t kernel_t (fifo_file (write)))
(allow kubelet_t kernel_t (unix_stream_socket (connectto)))

; TODO: ensure all these
; mounts := []specs.Mount{
; {Type: "bind", Destination: "/dev", Source: "/dev", Options: []string{"rbind", "rshared", "rw"}},
; {Type: "sysfs", Destination: "/sys", Source: "/sys", Options: []string{"bind", "ro"}},
; {Type: "securityfs", Destination: "/sys/kernel/security", Source: "/sys/kernel/security", Options: []string{"bind", "ro"}},
; {Type: "bind", Destination: constants.CgroupMountPath, Source: constants.CgroupMountPath, Options: []string{"rbind", "rshared", "rw"}},
; {Type: "bind", Destination: "/lib/modules", Source: "/lib/modules", Options: []string{"bind", "ro"}},
; {Type: "bind", Destination: "/etc/kubernetes", Source: "/etc/kubernetes", Options: []string{"bind", "rshared", "rw"}},
; {Type: "bind", Destination: constants.KubeletCredentialProviderBinDir, Source: constants.KubeletCredentialProviderBinDir, Options: []string{"bind", "ro"}},
; {Type: "bind", Destination: "/etc/nfsmount.conf", Source: "/etc/nfsmount.conf", Options: []string{"bind", "ro"}},
; {Type: "bind", Destination: "/etc/machine-id", Source: "/etc/machine-id", Options: []string{"bind", "ro"}},
; {Type: "bind", Destination: "/etc/os-release", Source: "/etc/os-release", Options: []string{"bind", "ro"}},
; {Type: "bind", Destination: constants.PodResolvConfPath, Source: constants.PodResolvConfPath, Options: []string{"bind", "ro"}},
; {Type: "bind", Destination: "/etc/cni", Source: "/etc/cni", Options: []string{"rbind", "rshared", "rw"}},
; {Type: "bind", Destination: "/usr/libexec/kubernetes", Source: "/usr/libexec/kubernetes", Options: []string{"rbind", "rshared", "rw"}},
; {Type: "bind", Destination: "/var/run", Source: "/run", Options: []string{"rbind", "rshared", "rw"}},
; {Type: "bind", Destination: "/var/lib/containerd", Source: "/var/lib/containerd", Options: []string{"rbind", "rshared", "rw"}},
; {Type: "bind", Destination: "/var/lib/kubelet", Source: "/var/lib/kubelet", Options: []string{"rbind", "rshared", "rw"}},
; {Type: "bind", Destination: "/var/log/containers", Source: "/var/log/containers", Options: []string{"rbind", "rshared", "rw"}},
; {Type: "bind", Destination: "/var/log/pods", Source: "/var/log/pods", Options: []string{"rbind", "rshared", "rw"}},
; }
3 changes: 3 additions & 0 deletions selinux/services/machined.cil
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@

; Used during reboot probably
(allow init_t apid_t (unix_stream_socket (connectto)))

(allow any_p self (capability (sys_boot sys_module)))
(allow any_p self (cap_userns (sys_boot sys_module)))
4 changes: 4 additions & 0 deletions selinux/services/udev.cil
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

; TODO: other module locations? Special label?
(allow udev_t lib_t (system (module_load)))
(allow udev_t self (capability (sys_module)))
(allow udev_t self (cap_userns (sys_module)))

(type udev_socket_t)
(call system_socket_f (udev_socket_t))
Expand Down Expand Up @@ -73,5 +75,7 @@
(filecon "/sbin/modprobe" file (system_u object_r modprobe_exec_t (systemLow systemLow)))
(allow kernel_t modprobe_exec_t (file (execute_no_trans)))
(allow udev_t modprobe_exec_t (file (execute_no_trans)))
(allow kernel_t self (capability (sys_module)))
(allow kernel_t self (cap_userns (sys_module)))

(allow udev_t kernel_t (key (search)))

0 comments on commit 617f296

Please sign in to comment.