[selinux-policy: 1223/3172] add uml, plus two renames in corenet

Daniel J Walsh dwalsh at fedoraproject.org
Thu Oct 7 20:50:52 UTC 2010


commit 5b6ddb9888105257e4d64da986e5e66814f037e2
Author: Chris PeBenito <cpebenito at tresys.com>
Date:   Thu Feb 16 21:33:18 2006 +0000

    add uml, plus two renames in corenet

 refpolicy/policy/modules/admin/vpn.te             |    2 +-
 refpolicy/policy/modules/apps/uml.fc              |   13 +
 refpolicy/policy/modules/apps/uml.if              |  267 +++++++++++++++++++++
 refpolicy/policy/modules/apps/uml.te              |   76 ++++++
 refpolicy/policy/modules/kernel/corenetwork.if.in |    4 +-
 refpolicy/policy/modules/services/nscd.te         |    2 +-
 refpolicy/policy/modules/services/ppp.te          |    2 +-
 refpolicy/policy/modules/system/init.te           |    6 +-
 refpolicy/policy/modules/system/sysnetwork.te     |    2 +-
 refpolicy/policy/modules/system/userdomain.if     |    2 +-
 10 files changed, 368 insertions(+), 8 deletions(-)
---
diff --git a/refpolicy/policy/modules/admin/vpn.te b/refpolicy/policy/modules/admin/vpn.te
index c2eeaf8..3e59ad2 100644
--- a/refpolicy/policy/modules/admin/vpn.te
+++ b/refpolicy/policy/modules/admin/vpn.te
@@ -62,7 +62,7 @@ corenet_udp_bind_all_nodes(vpnc_t)
 corenet_udp_bind_generic_port(vpnc_t)
 corenet_udp_bind_isakmp_port(vpnc_t)
 corenet_tcp_connect_all_ports(vpnc_t)
-corenet_use_tun_tap_device(vpnc_t)
+corenet_rw_tun_tap_dev(vpnc_t)
 
 dev_read_rand(vpnc_t)
 dev_read_urand(vpnc_t)
