aboutgitcodebugslistschat
path: root/contrib/selinux
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/selinux')
-rw-r--r--contrib/selinux/passt-repair.te16
-rw-r--r--contrib/selinux/passt.te8
-rw-r--r--contrib/selinux/pasta.fc16
-rw-r--r--contrib/selinux/pasta.te60
-rw-r--r--contrib/selinux/pesto.fc11
-rw-r--r--contrib/selinux/pesto.te95
6 files changed, 186 insertions, 20 deletions
diff --git a/contrib/selinux/passt-repair.te b/contrib/selinux/passt-repair.te
index f171be6..7157dfb 100644
--- a/contrib/selinux/passt-repair.te
+++ b/contrib/selinux/passt-repair.te
@@ -61,11 +61,11 @@ allow passt_repair_t unconfined_t:unix_stream_socket { connectto read write };
allow passt_repair_t passt_t:unix_stream_socket { connectto read write };
allow passt_repair_t user_tmp_t:unix_stream_socket { connectto read write };
-allow passt_repair_t user_tmp_t:dir search;
+allow passt_repair_t user_tmp_t:dir { getattr read search watch };
-allow passt_repair_t unconfined_t:sock_file { read write };
-allow passt_repair_t passt_t:sock_file { read write };
-allow passt_repair_t user_tmp_t:sock_file { read write };
+allow passt_repair_t unconfined_t:sock_file { getattr read write };
+allow passt_repair_t passt_t:sock_file { getattr read write };
+allow passt_repair_t user_tmp_t:sock_file { getattr read write };
allow passt_repair_t unconfined_t:tcp_socket { read setopt write };
allow passt_repair_t passt_t:tcp_socket { read setopt write };
@@ -80,8 +80,8 @@ allow passt_repair_t passt_t:tcp_socket { read setopt write };
allow passt_repair_t qemu_var_run_t:unix_stream_socket { connectto read write };
allow passt_repair_t virt_var_run_t:unix_stream_socket { connectto read write };
-allow passt_repair_t qemu_var_run_t:dir search;
-allow passt_repair_t virt_var_run_t:dir search;
+allow passt_repair_t qemu_var_run_t:dir { getattr read search watch };
+allow passt_repair_t virt_var_run_t:dir { getattr read search watch };
-allow passt_repair_t qemu_var_run_t:sock_file { read write };
-allow passt_repair_t virt_var_run_t:sock_file { read write };
+allow passt_repair_t qemu_var_run_t:sock_file { getattr read write };
+allow passt_repair_t virt_var_run_t:sock_file { getattr read write };
diff --git a/contrib/selinux/passt.te b/contrib/selinux/passt.te
index f8ea672..6995df8 100644
--- a/contrib/selinux/passt.te
+++ b/contrib/selinux/passt.te
@@ -49,7 +49,7 @@ require {
type proc_net_t;
type node_t;
class tcp_socket { create accept listen name_bind name_connect getattr ioctl };
- class udp_socket { create accept listen };
+ class udp_socket { create accept listen getattr };
class icmp_socket { bind create name_bind node_bind setopt read write };
class sock_file { create unlink write };
@@ -110,8 +110,6 @@ allow passt_t self:user_namespace create;
auth_read_passwd(passt_t)
allow passt_t proc_net_t:file read;
-allow passt_t net_conf_t:file { open read };
-allow passt_t net_conf_t:lnk_file read;
allow passt_t tmp_t:sock_file { create unlink write };
allow passt_t self:netlink_route_socket { bind create nlmsg_read read write setopt };
kernel_search_network_sysctl(passt_t)
@@ -129,11 +127,13 @@ corenet_tcp_connect_all_ports(passt_t)
corenet_tcp_sendrecv_all_ports(passt_t)
corenet_udp_sendrecv_all_ports(passt_t)
+sysnet_read_config(passt_t)
+
allow passt_t node_t:icmp_socket { name_bind node_bind };
allow passt_t port_t:icmp_socket name_bind;
allow passt_t self:tcp_socket { create getopt setopt connect bind listen accept shutdown read write getattr ioctl };
-allow passt_t self:udp_socket { create getopt setopt connect bind read write };
+allow passt_t self:udp_socket { create getopt setopt connect bind read write getattr };
allow passt_t self:icmp_socket { bind create setopt read write };
allow passt_t user_tmp_t:dir { add_name write };
diff --git a/contrib/selinux/pasta.fc b/contrib/selinux/pasta.fc
index 41ee46d..82dbcbe 100644
--- a/contrib/selinux/pasta.fc
+++ b/contrib/selinux/pasta.fc
@@ -8,7 +8,15 @@
# Copyright (c) 2022 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com>
-/usr/bin/pasta system_u:object_r:pasta_exec_t:s0
-/usr/bin/pasta.avx2 system_u:object_r:pasta_exec_t:s0
-/tmp/pasta\.pcap system_u:object_r:pasta_log_t:s0
-/var/run/pasta\.pid system_u:object_r:pasta_pid_t:s0
+/usr/bin/pasta system_u:object_r:pasta_exec_t:s0
+/usr/bin/pasta.avx2 system_u:object_r:pasta_exec_t:s0
+/tmp/pasta\.pcap system_u:object_r:pasta_log_t:s0
+/var/run/pasta\.pid system_u:object_r:pasta_pid_t:s0
+/run/user/[0-9]+/netns system_u:object_r:ifconfig_var_run_t:s0
+/run/user/[0-9]+/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0
+# In case XDG_RUNTIME_DIR is not set (i.e. no systemd user session) Podman falls
+# back to a location under /tmp
+/tmp/storage-run-[0-9]+/netns system_u:object_r:ifconfig_var_run_t:s0
+/tmp/storage-run-[0-9]+/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0
+/tmp/containers-user-[0-9]+/netns system_u:object_r:ifconfig_var_run_t:s0
+/tmp/containers-user-[0-9]+/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0
diff --git a/contrib/selinux/pasta.te b/contrib/selinux/pasta.te
index 89c8043..9394f97 100644
--- a/contrib/selinux/pasta.te
+++ b/contrib/selinux/pasta.te
@@ -89,6 +89,16 @@ require {
class capability { sys_tty_config setuid setgid };
class cap_userns { setpcap sys_admin sys_ptrace net_bind_service net_admin };
class user_namespace create;
+
+ # Container requires
+ attribute_role usernetctl_roles;
+ role container_user_r;
+ role staff_r;
+ role user_r;
+ type container_runtime_t;
+ type container_var_run_t;
+ type container_t;
+ type systemd_user_runtimedir_t;
}
type pasta_t;
@@ -113,6 +123,9 @@ init_daemon_domain(pasta_t, pasta_exec_t)
allow pasta_t self:capability { setpcap net_bind_service sys_tty_config dac_read_search net_admin sys_resource setuid setgid };
allow pasta_t self:cap_userns { setpcap sys_admin sys_ptrace net_admin net_bind_service };
+# pasta only calls setuid and setgid with the current UID and GID, so this
+# denial is harmless. See https://bugzilla.redhat.com/show_bug.cgi?id=2330512#c10
+dontaudit pasta_t self:cap_userns { setgid setuid };
allow pasta_t self:user_namespace create;
auth_read_passwd(pasta_t)
@@ -130,13 +143,13 @@ allow pasta_t user_home_t:file { open read getattr setattr execute execute_no_tr
allow pasta_t user_home_dir_t:dir { search getattr open add_name read write };
allow pasta_t user_home_dir_t:file { create open read write };
allow pasta_t tmp_t:dir { add_name mounton remove_name write };
-allow pasta_t tmpfs_t:filesystem mount;
+allow pasta_t tmpfs_t:filesystem { getattr mount };
allow pasta_t fs_t:filesystem unmount;
allow pasta_t root_t:dir mounton;
manage_files_pattern(pasta_t, pasta_pid_t, pasta_pid_t)
files_pid_filetrans(pasta_t, pasta_pid_t, file)
-allow pasta_t user_tmp_t:dir { add_name remove_name search write };
+allow pasta_t user_tmp_t:dir { add_name open read remove_name search watch write };
allow pasta_t user_tmp_t:fifo_file append;
allow pasta_t user_tmp_t:file { create open write };
allow pasta_t user_tmp_t:sock_file { create unlink };
@@ -147,15 +160,22 @@ logging_send_syslog_msg(pasta_t)
allow syslogd_t self:cap_userns sys_ptrace;
allow pasta_t proc_net_t:file { open read };
-allow pasta_t net_conf_t:file { open read };
allow pasta_t self:netlink_route_socket { bind create nlmsg_read nlmsg_write setopt read write };
kernel_search_network_sysctl(pasta_t)
+sysnet_read_config(pasta_t)
+
allow pasta_t tmp_t:sock_file { create unlink write };
allow pasta_t self:tcp_socket create_stream_socket_perms;
corenet_tcp_sendrecv_generic_node(pasta_t)
corenet_tcp_bind_generic_node(pasta_t)
+allow pasta_t container_runtime_t:dir { open read search };
+allow pasta_t container_runtime_t:fifo_file { getattr write };
+allow pasta_t container_runtime_t:file read;
+allow pasta_t container_runtime_t:lnk_file read;
+allow pasta_t container_t:lnk_file read;
+allow pasta_t container_t:dir { open read search };
allow pasta_t pasta_port_t:tcp_socket { name_bind name_connect };
allow pasta_t pasta_port_t:udp_socket { name_bind };
allow pasta_t http_port_t:tcp_socket { name_bind name_connect };
@@ -204,7 +224,6 @@ allow pasta_t kernel_t:system module_request;
allow pasta_t proc_t:dir mounton;
allow pasta_t proc_t:filesystem mount;
-allow pasta_t net_conf_t:lnk_file read;
allow pasta_t proc_net_t:lnk_file read;
allow pasta_t unconfined_t:process { noatsecure rlimitinh siginh };
@@ -213,3 +232,36 @@ allow pasta_t netutils_t:process { noatsecure rlimitinh siginh };
allow pasta_t ping_t:process { noatsecure rlimitinh siginh };
allow pasta_t user_tty_device_t:chr_file { append read write };
allow pasta_t user_devpts_t:chr_file { append read write };
+
+# Allow network administration commands for non-privileged users
+roleattribute container_user_r usernetctl_roles;
+roleattribute staff_r usernetctl_roles;
+roleattribute user_r usernetctl_roles;
+role usernetctl_roles types pasta_t;
+
+# Make pasta in a container run under the pasta_t context
+type_transition container_runtime_t pasta_exec_t : process pasta_t;
+allow container_runtime_t pasta_t:process transition;
+
+# Label the user network namespace files
+# Note: Podman files used to be user_tmp_t but are now container_var_run_t since
+# https://github.com/containers/container-selinux/pull/405
+type_transition container_runtime_t user_tmp_t : dir ifconfig_var_run_t "netns";
+type_transition container_runtime_t container_var_run_t : dir ifconfig_var_run_t "netns";
+type_transition container_runtime_t user_tmp_t : dir ifconfig_var_run_t "rootless-netns";
+type_transition container_runtime_t container_var_run_t : dir ifconfig_var_run_t "rootless-netns";
+allow pasta_t container_var_run_t:dir { add_name open read rmdir write };
+allow pasta_t ifconfig_var_run_t:dir { add_name open read rmdir write };
+allow pasta_t container_var_run_t:file { create open read write };
+allow pasta_t ifconfig_var_run_t:file { create open read write };
+allow pasta_t container_var_run_t:sock_file { getattr create open read write };
+allow pasta_t ifconfig_var_run_t:sock_file { getattr create open read write };
+allow systemd_user_runtimedir_t ifconfig_var_run_t:dir rmdir;
+
+# Allow pasta to bind to any port
+bool pasta_bind_all_ports true;
+if (pasta_bind_all_ports) {
+ allow pasta_t port_type:icmp_socket { accept getopt name_bind };
+ allow pasta_t port_type:tcp_socket { accept getopt name_bind name_connect };
+ allow pasta_t port_type:udp_socket { accept getopt name_bind };
+}
diff --git a/contrib/selinux/pesto.fc b/contrib/selinux/pesto.fc
new file mode 100644
index 0000000..7ec4d87
--- /dev/null
+++ b/contrib/selinux/pesto.fc
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# PESTO - Programmable Extensible Socket Translation Orchestrator
+# front-end for passt(1) and pasta(1) forwarding configuration
+#
+# contrib/selinux/pesto.fc - SELinux: File Context for pesto
+#
+# Copyright (c) 2026 Red Hat GmbH
+# Author: Stefano Brivio <sbrivio@redhat.com>
+
+/usr/bin/pesto system_u:object_r:pesto_exec_t:s0
diff --git a/contrib/selinux/pesto.te b/contrib/selinux/pesto.te
new file mode 100644
index 0000000..991833a
--- /dev/null
+++ b/contrib/selinux/pesto.te
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# PESTO - Programmable Extensible Socket Translation Orchestrator
+# front-end for passt(1) and pasta(1) forwarding configuration
+#
+# contrib/selinux/pesto.te - SELinux: Type Enforcement for pesto
+#
+# Copyright (c) 2026 Red Hat GmbH
+# Author: Stefano Brivio <sbrivio@redhat.com>
+
+policy_module(pesto, 0.1)
+
+require {
+ type unconfined_t;
+ type passt_t;
+ type pasta_t;
+ role unconfined_r;
+ class process transition;
+
+ class file { read execute execute_no_trans entrypoint open map };
+ class capability { dac_override dac_read_search };
+ class chr_file { append open getattr read write ioctl };
+
+ type net_conf_t;
+ type proc_net_t;
+ type sysctl_net_t;
+
+ class unix_stream_socket { create connect sendto };
+ class sock_file { read write };
+
+ type console_device_t;
+ type user_devpts_t;
+ type user_tmp_t;
+ type tmp_t;
+
+ # Workaround: pesto needs to needs to access socket files
+ # that passt, started by libvirt, might create under different
+ # labels, depending on whether passt is started as root or not.
+ #
+ # However, libvirt doesn't maintain its own policy, which makes
+ # updates particularly complicated. To avoid breakage in the short
+ # term, deal with that in passt's own policy.
+ type qemu_var_run_t;
+ type virt_var_run_t;
+}
+
+type pesto_t;
+domain_type(pesto_t);
+type pesto_exec_t;
+corecmd_executable_file(pesto_exec_t);
+
+role unconfined_r types pesto_t;
+
+allow pesto_t pesto_exec_t:file { read execute execute_no_trans entrypoint open map };
+type_transition unconfined_t pesto_exec_t:process pesto_t;
+allow unconfined_t pesto_t:process transition;
+
+allow pesto_t self:capability { dac_override dac_read_search };
+
+allow pesto_t proc_net_t:file read;
+kernel_search_network_sysctl(pesto_t)
+allow pesto_t sysctl_net_t:dir search;
+allow pesto_t sysctl_net_t:file { open read };
+
+allow pesto_t console_device_t:chr_file { append open getattr read write ioctl };
+allow pesto_t user_devpts_t:chr_file { append open getattr read write ioctl };
+
+allow pesto_t unconfined_t:unix_stream_socket { connectto read write };
+allow pesto_t passt_t:unix_stream_socket { connectto read write };
+allow pesto_t pasta_t:unix_stream_socket { connectto read write };
+allow pesto_t user_tmp_t:unix_stream_socket { connectto read write };
+
+allow pesto_t user_tmp_t:dir { getattr read search watch };
+
+allow pesto_t unconfined_t:sock_file { getattr read write };
+allow pesto_t passt_t:sock_file { getattr read write };
+allow pesto_t pasta_t:sock_file { getattr read write };
+allow pesto_t user_tmp_t:sock_file { getattr read write };
+allow pesto_t tmp_t:sock_file { getattr read write };
+
+# Workaround: pesto needs to needs to access socket files
+# that passt, started by libvirt, might create under different
+# labels, depending on whether passt is started as root or not.
+#
+# However, libvirt doesn't maintain its own policy, which makes
+# updates particularly complicated. To avoid breakage in the short
+# term, deal with that in passt's own policy.
+allow pesto_t qemu_var_run_t:unix_stream_socket { connectto read write };
+allow pesto_t virt_var_run_t:unix_stream_socket { connectto read write };
+
+allow pesto_t qemu_var_run_t:dir { getattr read search watch };
+allow pesto_t virt_var_run_t:dir { getattr read search watch };
+
+allow pesto_t qemu_var_run_t:sock_file { getattr read write };
+allow pesto_t virt_var_run_t:sock_file { getattr read write };