[DSE-Dev] Bug#668954: not a serious bug, just a new feature that doesn't work.

Russell Coker russell at coker.com.au
Tue Jun 26 06:53:39 UTC 2012


severity 668954 minor
thanks

I can't get the policy for this written for Wheezy.  I've attached a policy 
patch for a work in progress so anyone who is interested can work on it for 
their own purposes.

I'll get this going post-Wheezy with a new policy tree from upstream.  For 
Wheezy I think I'll just remove the sandbox program from policycoreutils as 
there's no way of making it do anything useful.

This isn't an important issue as it's a new feature that has never worked.  
Everything else in policycoreutils has worked well without this and will 
continue to work without it.

-- 
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/
-------------- next part --------------
Description: Add sandbox support for the sandbox utility from policycoreutils
Author: Russell Coker <russell at coker.com.au>
Origin: Fedora
Last-Update: 2012-06-26

Index: refpolicy-2.20110726/policy/modules/apps/sandbox.te
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ refpolicy-2.20110726/policy/modules/apps/sandbox.te	2012-06-26 15:58:56.353278656 +1000
@@ -0,0 +1,509 @@
+policy_module(sandbox,1.0.0)
+
+dbus_stub()
+attribute sandbox_domain;
+attribute sandbox_x_domain;
+attribute sandbox_web_type;
+attribute sandbox_file_type;
+attribute sandbox_tmpfs_type;
+attribute sandbox_type;
+
+type sandbox_exec_t;
+files_type(sandbox_exec_t)
+
+type sandbox_file_t, sandbox_file_type;
+files_type(sandbox_file_t)
+typealias sandbox_file_t alias { sandbox_x_file_t sandbox_web_file_t sandbox_net_file_t sandbox_min_file_t };
+
+########################################
+#
+# Declarations
+#
+
+sandbox_domain_template(sandbox)
+sandbox_x_domain_template(sandbox_min)
+sandbox_x_domain_template(sandbox_x)
+sandbox_x_domain_template(sandbox_web)
+sandbox_x_domain_template(sandbox_net)
+
+type sandbox_xserver_t;
+domain_type(sandbox_xserver_t)
+xserver_user_x_domain_template(sandbox_xserver, sandbox_xserver_t, sandbox_xserver_tmpfs_t)
+
+type sandbox_xserver_tmpfs_t;
+files_tmpfs_file(sandbox_xserver_tmpfs_t)
+
+type sandbox_devpts_t;
+term_pty(sandbox_devpts_t)
+files_type(sandbox_devpts_t)
+
+########################################
+#
+# sandbox xserver policy
+#
+allow sandbox_xserver_t self:process { signal_perms execstack };
+
+tunable_policy(`deny_execmem',`',`
+	allow sandbox_xserver_t self:process execmem;
+')
+
+allow sandbox_xserver_t self:fifo_file manage_fifo_file_perms;
+allow sandbox_xserver_t self:shm create_shm_perms;
+allow sandbox_xserver_t self:tcp_socket create_stream_socket_perms;
+
+manage_dirs_pattern(sandbox_xserver_t, sandbox_file_t, sandbox_file_t)
+manage_files_pattern(sandbox_xserver_t, sandbox_file_t, sandbox_file_t)
+manage_sock_files_pattern(sandbox_xserver_t, sandbox_file_t, sandbox_file_t)
+allow sandbox_xserver_t sandbox_file_t:sock_file create_sock_file_perms;
+
+manage_dirs_pattern(sandbox_xserver_t, sandbox_xserver_tmpfs_t, sandbox_xserver_tmpfs_t)
+manage_files_pattern(sandbox_xserver_t, sandbox_xserver_tmpfs_t, sandbox_xserver_tmpfs_t)
+manage_lnk_files_pattern(sandbox_xserver_t, sandbox_xserver_tmpfs_t, sandbox_xserver_tmpfs_t)
+manage_fifo_files_pattern(sandbox_xserver_t, sandbox_xserver_tmpfs_t, sandbox_xserver_tmpfs_t)
+manage_sock_files_pattern(sandbox_xserver_t, sandbox_xserver_tmpfs_t, sandbox_xserver_tmpfs_t)
+fs_tmpfs_filetrans(sandbox_xserver_t, sandbox_xserver_tmpfs_t, { dir file lnk_file sock_file fifo_file })
+
+kernel_dontaudit_request_load_module(sandbox_xserver_t)
+kernel_read_system_state(sandbox_xserver_t)
+
+corecmd_exec_bin(sandbox_xserver_t)
+corecmd_exec_shell(sandbox_xserver_t)
+
+corenet_all_recvfrom_unlabeled(sandbox_xserver_t)
+corenet_all_recvfrom_netlabel(sandbox_xserver_t)
+corenet_tcp_sendrecv_generic_if(sandbox_xserver_t)
+corenet_udp_sendrecv_generic_if(sandbox_xserver_t)
+corenet_tcp_sendrecv_generic_node(sandbox_xserver_t)
+corenet_udp_sendrecv_generic_node(sandbox_xserver_t)
+corenet_tcp_sendrecv_all_ports(sandbox_xserver_t)
+corenet_udp_sendrecv_all_ports(sandbox_xserver_t)
+corenet_tcp_bind_generic_node(sandbox_xserver_t)
+corenet_tcp_bind_xserver_port(sandbox_xserver_t)
+corenet_sendrecv_xserver_server_packets(sandbox_xserver_t)
+corenet_sendrecv_all_client_packets(sandbox_xserver_t)
+
+dev_read_sysfs(sandbox_xserver_t)
+dev_rwx_zero(sandbox_xserver_t)
+dev_read_urand(sandbox_xserver_t)
+
+domain_use_interactive_fds(sandbox_xserver_t)
+
+files_read_config_files(sandbox_xserver_t)
+files_read_usr_files(sandbox_xserver_t)
+files_search_home(sandbox_xserver_t)
+fs_dontaudit_rw_tmpfs_files(sandbox_xserver_t)
+fs_list_inotifyfs(sandbox_xserver_t)
+fs_search_auto_mountpoints(sandbox_xserver_t)
+
+miscfiles_read_fonts(sandbox_xserver_t)
+miscfiles_read_localization(sandbox_xserver_t)
+
+selinux_validate_context(sandbox_xserver_t)
+selinux_compute_access_vector(sandbox_xserver_t)
+selinux_compute_create_context(sandbox_xserver_t)
+
+auth_use_nsswitch(sandbox_xserver_t)
+
+logging_send_syslog_msg(sandbox_xserver_t)
+logging_send_audit_msgs(sandbox_xserver_t)
+
+userdom_use_inherited_user_terminals(sandbox_xserver_t)
+userdom_dontaudit_search_user_home_content(sandbox_xserver_t)
+userdom_dontaudit_rw_user_tmp_pipes(sandbox_xserver_t)
+
+xserver_entry_type(sandbox_xserver_t)
+
+optional_policy(`
+	dbus_system_bus_client(sandbox_xserver_t)
+
+	optional_policy(`
+		hal_dbus_chat(sandbox_xserver_t)
+	')
+')
+
+########################################
+#
+# sandbox local policy
+#
+
+allow sandbox_domain self:process { getattr signal_perms getsched setsched setpgid execstack };
+tunable_policy(`deny_execmem',`',`
+	allow sandbox_domain self:process execmem;
+')
+
+allow sandbox_domain self:fifo_file manage_file_perms;
+allow sandbox_domain self:sem create_sem_perms;
+allow sandbox_domain self:shm create_shm_perms;
+allow sandbox_domain self:msgq create_msgq_perms;
+allow sandbox_domain self:unix_stream_socket create_stream_socket_perms;
+allow sandbox_domain self:unix_dgram_socket { sendto create_socket_perms };
+dontaudit sandbox_domain self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };
+
+dev_rw_all_inherited_chr_files(sandbox_domain)
+dev_rw_all_inherited_blk_files(sandbox_domain)
+
+can_exec(sandbox_domain, sandbox_file_t)
+allow sandbox_domain sandbox_file_t:filesystem getattr;
+manage_files_pattern(sandbox_domain, sandbox_file_t, sandbox_file_t);
+manage_dirs_pattern(sandbox_domain, sandbox_file_t, sandbox_file_t);
+manage_sock_files_pattern(sandbox_domain, sandbox_file_t, sandbox_file_t);
+manage_fifo_files_pattern(sandbox_domain, sandbox_file_t, sandbox_file_t);
+manage_lnk_files_pattern(sandbox_domain, sandbox_file_t, sandbox_file_t);
+dontaudit sandbox_domain sandbox_file_t:dir mounton;
+
+gen_require(`
+	type usr_t, lib_t, locale_t;
+	type var_t, var_run_t, rpm_log_t, locale_t;
+	attribute exec_type, configfile;
+')
+
+kernel_dontaudit_read_system_state(sandbox_domain)
+
+corecmd_exec_all_executables(sandbox_domain)
+
+files_rw_all_inherited_files(sandbox_domain, -exec_type -configfile -usr_t -lib_t -locale_t -var_t -var_run_t -device_t -rpm_log_t )
+files_entrypoint_all_files(sandbox_domain)
+
+files_read_config_files(sandbox_domain)
+files_read_usr_files(sandbox_domain)
+files_read_var_files(sandbox_domain)
+files_dontaudit_search_all_dirs(sandbox_domain)
+
+miscfiles_read_localization(sandbox_domain)
+
+userdom_dontaudit_use_user_terminals(sandbox_domain)
+
+mta_dontaudit_read_spool_symlinks(sandbox_domain)
+
+########################################
+#
+# sandbox_x_domain local policy
+#
+allow sandbox_x_domain self:process { getattr signal_perms getsched setsched setpgid execstack };
+tunable_policy(`deny_execmem',`',`
+	allow sandbox_x_domain self:process execmem;
+')
+
+allow sandbox_x_domain self:fifo_file manage_file_perms;
+allow sandbox_x_domain self:sem create_sem_perms;
+allow sandbox_x_domain self:shm create_shm_perms;
+allow sandbox_x_domain self:msgq create_msgq_perms;
+allow sandbox_x_domain self:netlink_selinux_socket create_socket_perms;
+allow sandbox_x_domain self:unix_dgram_socket { sendto create_socket_perms };
+allow sandbox_x_domain self:unix_stream_socket { connectto create_stream_socket_perms };
+
+dontaudit sandbox_x_domain sandbox_x_domain:process signal;
+dontaudit sandbox_x_domain sandbox_xserver_t:process signal;
+dontaudit sandbox_x_domain self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };
+
+allow sandbox_x_domain sandbox_xserver_t:unix_stream_socket connectto;
+
+allow sandbox_x_domain sandbox_devpts_t:chr_file { rw_term_perms setattr };
+term_create_pty(sandbox_x_domain,sandbox_devpts_t)
+
+can_exec(sandbox_x_domain, sandbox_file_t)
+allow sandbox_x_domain sandbox_file_t:filesystem getattr;
+manage_files_pattern(sandbox_x_domain, sandbox_file_t, sandbox_file_t);
+manage_dirs_pattern(sandbox_x_domain, sandbox_file_t, sandbox_file_t);
+manage_sock_files_pattern(sandbox_x_domain, sandbox_file_t, sandbox_file_t);
+manage_fifo_files_pattern(sandbox_x_domain, sandbox_file_t, sandbox_file_t);
+manage_lnk_files_pattern(sandbox_x_domain, sandbox_file_t, sandbox_file_t);
+dontaudit sandbox_x_domain sandbox_file_t:dir mounton;
+
+kernel_getattr_proc(sandbox_x_domain)
+kernel_read_network_state(sandbox_x_domain)
+kernel_read_system_state(sandbox_x_domain)
+kernel_dontaudit_search_kernel_sysctl(sandbox_x_domain)
+
+domain_dontaudit_read_all_domains_state(sandbox_x_domain)
+
+corecmd_exec_all_executables(sandbox_x_domain)
+
+dev_read_urand(sandbox_x_domain)
+dev_dontaudit_read_rand(sandbox_x_domain)
+dev_read_sysfs(sandbox_x_domain)
+dev_dontaudit_rw_dri(sandbox_x_domain)
+
+files_search_home(sandbox_x_domain)
+files_dontaudit_list_all_mountpoints(sandbox_x_domain)
+files_entrypoint_all_files(sandbox_x_domain)
+files_read_config_files(sandbox_x_domain)
+files_read_usr_files(sandbox_x_domain)
+files_read_usr_symlinks(sandbox_x_domain)
+
+fs_getattr_tmpfs(sandbox_x_domain)
+fs_getattr_xattr_fs(sandbox_x_domain)
+fs_list_inotifyfs(sandbox_x_domain)
+fs_dontaudit_getattr_xattr_fs(sandbox_x_domain)
+
+auth_dontaudit_read_login_records(sandbox_x_domain)
+auth_dontaudit_write_login_records(sandbox_x_domain)
+auth_search_pam_console_data(sandbox_x_domain)
+
+init_read_utmp(sandbox_x_domain)
+init_dontaudit_write_utmp(sandbox_x_domain)
+
+libs_dontaudit_setattr_lib_files(sandbox_x_domain)
+
+miscfiles_read_localization(sandbox_x_domain)
+miscfiles_dontaudit_setattr_fonts_cache_dirs(sandbox_x_domain)
+
+mta_dontaudit_read_spool_symlinks(sandbox_x_domain)
+
+selinux_get_fs_mount(sandbox_x_domain)
+selinux_validate_context(sandbox_x_domain)
+selinux_compute_access_vector(sandbox_x_domain)
+selinux_compute_create_context(sandbox_x_domain)
+selinux_compute_relabel_context(sandbox_x_domain)
+selinux_compute_user_contexts(sandbox_x_domain)
+seutil_read_default_contexts(sandbox_x_domain)
+
+term_getattr_pty_fs(sandbox_x_domain)
+term_use_ptmx(sandbox_x_domain)
+term_search_ptys(sandbox_x_domain)
+
+application_dontaudit_signal(sandbox_x_domain)
+application_dontaudit_sigkill(sandbox_x_domain)
+
+logging_send_syslog_msg(sandbox_x_domain)
+logging_dontaudit_search_logs(sandbox_x_domain)
+
+miscfiles_read_fonts(sandbox_x_domain)
+
+storage_dontaudit_rw_fuse(sandbox_x_domain)
+
+optional_policy(`
+	consolekit_dbus_chat(sandbox_x_domain)
+')
+
+optional_policy(`
+	cups_stream_connect(sandbox_x_domain)
+	cups_read_rw_config(sandbox_x_domain)
+')
+
+optional_policy(`
+	dbus_system_bus_client(sandbox_x_domain)
+')
+
+optional_policy(`
+	devicekit_dontaudit_dbus_chat_disk(sandbox_x_domain)
+')
+
+optional_policy(`
+	gnome_read_gconf_config(sandbox_x_domain)
+')
+
+optional_policy(`
+	nscd_dontaudit_search_pid(sandbox_x_domain)
+')
+
+optional_policy(`
+	sssd_dontaudit_search_lib(sandbox_x_domain)
+')
+
+optional_policy(`
+	udev_read_db(sandbox_x_domain)
+')
+
+userdom_dontaudit_use_user_terminals(sandbox_x_domain)
+userdom_read_user_home_content_symlinks(sandbox_x_domain)
+userdom_search_user_home_content(sandbox_x_domain)
+userdom_dontaudit_rw_user_tmp_pipes(sandbox_x_domain)
+
+fs_search_auto_mountpoints(sandbox_x_domain)
+
+tunable_policy(`use_nfs_home_dirs',`
+	fs_search_auto_mountpoints(sandbox_x_domain)
+	fs_search_nfs(sandbox_xserver_t)
+	fs_read_nfs_files(sandbox_xserver_t)
+	fs_manage_nfs_dirs(sandbox_x_domain)
+	fs_manage_nfs_files(sandbox_x_domain)
+	fs_exec_nfs_files(sandbox_x_domain)
+')
+
+tunable_policy(`use_samba_home_dirs',`
+	fs_search_cifs(sandbox_xserver_t)
+	fs_read_cifs_files(sandbox_xserver_t)
+	fs_manage_cifs_dirs(sandbox_x_domain)
+	fs_manage_cifs_files(sandbox_x_domain)
+	fs_exec_cifs_files(sandbox_x_domain)
+')
+
+tunable_policy(`use_fusefs_home_dirs',`
+	fs_search_fusefs(sandbox_xserver_t)
+	fs_read_fusefs_files(sandbox_xserver_t)
+	fs_manage_fusefs_dirs(sandbox_x_domain)
+	fs_manage_fusefs_files(sandbox_x_domain)
+	fs_exec_fusefs_files(sandbox_x_domain)
+')
+
+files_search_home(sandbox_x_t)
+userdom_use_user_ptys(sandbox_x_t)
+
+########################################
+#
+# sandbox_x_client_t local policy
+#
+allow sandbox_x_client_t self:tcp_socket create_stream_socket_perms;
+allow sandbox_x_client_t self:udp_socket create_socket_perms;
+allow sandbox_x_client_t self:dbus { acquire_svc send_msg };
+
+dev_read_rand(sandbox_x_client_t)
+
+corenet_tcp_connect_ipp_port(sandbox_x_client_t)
+
+auth_use_nsswitch(sandbox_x_client_t)
+
+optional_policy(`
+	colord_dbus_chat(sandbox_x_client_t)
+')
+
+optional_policy(`
+	hal_dbus_chat(sandbox_x_client_t)
+')
+
+optional_policy(`
+	nsplugin_read_rw_files(sandbox_x_client_t)
+')
+
+########################################
+#
+# sandbox_web_client_t local policy
+#
+typeattribute sandbox_web_client_t sandbox_web_type;
+
+auth_use_nsswitch(sandbox_web_client_t)
+
+allow sandbox_web_type self:capability { setuid setgid };
+allow sandbox_web_type self:netlink_audit_socket nlmsg_relay;
+dontaudit sandbox_web_type self:process setrlimit;
+
+allow sandbox_web_type self:tcp_socket create_stream_socket_perms;
+allow sandbox_web_type self:udp_socket create_socket_perms;
+allow sandbox_web_type self:dbus { acquire_svc send_msg };
+
+kernel_dontaudit_search_kernel_sysctl(sandbox_web_type)
+kernel_request_load_module(sandbox_web_type)
+
+dev_read_rand(sandbox_web_type)
+dev_write_sound(sandbox_web_type)
+dev_read_sound(sandbox_web_type)
+
+corenet_all_recvfrom_unlabeled(sandbox_web_type)
+corenet_all_recvfrom_netlabel(sandbox_web_type)
+corenet_tcp_sendrecv_generic_if(sandbox_web_type)
+corenet_raw_sendrecv_generic_if(sandbox_web_type)
+corenet_tcp_sendrecv_generic_node(sandbox_web_type)
+corenet_raw_sendrecv_generic_node(sandbox_web_type)
+corenet_tcp_sendrecv_http_port(sandbox_web_type)
+corenet_tcp_sendrecv_http_cache_port(sandbox_web_type)
+corenet_tcp_sendrecv_squid_port(sandbox_web_type)
+corenet_tcp_sendrecv_ftp_port(sandbox_web_type)
+corenet_tcp_sendrecv_ipp_port(sandbox_web_type)
+corenet_tcp_connect_http_port(sandbox_web_type)
+corenet_tcp_connect_http_cache_port(sandbox_web_type)
+corenet_tcp_connect_squid_port(sandbox_web_type)
+corenet_tcp_connect_flash_port(sandbox_web_type)
+corenet_tcp_connect_ftp_port(sandbox_web_type)
+corenet_tcp_connect_all_ephemeral_ports(sandbox_web_type)
+corenet_tcp_connect_ipp_port(sandbox_web_type)
+corenet_tcp_connect_streaming_port(sandbox_web_type)
+corenet_tcp_connect_pulseaudio_port(sandbox_web_type)
+corenet_tcp_connect_speech_port(sandbox_web_type)
+corenet_tcp_connect_generic_port(sandbox_web_type)
+corenet_tcp_connect_soundd_port(sandbox_web_type)
+corenet_tcp_connect_speech_port(sandbox_web_type)
+corenet_sendrecv_http_client_packets(sandbox_web_type)
+corenet_sendrecv_http_cache_client_packets(sandbox_web_type)
+corenet_sendrecv_squid_client_packets(sandbox_web_type)
+corenet_sendrecv_ftp_client_packets(sandbox_web_type)
+corenet_sendrecv_ipp_client_packets(sandbox_web_type)
+corenet_sendrecv_generic_client_packets(sandbox_web_type)
+
+corenet_dontaudit_tcp_sendrecv_generic_port(sandbox_web_type)
+corenet_dontaudit_tcp_bind_generic_port(sandbox_web_type)
+
+files_dontaudit_getattr_all_dirs(sandbox_web_type)
+
+fs_dontaudit_rw_anon_inodefs_files(sandbox_web_type)
+fs_dontaudit_getattr_all_fs(sandbox_web_type)
+
+storage_dontaudit_getattr_fixed_disk_dev(sandbox_web_type)
+
+dbus_system_bus_client(sandbox_web_type)
+dbus_read_config(sandbox_web_type)
+selinux_get_fs_mount(sandbox_web_type)
+selinux_validate_context(sandbox_web_type)
+selinux_compute_access_vector(sandbox_web_type)
+selinux_compute_create_context(sandbox_web_type)
+selinux_compute_relabel_context(sandbox_web_type)
+selinux_compute_user_contexts(sandbox_web_type)
+seutil_read_default_contexts(sandbox_web_type)
+
+userdom_rw_user_tmpfs_files(sandbox_web_type)
+userdom_delete_user_tmpfs_files(sandbox_web_type)
+
+optional_policy(`
+	alsa_read_rw_config(sandbox_web_type)
+')
+
+optional_policy(`
+	bluetooth_dontaudit_dbus_chat(sandbox_web_type)
+')
+
+optional_policy(`
+	hal_dbus_chat(sandbox_web_type)
+')
+
+optional_policy(`
+	chrome_domtrans_sandbox(sandbox_web_type)
+')
+
+optional_policy(`
+	nsplugin_manage_rw(sandbox_web_type)
+	nsplugin_read_rw_files(sandbox_web_type)
+	nsplugin_rw_exec(sandbox_web_type)
+')
+
+optional_policy(`
+	pulseaudio_stream_connect(sandbox_web_type)
+	allow sandbox_web_type self:netlink_kobject_uevent_socket create_socket_perms;
+')
+
+optional_policy(`
+	rtkit_daemon_dontaudit_dbus_chat(sandbox_web_type)
+')
+
+optional_policy(`
+	networkmanager_dontaudit_dbus_chat(sandbox_web_type)
+')
+
+optional_policy(`
+	udev_read_state(sandbox_web_type)
+')
+
+########################################
+#
+# sandbox_net_client_t local policy
+#
+typeattribute sandbox_net_client_t sandbox_web_type;
+
+corenet_all_recvfrom_unlabeled(sandbox_net_client_t)
+corenet_all_recvfrom_netlabel(sandbox_net_client_t)
+corenet_tcp_sendrecv_generic_if(sandbox_net_client_t)
+corenet_udp_sendrecv_generic_if(sandbox_net_client_t)
+corenet_tcp_sendrecv_generic_node(sandbox_net_client_t)
+corenet_udp_sendrecv_generic_node(sandbox_net_client_t)
+corenet_tcp_sendrecv_all_ports(sandbox_net_client_t)
+corenet_udp_sendrecv_all_ports(sandbox_net_client_t)
+corenet_tcp_connect_all_ports(sandbox_net_client_t)
+corenet_sendrecv_all_client_packets(sandbox_net_client_t)
+
+auth_use_nsswitch(sandbox_net_client_t)
+
+optional_policy(`
+	mozilla_dontaudit_rw_user_home_files(sandbox_x_t)
+	mozilla_dontaudit_rw_user_home_files(sandbox_xserver_t)
+	mozilla_dontaudit_rw_user_home_files(sandbox_x_domain)
+	mozilla_plugin_dontaudit_leaks(sandbox_x_domain)
+')
Index: refpolicy-2.20110726/policy/modules/apps/sandbox.fc
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ refpolicy-2.20110726/policy/modules/apps/sandbox.fc	2012-06-26 15:58:56.353278656 +1000
@@ -0,0 +1 @@
+/usr/share/sandbox/start -- gen_context(system_u:object_r:sandbox_exec_t,s0)
Index: refpolicy-2.20110726/policy/modules/apps/sandbox.if
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ refpolicy-2.20110726/policy/modules/apps/sandbox.if	2012-06-26 15:58:56.353278656 +1000
@@ -0,0 +1,363 @@
+## <summary>policy for sandbox</summary>
+
+########################################
+## <summary>
+##	Execute sandbox in the sandbox domain, and
+##	allow the specified role the sandbox domain.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+## <param name="role">
+##	<summary>
+##	The role to be allowed the sandbox domain.
+##	</summary>
+## </param>
+#
+interface(`sandbox_transition',`
+	gen_require(`
+		type sandbox_xserver_t;
+		type sandbox_file_t;
+		attribute sandbox_domain;
+		attribute sandbox_x_domain;
+		attribute sandbox_tmpfs_type;
+	')
+
+	allow $1 sandbox_domain:process transition;
+	dontaudit $1 sandbox_domain:process { noatsecure siginh rlimitinh };
+	role $2 types sandbox_domain;
+	allow sandbox_domain $1:process { sigchld signull };
+	allow sandbox_domain $1:fifo_file rw_inherited_fifo_file_perms;
+
+	allow $1 sandbox_x_domain:process { signal_perms transition };
+	dontaudit $1 sandbox_x_domain:process { noatsecure siginh rlimitinh };
+	allow sandbox_x_domain $1:process { sigchld signull };
+	allow { sandbox_x_domain sandbox_xserver_t } $1:fd use;
+	dontaudit sandbox_domain $1:process signal;
+	role $2 types sandbox_x_domain;
+	role $2 types sandbox_xserver_t;
+	allow $1 sandbox_xserver_t:process signal_perms;
+	dontaudit sandbox_xserver_t $1:fifo_file rw_inherited_fifo_file_perms;
+	dontaudit sandbox_xserver_t $1:tcp_socket rw_socket_perms;
+	dontaudit sandbox_xserver_t $1:udp_socket rw_socket_perms;
+	allow sandbox_xserver_t $1:unix_stream_socket { connectto rw_socket_perms };
+	allow sandbox_x_domain sandbox_x_domain:process signal;
+	# Dontaudit leaked file descriptors
+	dontaudit sandbox_x_domain $1:fifo_file { read write };
+	dontaudit sandbox_x_domain $1:tcp_socket rw_socket_perms;
+	dontaudit sandbox_x_domain $1:udp_socket rw_socket_perms;
+	dontaudit sandbox_x_domain $1:unix_stream_socket { read write };
+	dontaudit sandbox_x_domain $1:process { signal sigkill };
+	
+	allow $1 sandbox_tmpfs_type:file manage_file_perms;
+	dontaudit $1 sandbox_tmpfs_type:file manage_file_perms;
+
+	can_exec($1, sandbox_file_t)
+	allow $1 sandbox_file_t:filesystem getattr;
+	manage_files_pattern($1, sandbox_file_t, sandbox_file_t);
+	manage_dirs_pattern($1, sandbox_file_t, sandbox_file_t);
+	manage_sock_files_pattern($1, sandbox_file_t, sandbox_file_t);
+	manage_fifo_files_pattern($1, sandbox_file_t, sandbox_file_t);
+	manage_lnk_files_pattern($1, sandbox_file_t, sandbox_file_t);
+	relabel_dirs_pattern($1, sandbox_file_t, sandbox_file_t)
+	relabel_files_pattern($1, sandbox_file_t, sandbox_file_t)
+	relabel_lnk_files_pattern($1, sandbox_file_t, sandbox_file_t)
+	relabel_fifo_files_pattern($1, sandbox_file_t, sandbox_file_t)
+	relabel_sock_files_pattern($1, sandbox_file_t, sandbox_file_t)
+')
+
+########################################
+## <summary>
+##	Creates types and rules for a basic
+##	sandbox process domain.
+## </summary>
+## <param name="prefix">
+##	<summary>
+##	Prefix for the domain.
+##	</summary>
+## </param>
+#
+template(`sandbox_domain_template',`
+
+	gen_require(`
+		attribute sandbox_domain;
+		type sandbox_file_t;
+		attribute sandbox_type;
+	')
+	type $1_t, sandbox_domain, sandbox_type;
+
+	application_type($1_t)
+
+	mls_rangetrans_target($1_t)
+	mcs_untrusted_proc($1_t)
+')
+
+########################################
+## <summary>
+##	Creates types and rules for a basic
+##	sandbox process domain.
+## </summary>
+## <param name="prefix">
+##	<summary>
+##	Prefix for the domain.
+##	</summary>
+## </param>
+#
+template(`sandbox_x_domain_template',`
+	gen_require(`
+		type xserver_exec_t, sandbox_devpts_t;
+		type sandbox_xserver_t;
+		type sandbox_exec_t;
+		attribute sandbox_domain, sandbox_x_domain;
+		attribute sandbox_tmpfs_type;
+		attribute sandbox_type;
+	')
+
+	type $1_t, sandbox_x_domain, sandbox_type;
+	application_type($1_t)
+	mcs_untrusted_proc($1_t)
+
+	auth_use_nsswitch($1_t)
+
+	# window manager
+	miscfiles_setattr_fonts_cache_dirs($1_t)
+	allow $1_t self:capability setuid;
+
+	type $1_client_t, sandbox_x_domain;
+	application_type($1_client_t)
+	mcs_untrusted_proc($1_t)
+
+	type $1_client_tmpfs_t, sandbox_tmpfs_type;
+	files_tmpfs_file($1_client_tmpfs_t)
+
+	manage_files_pattern($1_client_t, $1_client_tmpfs_t, $1_client_tmpfs_t)
+	manage_files_pattern($1_t, $1_client_tmpfs_t, $1_client_tmpfs_t)
+	fs_tmpfs_filetrans($1_client_t, $1_client_tmpfs_t, file )
+	fs_tmpfs_filetrans($1_t, $1_client_tmpfs_t, file )
+	# Pulseaudio tmpfs files with different MCS labels
+	dontaudit $1_client_t $1_client_tmpfs_t:file { read write };
+	dontaudit $1_t $1_client_tmpfs_t:file { read write };
+	allow sandbox_xserver_t $1_client_tmpfs_t:file { read write };
+
+	domtrans_pattern($1_t, xserver_exec_t, sandbox_xserver_t)
+	allow $1_t sandbox_xserver_t:process signal_perms;
+
+	domtrans_pattern($1_t, sandbox_exec_t, $1_client_t)
+	domain_entry_file($1_client_t,  sandbox_exec_t)
+
+	# Random tmpfs_t that gets created when you run X. 
+	fs_rw_tmpfs_files($1_t)
+
+	ps_process_pattern(sandbox_xserver_t, $1_client_t)
+	ps_process_pattern(sandbox_xserver_t, $1_t)
+	allow sandbox_xserver_t $1_client_t:shm rw_shm_perms;
+	allow sandbox_xserver_t $1_t:shm rw_shm_perms;
+	allow $1_client_t $1_t:unix_stream_socket connectto;
+	allow $1_t $1_client_t:unix_stream_socket connectto;
+
+	fs_get_xattr_fs_quotas($1_client_t)
+')
+
+########################################
+## <summary>
+##	allow domain to read, 
+##	write sandbox_xserver tmp files
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_rw_xserver_tmpfs_files',`
+	gen_require(`
+		type sandbox_xserver_tmpfs_t;
+	')
+
+	allow $1 sandbox_xserver_tmpfs_t:file rw_file_perms;
+')
+
+########################################
+## <summary>
+##	allow domain to read
+##	sandbox tmpfs files
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_read_tmpfs_files',`
+	gen_require(`
+		attribute sandbox_tmpfs_type;
+	')
+
+	allow $1 sandbox_tmpfs_type:file read_file_perms;
+')
+
+########################################
+## <summary>
+##	allow domain to manage
+##	sandbox tmpfs files
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_manage_tmpfs_files',`
+	gen_require(`
+		attribute sandbox_tmpfs_type;
+	')
+
+	allow $1 sandbox_tmpfs_type:file manage_file_perms;
+')
+
+########################################
+## <summary>
+##	Delete sandbox files
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_delete_files',`
+	gen_require(`
+		type sandbox_file_t;
+	')
+
+	delete_files_pattern($1, sandbox_file_t, sandbox_file_t)
+')
+
+########################################
+## <summary>
+##	Delete sandbox symbolic links
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_delete_lnk_files',`
+	gen_require(`
+		type sandbox_file_t;
+	')
+
+	delete_lnk_files_pattern($1, sandbox_file_t, sandbox_file_t)
+')
+
+########################################
+## <summary>
+##	Delete sandbox fifo files
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_delete_pipes',`
+	gen_require(`
+		type sandbox_file_t;
+	')
+
+	delete_fifo_files_pattern($1, sandbox_file_t, sandbox_file_t)
+')
+
+########################################
+## <summary>
+##	Delete sandbox sock files
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_delete_sock_files',`
+	gen_require(`
+		type sandbox_file_t;
+	')
+
+	delete_sock_files_pattern($1, sandbox_file_t, sandbox_file_t)
+')
+
+########################################
+## <summary>
+##	Allow domain to  set the attributes
+##	of the sandbox directory.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_setattr_dirs',`
+	gen_require(`
+		type sandbox_file_t;
+	')
+
+	allow $1 sandbox_file_t:dir setattr;
+')
+
+########################################
+## <summary>
+##	Delete sandbox directories
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_delete_dirs',`
+	gen_require(`
+		type sandbox_file_t;
+	')
+
+	delete_dirs_pattern($1, sandbox_file_t, sandbox_file_t)
+')
+
+########################################
+## <summary>
+##	allow domain to list sandbox dirs
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access
+##	</summary>
+## </param>
+#
+interface(`sandbox_list',`
+	gen_require(`
+		type sandbox_file_t;
+	')
+
+	allow $1 sandbox_file_t:dir list_dir_perms;
+')
+
+########################################
+## <summary>
+##	Read and write a sandbox domain pty.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`sandbox_use_ptys',`
+	gen_require(`
+		type sandbox_devpts_t;
+	')
+
+	allow $1 sandbox_devpts_t:chr_file rw_inherited_term_perms;
+')
Index: refpolicy-2.20110726/policy/mcs
===================================================================
--- refpolicy-2.20110726.orig/policy/mcs	2012-06-26 15:58:17.342573307 +1000
+++ refpolicy-2.20110726/policy/mcs	2012-06-26 16:07:07.321412186 +1000
@@ -69,30 +69,43 @@
 #  - /proc/pid operations are not constrained.
 
 mlsconstrain file { read ioctl lock execute execute_no_trans }
-	(( h1 dom h2 ) or ( t1 == mcsreadall ) or ( t2 == domain ));
+	(( h1 dom h2 ) or ( t1 == mcsreadall ) or
+	(( t1 != mcsuntrustedproc ) and ( t2 == domain )));
 
 mlsconstrain file { write setattr append link rename }
 ifdef(`distro_debian', `
-	((( h1 dom h2 ) and ( l1 domby l2 )) or ( t1 == mcswriteall ) or (t2 == mcstrustedobject) or ( t2 == domain ));
+	((( h1 dom h2 ) and ( l1 domby l2 )) or ( t1 == mcswriteall ) or (t2 == mcstrustedobject) or (( t1 != mcsuntrustedproc ) and (t2 == domain)));
 ', `
-	(( h1 dom h2 ) or ( t1 == mcswriteall ) or ( t2 == domain ));
+	(( h1 dom h2 ) or ( t1 == mcswriteall ) or (( t1 != mcsuntrustedproc ) and (t2 == domain)));
 ')
 
 mlsconstrain file { unlink }
 ifdef(`distro_debian', `
-	((( h1 dom h2 ) and ( l1 domby l2 )) or (( t1 == mcswriteall ) or ( t1 == mcsdeleteall )) or (t2 == mcstrustedobject) or ( t2 == domain ));
+	((( h1 dom h2 ) and ( l1 domby l2 )) or (( t1 == mcswriteall ) or ( t1 == mcsdeleteall )) or (t2 == mcstrustedobject) or (( t1 != mcsuntrustedproc ) and (t2 == domain)));
 ', `
-	(( h1 dom h2 ) or (( t1 == mcswriteall ) or ( t1 == mcsdeleteall )) or ( t2 == domain ));
+	(( h1 dom h2 ) or (( t1 == mcswriteall ) or ( t1 == mcsdeleteall )) or (( t1 != mcsuntrustedproc ) and (t2 == domain)));
 ')
 
 mlsconstrain dir { search read ioctl lock }
-	(( h1 dom h2 ) or ( t1 == mcsreadall ) or ( t1 == mcsdeleteall ) or ( t2 == domain ));
+	(( h1 dom h2 ) or ( t1 == mcsreadall ) or ( t1 == mcsdeleteall ) or (( t1 != mcsuntrustedproc ) and (t2 == domain)));
 
 mlsconstrain dir { setattr append link rename add_name }
-	(( h1 dom h2 ) or ( t1 == mcswriteall ) or ( t2 == domain ));
+	(( h1 dom h2 ) or ( t1 == mcswriteall ) or (( t1 != mcsuntrustedproc ) and (t2 == domain)));
 
 mlsconstrain dir { write unlink remove_name }
-	(( h1 dom h2 ) or ( t1 == mcswriteall ) or ( t1 == mcsdeleteall ) or ( t2 == domain ));
+	(( h1 dom h2 ) or ( t1 == mcswriteall ) or ( t1 == mcsdeleteall ) or (( t1 != mcsuntrustedproc ) and (t2 == domain)));
+
+mlsconstrain fifo_file { open }
+    (( h1 dom h2 ) or ( t1 == mcsreadall ) or
+     (( t1 != mcsuntrustedproc ) and ( t2 == domain )));
+
+mlsconstrain { lnk_file chr_file blk_file sock_file } { getattr read ioctl }
+    (( h1 dom h2 ) or ( t1 == mcsreadall ) or
+     (( t1 != mcsuntrustedproc ) and (t2 == domain)));
+
+mlsconstrain { lnk_file chr_file blk_file sock_file } { write setattr }
+    (( h1 dom h2 ) or ( t1 == mcswriteall ) or
+     (( t1 != mcsuntrustedproc ) and (t2 == domain)));
 
 # New filesystem object labels must be dominated by the relabeling subject
 # clearance, also the objects are single-level.
@@ -105,7 +118,10 @@
 
 # new file labels must be dominated by the relabeling subject clearance
 mlsconstrain { dir file lnk_file chr_file blk_file sock_file fifo_file } { relabelfrom }
-	( h1 dom h2 );
+	(( h1 dom h2 ) or ( t1 == mcswriteall ));
+
+mlsconstrain { file lnk_file fifo_file } { create relabelto }
+       ( l2 eq h2 );
 
 # not mandatory at this time - can write down
 mlsconstrain { dir file lnk_file chr_file blk_file sock_file fifo_file } { create relabelto }
@@ -128,6 +144,9 @@
 mlsconstrain process { sigkill sigstop }
 	(( h1 dom h2 ) or ( t1 == mcskillall ));
 
+mlsconstrain process { signal }
+	(( h1 dom h2 ) or ( t1 != mcsuntrustedproc ));
+
 #
 # MCS policy for SELinux-enabled databases
 #
@@ -171,4 +190,21 @@
 mlsconstrain db_blob { drop getattr setattr relabelfrom read write import export }
 	( h1 dom h2 );
 
+mlsconstrain { tcp_socket udp_socket rawip_socket } node_bind
+	(( h1 dom h2 ) or ( t1 == mcsnetwrite ));
+
+# the node recvfrom/sendto ops, the recvfrom permission is a "write" operation
+# because the subject in this particular case is the remote domain which is
+# writing data out the network node which is acting as the object
+mlsconstrain { node } { recvfrom }
+	((( l1 dom l2 ) and ( l1 domby h2 )) or
+	 ( t1 == mcsnetwrite ) or
+	 ( t1 == unlabeled_t ));
+mlsconstrain { node } { sendto }
+	((( l1 dom l2 ) and ( l1 domby h2 )) or
+	 ( t1 == mcsnetwrite ));
+
+mlsconstrain packet { send recv }
+	(( h1 dom h2 ) or ( t1 == mcsnetwrite ));
+
 ') dnl end enable_mcs
Index: refpolicy-2.20110726/policy/modules/kernel/mcs.if
===================================================================
--- refpolicy-2.20110726.orig/policy/modules/kernel/mcs.if	2012-06-26 15:58:17.342573307 +1000
+++ refpolicy-2.20110726/policy/modules/kernel/mcs.if	2012-06-26 15:59:40.612405046 +1000
@@ -172,3 +172,50 @@
 	typeattribute $1 mcstrustedobject;
 ')
 
+
+########################################
+## <summary>
+##	Make specified process type MCS untrusted.
+## </summary>
+## <desc>
+##	<p>
+##	Make specified process type MCS untrusted.  This
+##	prevents this process from sending signals to other processes 
+##      with different mcs labels
+##	object.
+##	</p>
+## </desc>
+## <param name="domain">
+##	<summary>
+##	The type of the process.
+##	</summary>
+## </param>
+#
+interface(`mcs_untrusted_proc',`
+	gen_require(`
+		attribute mcsuntrustedproc;
+	')
+
+	typeattribute $1 mcsuntrustedproc;
+')
+
+########################################
+## <summary>
+##	Make specified domain MCS trusted
+##	for writing to sockets at any level.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`mcs_socket_write_all_levels',`
+	gen_require(`
+		attribute mcsnetwrite;
+	')
+
+	typeattribute $1 mcsnetwrite;
+')
+
Index: refpolicy-2.20110726/policy/modules/kernel/mcs.te
===================================================================
--- refpolicy-2.20110726.orig/policy/modules/kernel/mcs.te	2012-06-26 15:56:17.738615152 +1000
+++ refpolicy-2.20110726/policy/modules/kernel/mcs.te	2012-06-26 16:09:42.191953963 +1000
@@ -21,3 +21,5 @@
 attribute mcsreadall;
 # process may delete all files and write dirs as appropriate
 attribute mcsdeleteall;
+attribute mcsuntrustedproc;
+attribute mcsnetwrite;
Index: refpolicy-2.20110726/policy/modules/system/userdomain.if
===================================================================
--- refpolicy-2.20110726.orig/policy/modules/system/userdomain.if	2012-06-26 15:56:19.794747210 +1000
+++ refpolicy-2.20110726/policy/modules/system/userdomain.if	2012-06-26 16:31:18.293929291 +1000
@@ -3113,6 +3113,44 @@
 
 ########################################
 ## <summary>
+##	Do not audit attempts to write users
+##	temporary files.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain to not audit.
+##	</summary>
+## </param>
+#
+interface(`userdom_dontaudit_write_user_tmp_files',`
+	gen_require(`
+		type user_tmp_t;
+	')
+
+	dontaudit $1 user_tmp_t:file write;
+')
+
+########################################
+## <summary>
+##	Do not audit attempts to read/write users
+##	temporary fifo files.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain to not audit.
+##	</summary>
+## </param>
+#
+interface(`userdom_dontaudit_rw_user_tmp_pipes',`
+	gen_require(`
+		type user_tmp_t;
+	')
+
+	dontaudit $1 user_tmp_t:fifo_file rw_inherited_fifo_file_perms;
+')
+
+########################################
+## <summary>
 ##	Do not audit attempts to use user ttys.
 ## </summary>
 ## <param name="domain">


More information about the SELinux-devel mailing list