diff --git a/refpolicy/policy/modules/apps/uml.fc b/refpolicy/policy/modules/apps/uml.fc
new file mode 100644
index 0000000..2a4afa0
--- /dev/null
+++ b/refpolicy/policy/modules/apps/uml.fc
@@ -0,0 +1,13 @@
+#
+# /usr
+#
+/usr/bin/uml_switch	--	gen_context(system_u:object_r:uml_switch_exec_t,s0)
+
+#
+# /var
+#
+/var/run/uml-utilities(/.*)?	gen_context(system_u:object_r:uml_switch_var_run_t,s0)
+
+ifdef(`strict_policy',`
+	HOME_DIR/\.uml(/.*)?		gen_context(system_u:object_r:ROLE_uml_rw_t,s0)
+')
diff --git a/refpolicy/policy/modules/apps/uml.if b/refpolicy/policy/modules/apps/uml.if
new file mode 100644
index 0000000..c6d9e62
--- /dev/null
+++ b/refpolicy/policy/modules/apps/uml.if
@@ -0,0 +1,267 @@
+## <summary>Policy for UML</summary>
+	
+#######################################
+## <summary>
+##	The per user domain template for the uml module.
+## </summary>
+## <desc>
+##	<p>
+##	This template creates a derived domains which are used
+##	for uml program.
+##	</p>
+##	<p>
+##	This template is invoked automatically for each user, and
+##	generally does not need to be invoked directly
+##	by policy writers.
+##	</p>
+## </desc>
+## <param name="userdomain_prefix">
+##	<summary>
+##	The prefix of the user domain (e.g., user
+##	is the prefix for user_t).
+##	</summary>
+## </param>
+## <param name="user_domain">
+##	<summary>
+##	The type of the user domain.
+##	</summary>
+## </param>
+## <param name="user_role">
+##	<summary>
+##	The role associated with the user domain.
+##	</summary>
+## </param>
+#
+template(`uml_per_userdomain_template',`
+	
+	########################################
+	#
+	# Declarations
+	#
+	type $1_uml_t;
+	domain_type($1_uml_t)
+	role $3 types $1_uml_t;
+
+	type $1_uml_exec_t;
+	domain_entry_file($1_uml_t,$1_uml_exec_t)
+
+	type $1_uml_ro_t;
+	files_type($1_uml_ro_t)
+
+	type $1_uml_rw_t;
+	files_type($1_uml_rw_t)
+
+	type $1_uml_tmp_t;
+	files_tmp_file($1_uml_tmp_t)
+
+	type $1_uml_tmpfs_t;
+	files_tmpfs_file($1_uml_tmpfs_t)
+
+	type $1_uml_devpts_t;
+	term_pty($1_uml_devpts_t)
+
+	########################################
+	#
+	# Local policy
+	#
+	allow $1_uml_t self:fifo_file rw_file_perms;
+	allow $1_uml_t self:process { fork signal_perms ptrace };
+	allow $1_uml_t self:unix_stream_socket create_stream_socket_perms;
+	allow $1_uml_t self:unix_dgram_socket create_socket_perms;
+	# Use the network.
+	allow $1_uml_t self:tcp_socket create_stream_socket_perms;
+	allow $1_uml_t self:udp_socket create_socket_perms;
+
+	allow $1_uml_t $2:process sigchld;
+	allow $1_uml_t $2:fifo_file { ioctl read write getattr lock append };
+
+	# allow the UML thing to happen
+	allow $1_uml_t $1_uml_devpts_t:chr_file { rw_file_perms setattr };
+	term_create_pty($1_uml_t,$1_uml_devpts_t)
+
+	allow $1_uml_t $1_uml_tmp_t:dir create_dir_perms;
+	allow $1_uml_t $1_uml_tmp_t:file create_file_perms;
+	files_filetrans_tmp($1_uml_t, $1_uml_tmp_t, { file dir })
+	can_exec($1_uml_t, $1_uml_tmp_t)
+
+	allow $1_uml_t $1_uml_tmpfs_t:dir { read getattr lock search ioctl add_name remove_name write };
+	allow $1_uml_t $1_uml_tmpfs_t:file { create ioctl read getattr lock write setattr append link unlink rename };
+	allow $1_uml_t $1_uml_tmpfs_t:lnk_file { create read getattr setattr link unlink rename };
+	allow $1_uml_t $1_uml_tmpfs_t:sock_file { create ioctl read getattr lock write setattr append link unlink rename };
+	allow $1_uml_t $1_uml_tmpfs_t:fifo_file { create ioctl read getattr lock write setattr append link unlink rename };
+	fs_filetrans_tmpfs($1_uml_t,$1_uml_tmpfs_t,{ dir file lnk_file sock_file fifo_file })
+	can_exec($1_uml_t, $1_uml_tmpfs_t)
+
+	# access config files
+	allow $1_uml_t { $1_uml_ro_t uml_ro_t }:dir r_dir_perms;
+	allow $1_uml_t { $1_uml_ro_t uml_ro_t }:file r_file_perms;
+	allow $1_uml_t { $1_uml_ro_t uml_ro_t }:lnk_file { getattr read };
+
+	allow $1_uml_t $1_uml_rw_t:dir create_dir_perms;
+	allow $1_uml_t $1_uml_rw_t:file create_file_perms;
+	allow $1_uml_t $1_uml_rw_t:lnk_file create_lnk_perms;
+	allow $1_uml_t $1_uml_rw_t:sock_file create_file_perms;
+	allow $1_uml_t $1_uml_rw_t:fifo_file create_file_perms;
+	userdom_filetrans_user_home_dir($1,$1_uml_t,$1_uml_rw_t,{ file lnk_file sock_file fifo_file })
+
+	allow $2 uml_ro_t:dir r_dir_perms;
+	allow $2 uml_ro_t:file r_file_perms;
+	allow $2 uml_ro_t:lnk_file { getattr read };
+
+	allow $2 { $1_uml_ro_t $1_uml_rw_t }:{ file sock_file fifo_file } { relabelfrom relabelto create_file_perms };
+	allow $2 { $1_uml_ro_t $1_uml_rw_t }:lnk_file { relabelfrom relabelto create_lnk_perms };
+	allow $2 { $1_uml_ro_t $1_uml_rw_t $1_uml_exec_t }:dir { relabelfrom relabelto create_dir_perms };
+	allow $2 $1_uml_exec_t:file { relabelfrom relabelto create_file_perms };
+
+	allow $2 $1_uml_t:process ptrace;
+	allow $2 $1_uml_t:process signal_perms;
+
+	# allow ps, ptrace, signal
+	allow $2 $1_uml_t:dir { search getattr read };
+	allow $2 $1_uml_t:{ file lnk_file } { read getattr };
+	allow $2 $1_uml_t:process getattr;
+	# We need to suppress this denial because procps tries to access
+	# /proc/pid/environ and this now triggers a ptrace check in recent kernels
+	# (2.4 and 2.6).  Might want to change procps to not do this, or only if
+	# running in a privileged domain.
+	dontaudit $2 $1_uml_t:process ptrace;
+
+	allow $2 $1_uml_tmp_t:dir create_dir_perms;
+	allow $2 $1_uml_tmp_t:file create_file_perms;
+	allow $2 $1_uml_tmp_t:lnk_file create_lnk_perms;
+	allow $2 $1_uml_tmp_t:sock_file create_file_perms;
+
+	# Transition from the user domain to this domain.
+	domain_auto_trans($2, { uml_exec_t $1_uml_exec_t }, $1_uml_t)
+	can_exec($1_uml_t, { uml_exec_t $1_uml_exec_t })
+
+	# for mconsole
+	allow { $2 $1_uml_t } $1_uml_t:unix_dgram_socket sendto;
+	allow $1_uml_t $2:unix_dgram_socket sendto;
+	
+	kernel_read_system_state($1_uml_t)
+	# for SKAS - need something better
+	kernel_write_proc_files($1_uml_t)
+
+	# for xterm
+	corecmd_exec_bin($1_uml_t)
+	corecmd_exec_sbin($1_uml_t)
+
+	corenet_tcp_sendrecv_generic_if($1_uml_t)
+	corenet_udp_sendrecv_generic_if($1_uml_t)
+	corenet_raw_sendrecv_generic_if($1_uml_t)
+	corenet_tcp_sendrecv_all_nodes($1_uml_t)
+	corenet_udp_sendrecv_all_nodes($1_uml_t)
+	corenet_raw_sendrecv_all_nodes($1_uml_t)
+	corenet_tcp_sendrecv_all_ports($1_uml_t)
+	corenet_udp_sendrecv_all_ports($1_uml_t)
+	corenet_non_ipsec_sendrecv($1_uml_t)
+	corenet_tcp_bind_all_nodes($1_uml_t)
+	corenet_udp_bind_all_nodes($1_uml_t)
+	corenet_tcp_connect_all_ports($1_uml_t)
+	corenet_rw_tun_tap_dev($1_uml_t)
+	
+	domain_use_wide_inherit_fd($1_uml_t)
+
+	# for xterm
+	files_read_etc_files($1_uml_t)
+	files_dontaudit_read_etc_runtime_files($1_uml_t)
+	# putting uml data under /var is usual...
+	files_search_var($1_uml_t)
+
+	fs_getattr_xattr_fs($1_uml_t)
+
+	init_read_utmp($1_uml_t)
+	init_dontaudit_write_utmp($1_uml_t)
+
+	# for xterm
+	libs_use_ld_so($1_uml_t)
+	libs_use_shared_libs($1_uml_t)
+	libs_exec_lib_files($1_uml_t)
+
+	# Inherit and use descriptors from newrole.
+	seutil_use_newrole_fd($1_uml_t)
+
+	# Use the network.
+	sysnet_read_config($1_uml_t)
+
+	userdom_use_user_terminals($1,$1_uml_t)
+
+	optional_policy(`mount',`
+		mount_send_nfs_client_request($1_uml_t)
+	')
+
+	optional_policy(`nis',`
+		nis_use_ypbind($1_uml_t)
+	')
+
+	optional_policy(`ssh',`	
+		ssh_tcp_connect($1_uml_t)
+	')
+	
+	ifdef(`TODO',`
+		# for X
+		optional_policy(`startx',`
+			ifelse($1, sysadm,`
+			',`
+				optional_policy(`xdm',`
+					allow $1_uml_t xdm_xserver_tmp_t:dir search;
+				')
+				allow $1_uml_t $1_xserver_tmp_t:sock_file write;
+				allow $1_uml_t $1_xserver_t:unix_stream_socket connectto;
+			')
+		')
+
+		optional_policy(`uml_net.te',`
+			# for uml_net
+			domain_auto_trans($1_uml_t, uml_net_exec_t, uml_net_t)
+			allow uml_net_t $1_uml_t:unix_stream_socket { read write };
+			allow uml_net_t $1_uml_t:unix_dgram_socket { read write };
+			dontaudit uml_net_t privfd:fd use;
+			can_access_pty(uml_net_t, $1_uml)
+			dontaudit uml_net_t $1_uml_rw_t:dir { getattr search };
+		')
+		#TODO
+		optional_policy(`xauth',`
+			allow $1_uml_t $1_xauth_home_t:file { getattr read };
+		')
+	')
+')
+
+########################################
+## <summary>
+##	Set attributes on uml utility socket files.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`uml_setattr_util_sockets',`
+	gen_require(`
+		type uml_switch_var_run_t;
+	')
+
+	allow $1 uml_switch_var_run_t:sock_file setattr;
+')
+
+########################################
+## <summary>
+##	Manage uml utility files.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`uml_manage_util_files',`
+	gen_require(`
+		type uml_switch_var_run_t;
+	')
+
+	allow $1 uml_switch_var_run_t:dir rw_dir_perms;
+	allow $1 uml_switch_var_run_t:file create_file_perms;
+	allow $1 uml_switch_var_run_t:lnk_file create_lnk_perms;
+')
diff --git a/refpolicy/policy/modules/apps/uml.te b/refpolicy/policy/modules/apps/uml.te
new file mode 100644
index 0000000..576c1e8
--- /dev/null
+++ b/refpolicy/policy/modules/apps/uml.te
@@ -0,0 +1,76 @@
+
+policy_module(uml,1.0.0)
+
+########################################
+#
+# Declarations
+#
+
+type uml_exec_t;
+files_type(uml_exec_t)
+
+type uml_ro_t;
+files_type(uml_ro_t)
+
+type uml_switch_t;
+type uml_switch_exec_t;
+init_daemon_domain(uml_switch_t,uml_switch_exec_t)
+
+type uml_switch_var_run_t;
+files_pid_file(uml_switch_var_run_t)
+
+########################################
+#
+# Local policy
+#
+
+dontaudit uml_switch_t self:capability sys_tty_config;
+allow uml_switch_t self:process signal_perms;
+allow uml_switch_t self:unix_dgram_socket create_socket_perms;
+allow uml_switch_t self:unix_stream_socket create_stream_socket_perms;
+
+allow uml_switch_t uml_switch_var_run_t:sock_file create_file_perms;
+allow uml_switch_t uml_switch_var_run_t:file create_file_perms;
+allow uml_switch_t uml_switch_var_run_t:dir rw_dir_perms;
+files_filetrans_pid(uml_switch_t,uml_switch_var_run_t,file)
+
+kernel_read_kernel_sysctls(uml_switch_t)
+kernel_list_proc(uml_switch_t)
+kernel_read_proc_symlinks(uml_switch_t)
+
+dev_read_sysfs(uml_switch_t)
+
+domain_use_wide_inherit_fd(uml_switch_t)
+
+fs_getattr_all_fs(uml_switch_t)
+fs_search_auto_mountpoints(uml_switch_t)
+
+term_dontaudit_use_console(uml_switch_t)
+
+init_use_fd(uml_switch_t)
+init_use_script_ptys(uml_switch_t)
+
+libs_use_ld_so(uml_switch_t)
+libs_use_shared_libs(uml_switch_t)
+
+logging_send_syslog_msg(uml_switch_t)
+
+miscfiles_read_localization(uml_switch_t)
+
+userdom_dontaudit_use_unpriv_user_fd(uml_switch_t)
+userdom_dontaudit_search_sysadm_home_dir(uml_switch_t)
+
+ifdef(`targeted_policy',`
+	files_dontaudit_read_root_files(uml_switch_t)
+
+	term_dontaudit_use_unallocated_ttys(uml_switch_t)
+	term_dontaudit_use_generic_ptys(uml_switch_t)
+')
+
+optional_policy(`selinuxutil',`
+	seutil_sigchld_newrole(uml_switch_t)
+')
+
+optional_policy(`udev',`
+	udev_read_db(uml_switch_t)
+')
diff --git a/refpolicy/policy/modules/kernel/corenetwork.if.in b/refpolicy/policy/modules/kernel/corenetwork.if.in
index bf0c4e7..c02492c 100644
--- a/refpolicy/policy/modules/kernel/corenetwork.if.in
+++ b/refpolicy/policy/modules/kernel/corenetwork.if.in
@@ -1161,7 +1161,7 @@ interface(`corenet_dontaudit_tcp_connect_all_reserved_ports',`
 ##	</summary>
 ## </param>
 #
-interface(`corenet_use_tun_tap_device',`
+interface(`corenet_rw_tun_tap_dev',`
 	gen_require(`
 		type tun_tap_device_t;
 	')
@@ -1180,7 +1180,7 @@ interface(`corenet_use_tun_tap_device',`
 ##	</summary>
 ## </param>
 #
-interface(`corenet_use_ppp_device',`
+interface(`corenet_rw_ppp_dev',`
 	gen_require(`
 		type ppp_device_t;
 	')
diff --git a/refpolicy/policy/modules/services/nscd.te b/refpolicy/policy/modules/services/nscd.te
index 4b16aab..557259c 100644
--- a/refpolicy/policy/modules/services/nscd.te
+++ b/refpolicy/policy/modules/services/nscd.te
@@ -80,7 +80,7 @@ corenet_non_ipsec_sendrecv(nscd_t)
 corenet_tcp_bind_all_nodes(nscd_t)
 corenet_udp_bind_all_nodes(nscd_t)
 corenet_tcp_connect_all_ports(nscd_t)
-corenet_use_tun_tap_device(nscd_t)
+corenet_rw_tun_tap_dev(nscd_t)
 
 selinux_get_fs_mount(nscd_t)
 selinux_validate_context(nscd_t)
diff --git a/refpolicy/policy/modules/services/ppp.te b/refpolicy/policy/modules/services/ppp.te
index 274fd73..93ebf4d 100644
--- a/refpolicy/policy/modules/services/ppp.te
+++ b/refpolicy/policy/modules/services/ppp.te
@@ -129,7 +129,7 @@ corenet_non_ipsec_sendrecv(pppd_t)
 corenet_tcp_bind_all_nodes(pppd_t)
 corenet_udp_bind_all_nodes(pppd_t)
 # Access /dev/ppp.
-corenet_use_ppp_device(pppd_t)
+corenet_rw_ppp_dev(pppd_t)
 
 fs_getattr_all_fs(pppd_t)
 fs_search_auto_mountpoints(pppd_t)
diff --git a/refpolicy/policy/modules/system/init.te b/refpolicy/policy/modules/system/init.te
index a66c750..233b778 100644
--- a/refpolicy/policy/modules/system/init.te
+++ b/refpolicy/policy/modules/system/init.te
@@ -1,5 +1,5 @@
 
-policy_module(init,1.2.3)
+policy_module(init,1.2.4)
 
 gen_require(`
 	class passwd rootok;
@@ -685,6 +685,10 @@ optional_policy(`sysnetwork',`
 	sysnet_read_dhcpc_state(initrc_t)
 ')
 
+optional_policy(`uml',`
+	uml_setattr_util_sockets(initrc_t)
+')
+
 optional_policy(`xfs',`
 	miscfiles_manage_fonts(initrc_t)
 
diff --git a/refpolicy/policy/modules/system/sysnetwork.te b/refpolicy/policy/modules/system/sysnetwork.te
index 0a97e5f..e8a4eee 100644
--- a/refpolicy/policy/modules/system/sysnetwork.te
+++ b/refpolicy/policy/modules/system/sysnetwork.te
@@ -282,7 +282,7 @@ kernel_read_system_state(ifconfig_t)
 kernel_read_network_state(ifconfig_t)
 kernel_search_network_sysctl(ifconfig_t)
 
-corenet_use_tun_tap_device(ifconfig_t)
+corenet_rw_tun_tap_dev(ifconfig_t)
 
 dev_read_sysfs(ifconfig_t)
 
diff --git a/refpolicy/policy/modules/system/userdomain.if b/refpolicy/policy/modules/system/userdomain.if
index cef0ee7..2d3471f 100644
--- a/refpolicy/policy/modules/system/userdomain.if
+++ b/refpolicy/policy/modules/system/userdomain.if
@@ -824,7 +824,7 @@ template(`admin_user_template',`
 
 	corenet_tcp_bind_generic_port($1_t)
 	# allow setting up tunnels
-	corenet_use_tun_tap_device($1_t)
+	corenet_rw_tun_tap_dev($1_t)
 
 	dev_getattr_generic_blk_files($1_t)
 	dev_getattr_generic_chr_files($1_t)


More information about the scm-commits mailing list