Chris PeBenito 76a9fe
policy_module(mount, 1.11.1)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Declarations
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 56e1b3
## <desc>
Chris PeBenito 56e1b3
## 

Chris PeBenito dd9e1d
## Allow the mount command to mount any directory or file.
Chris PeBenito 56e1b3
## 

Chris PeBenito 56e1b3
## </desc>
Chris PeBenito 3f67f7
gen_tunable(allow_mount_anyfile, false)
Chris PeBenito 56e1b3
Chris PeBenito 17de1b
type mount_t;
Chris PeBenito 17de1b
type mount_exec_t;
Chris PeBenito 3f67f7
init_system_domain(mount_t, mount_exec_t)
Chris PeBenito 17de1b
role system_r types mount_t;
Chris PeBenito 17de1b
Dan Walsh 3eaa99
type fusermount_exec_t;
Dan Walsh 3eaa99
domain_entry_file(mount_t, fusermount_exec_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
typealias mount_t alias mount_ntfs_t;
Dan Walsh 3eaa99
typealias mount_exec_t alias mount_ntfs_exec_t;
Dan Walsh 3eaa99
Chris PeBenito eac818
type mount_loopback_t; # customizable
Chris PeBenito eac818
files_type(mount_loopback_t)
Dan Walsh 3eaa99
typealias mount_loopback_t alias mount_loop_t;
Chris PeBenito eac818
Chris PeBenito 17de1b
type mount_tmp_t;
Chris PeBenito 17de1b
files_tmp_file(mount_tmp_t)
Chris PeBenito 17de1b
Chris PeBenito 350b6a
# causes problems with interfaces when
Chris PeBenito 350b6a
# this is optionally declared in monolithic
Chris PeBenito 350b6a
# policy--duplicate type declaration
Chris PeBenito 350b6a
type unconfined_mount_t;
Chris PeBenito 3f67f7
application_domain(unconfined_mount_t, mount_exec_t)
Dan Walsh 3eaa99
role system_r types unconfined_mount_t;
Dan Walsh 3eaa99
Dan Walsh 3eaa99
type mount_var_run_t;
Dan Walsh 3eaa99
files_pid_file(mount_var_run_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
# showmount - show mount information for an NFS server
Dan Walsh 3eaa99
Dan Walsh 3eaa99
type showmount_t;
Dan Walsh 3eaa99
type showmount_exec_t;
Dan Walsh 3eaa99
application_domain(showmount_t, showmount_exec_t)
Dan Walsh 3eaa99
role system_r types showmount_t;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# mount local policy
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# setuid/setgid needed to mount cifs 
Dan Walsh 3eaa99
allow mount_t self:capability { fsetid ipc_lock setpcap sys_rawio sys_resource sys_admin dac_override dac_read_search chown sys_tty_config setuid setgid };
Dan Walsh 3eaa99
allow mount_t self:process { getcap getsched ptrace setcap setrlimit signal };
Dan Walsh 3eaa99
allow mount_t self:fifo_file rw_fifo_file_perms;
Dan Walsh 3eaa99
allow mount_t self:unix_stream_socket create_stream_socket_perms;
Dan Walsh 3eaa99
allow mount_t self:unix_dgram_socket create_socket_perms; 
Chris PeBenito 17de1b
Chris PeBenito c0868a
allow mount_t mount_loopback_t:file read_file_perms;
Chris PeBenito d6d16b
Chris PeBenito c0868a
allow mount_t mount_tmp_t:file manage_file_perms;
Chris PeBenito c0868a
allow mount_t mount_tmp_t:dir manage_dir_perms;
Chris PeBenito c0868a
Chris PeBenito d6d16b
can_exec(mount_t, mount_exec_t)
Chris PeBenito eac818
Chris PeBenito 3f67f7
files_tmp_filetrans(mount_t, mount_tmp_t, { file dir })
Chris PeBenito 17de1b
Dan Walsh 3eaa99
manage_dirs_pattern(mount_t,mount_var_run_t,mount_var_run_t)
Dan Walsh 3eaa99
manage_files_pattern(mount_t,mount_var_run_t,mount_var_run_t)
Dan Walsh 3eaa99
files_pid_filetrans(mount_t,mount_var_run_t,dir)
Dan Walsh 3eaa99
files_var_filetrans(mount_t,mount_var_run_t,dir)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
# In order to mount reiserfs_t
Dan Walsh 3eaa99
kernel_dontaudit_getattr_core_if(mount_t)
Dan Walsh 3eaa99
kernel_list_unlabeled(mount_t)
Dan Walsh 3eaa99
kernel_mount_unlabeled(mount_t)
Dan Walsh 3eaa99
kernel_unmount_unlabeled(mount_t)
Chris PeBenito 17de1b
kernel_read_system_state(mount_t)
Dan Walsh 3eaa99
kernel_read_network_state(mount_t)
Chris PeBenito d9845a
kernel_read_kernel_sysctls(mount_t)
Dan Walsh cbadf7
kernel_manage_debugfs(mount_t)
Dan Walsh 3eaa99
kernel_setsched(mount_t)
Dan Walsh 3eaa99
kernel_use_fds(mount_t)
Dan Walsh 3eaa99
kernel_request_load_module(mount_t)
Chris PeBenito 17de1b
Chris PeBenito f0e959
# required for mount.smbfs
Chris PeBenito f0e959
corecmd_exec_bin(mount_t)
Chris PeBenito f0e959
Dan Walsh 3eaa99
dev_getattr_generic_blk_files(mount_t)
Chris PeBenito 17de1b
dev_getattr_all_blk_files(mount_t)
Chris PeBenito 17de1b
dev_list_all_dev_nodes(mount_t)
Dan Walsh 3eaa99
dev_read_usbfs(mount_t)
Dan Walsh 3eaa99
dev_read_rand(mount_t)
Dan Walsh 3eaa99
dev_read_sysfs(mount_t)
Chris PeBenito 17de1b
dev_rw_lvm_control(mount_t)
Chris PeBenito 17de1b
dev_dontaudit_getattr_all_chr_files(mount_t)
Chris PeBenito 17de1b
dev_dontaudit_getattr_memory_dev(mount_t)
Chris PeBenito 17de1b
dev_getattr_sound_dev(mount_t)
Dan Walsh 3eaa99
ifdef(`hide_broken_symptoms',`
Dan Walsh 3eaa99
	dev_rw_generic_blk_files(mount_t)
Dan Walsh 3eaa99
')
Jeremy Solt 2fc79f
# Early devtmpfs, before udev relabel
Jeremy Solt 2fc79f
dev_dontaudit_rw_generic_chr_files(mount_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
domain_use_interactive_fds(mount_t)
Dan Walsh 3eaa99
domain_dontaudit_search_all_domains_state(mount_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
files_search_all(mount_t)
Chris PeBenito 17de1b
files_read_etc_files(mount_t)
Chris PeBenito 17de1b
files_manage_etc_runtime_files(mount_t)
Chris PeBenito 3f67f7
files_etc_filetrans_etc_runtime(mount_t, file)
Chris PeBenito 17de1b
files_mounton_all_mountpoints(mount_t)
Dan Walsh 3eaa99
# ntfs-3g checks whether the mountpoint is writable before mounting
Dan Walsh 3eaa99
files_write_all_mountpoints(mount_t)
Chris PeBenito 17de1b
files_unmount_rootfs(mount_t)
Chris PeBenito 17de1b
# These rules need to be generalized.  Only admin, initrc should have it:
Dan Walsh 3eaa99
files_relabel_all_file_type_fs(mount_t)
Chris PeBenito 17de1b
files_mount_all_file_type_fs(mount_t)
Chris PeBenito 17de1b
files_unmount_all_file_type_fs(mount_t)
Chris PeBenito 17de1b
# for when /etc/mtab loses its type
Chris PeBenito 17de1b
# cjp: this seems wrong, the type should probably be etc
Chris PeBenito 17de1b
files_read_isid_type_files(mount_t)
Chris PeBenito 17de1b
# For reading cert files
Chris PeBenito 17de1b
files_read_usr_files(mount_t)
Chris PeBenito a5e213
files_list_mnt(mount_t)
Chris PeBenito 17de1b
Dan Walsh 3eaa99
fs_list_all(mount_t)
Dan Walsh 3eaa99
fs_getattr_all_fs(mount_t)
Chris PeBenito f0e959
fs_mount_all_fs(mount_t)
Chris PeBenito f0e959
fs_unmount_all_fs(mount_t)
Chris PeBenito f0e959
fs_remount_all_fs(mount_t)
Chris PeBenito f0e959
fs_relabelfrom_all_fs(mount_t)
Dan Walsh 3eaa99
fs_rw_anon_inodefs_files(mount_t)
Chris PeBenito f0e959
fs_rw_tmpfs_chr_files(mount_t)
Dan Walsh 3eaa99
fs_rw_nfsd_fs(mount_t)
Dan Walsh 3eaa99
fs_manage_tmpfs_dirs(mount_t)
Chris PeBenito f0e959
fs_read_tmpfs_symlinks(mount_t)
Dan Walsh 3eaa99
fs_read_fusefs_files(mount_t)
Dan Walsh 3eaa99
fs_manage_nfs_dirs(mount_t)
Dan Walsh 3eaa99
fs_read_nfs_symlinks(mount_t)
Chris PeBenito f0e959
Chris PeBenito f0e959
mls_file_read_all_levels(mount_t)
Chris PeBenito f0e959
mls_file_write_all_levels(mount_t)
Chris PeBenito f0e959
Chris PeBenito f0e959
selinux_get_enforce_mode(mount_t)
Dan Walsh 3eaa99
selinux_dontaudit_write_fs(mount_t)
Chris PeBenito f0e959
Chris PeBenito f0e959
storage_raw_read_fixed_disk(mount_t)
Chris PeBenito f0e959
storage_raw_write_fixed_disk(mount_t)
Chris PeBenito f0e959
storage_raw_read_removable_device(mount_t)
Chris PeBenito f0e959
storage_raw_write_removable_device(mount_t)
Dan Walsh 3eaa99
storage_rw_fuse(mount_t)
Chris PeBenito f0e959
Chris PeBenito f0e959
term_use_all_terms(mount_t)
Chris PeBenito f0e959
Chris PeBenito f0e959
auth_use_nsswitch(mount_t)
Chris PeBenito f0e959
Chris PeBenito 17de1b
init_use_fds(mount_t)
Chris PeBenito 17de1b
init_use_script_ptys(mount_t)
Chris PeBenito 17de1b
init_dontaudit_getattr_initctl(mount_t)
Dan Walsh 3eaa99
init_stream_connect_script(mount_t)
Dan Walsh 3eaa99
init_rw_script_stream_sockets(mount_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
logging_send_syslog_msg(mount_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
miscfiles_read_localization(mount_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
sysnet_use_portmap(mount_t)
Chris PeBenito 17de1b
Chris PeBenito d9845a
seutil_read_config(mount_t)
Chris PeBenito a5e213
Chris PeBenito 17de1b
userdom_use_all_users_fds(mount_t)
Dan Walsh 3eaa99
userdom_manage_user_home_content_dirs(mount_t)
Dan Walsh 3eaa99
userdom_read_user_home_content_symlinks(mount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	abrt_rw_fifo_file(mount_t)
Dan Walsh 3eaa99
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
ifdef(`distro_redhat',`
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		auth_read_pam_console_data(mount_t)
Chris PeBenito 17de1b
		# mount config by default sets fscontext=removable_t
Chris PeBenito 17de1b
		fs_relabelfrom_dos_fs(mount_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 12cf80
ifdef(`distro_ubuntu',`
Chris PeBenito 12cf80
	optional_policy(`
Chris PeBenito 12cf80
		unconfined_domain(mount_t)
Chris PeBenito 12cf80
	')
Chris PeBenito 12cf80
')
Chris PeBenito 12cf80
Dan Walsh 3eaa99
corecmd_exec_shell(mount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
modutils_domtrans_insmod(mount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
fstools_domtrans(mount_t)
Dan Walsh 3eaa99
Chris PeBenito 350b6a
tunable_policy(`allow_mount_anyfile',`
Chris PeBenito 350b6a
	auth_read_all_dirs_except_shadow(mount_t)
Chris PeBenito 350b6a
	auth_read_all_files_except_shadow(mount_t)
Chris PeBenito 350b6a
	files_mounton_non_security(mount_t)
Dan Walsh 3eaa99
	files_rw_all_inherited_files(mount_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	# for nfs
Chris PeBenito 190066
	corenet_all_recvfrom_unlabeled(mount_t)
Chris PeBenito 190066
	corenet_all_recvfrom_netlabel(mount_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_if(mount_t)
Chris PeBenito 17de1b
	corenet_raw_sendrecv_all_if(mount_t)
Chris PeBenito 17de1b
	corenet_udp_sendrecv_all_if(mount_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_nodes(mount_t)
Chris PeBenito 17de1b
	corenet_raw_sendrecv_all_nodes(mount_t)
Chris PeBenito 17de1b
	corenet_udp_sendrecv_all_nodes(mount_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_ports(mount_t)
Chris PeBenito 17de1b
	corenet_udp_sendrecv_all_ports(mount_t)
Chris PeBenito 17de1b
	corenet_tcp_bind_all_nodes(mount_t)
Chris PeBenito 17de1b
	corenet_udp_bind_all_nodes(mount_t)
Chris PeBenito 17de1b
	corenet_tcp_bind_generic_port(mount_t)
Chris PeBenito 17de1b
	corenet_udp_bind_generic_port(mount_t)
Chris PeBenito 17de1b
	corenet_tcp_bind_reserved_port(mount_t)
Chris PeBenito 17de1b
	corenet_udp_bind_reserved_port(mount_t)
Chris PeBenito 17de1b
	corenet_tcp_bind_all_rpc_ports(mount_t)
Chris PeBenito 17de1b
	corenet_udp_bind_all_rpc_ports(mount_t)
Chris PeBenito 17de1b
	corenet_dontaudit_tcp_bind_all_reserved_ports(mount_t)
Chris PeBenito 17de1b
	corenet_dontaudit_udp_bind_all_reserved_ports(mount_t)
Chris PeBenito 17de1b
	corenet_tcp_connect_all_ports(mount_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	fs_search_rpc(mount_t)
Chris PeBenito 17de1b
Chris PeBenito 0d96ff
	rpc_stub(mount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
	rpc_domtrans_rpcd(mount_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	apm_use_fds(mount_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Dan Walsh 3eaa99
	cron_system_entry(mount_t, mount_exec_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	dbus_system_bus_client(mount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
	optional_policy(`
Dan Walsh 3eaa99
		hal_dbus_chat(mount_t)
Dan Walsh 3eaa99
	')
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	hal_write_log(mount_t)
Dan Walsh 3eaa99
	hal_use_fds(mount_t)
Dan Walsh 3eaa99
	hal_dontaudit_rw_pipes(mount_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Chris PeBenito 17de1b
	ifdef(`hide_broken_symptoms',`
Chris PeBenito 17de1b
		# for a bug in the X server
Chris PeBenito 17de1b
		rhgb_dontaudit_rw_stream_sockets(mount_t)
Chris PeBenito 17de1b
		term_dontaudit_use_ptmx(mount_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Dan Walsh 3fdb12
optional_policy(`
Dan Walsh 3fdb12
	livecd_rw_tmp_files(mount_t)
Dan Walsh 3fdb12
')
Dan Walsh 3fdb12
Dan Walsh 3eaa99
# Needed for mount crypt https://bugzilla.redhat.com/show_bug.cgi?id=418711
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	lvm_domtrans(mount_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Chris PeBenito 17de1b
# for kernel package installation
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	rpm_rw_pipes(mount_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	samba_domtrans_smbmount(mount_t)
Dan Walsh 3eaa99
	samba_read_config(mount_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	ssh_exec(mount_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	usbmuxd_stream_connect(mount_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	vmware_exec_host(mount_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Unconfined mount local policy
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 350b6a
optional_policy(`
Dan Walsh 3eaa99
	unconfined_domain_noaudit(unconfined_mount_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	userdom_unpriv_usertype(unconfined, unconfined_mount_t)
Chris PeBenito 3f67f7
	files_etc_filetrans_etc_runtime(unconfined_mount_t, file)
Chris PeBenito 17de1b
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
######################################
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
# showmount local policy
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
Dan Walsh 3eaa99
allow showmount_t self:tcp_socket create_stream_socket_perms;
Dan Walsh 3eaa99
allow showmount_t self:udp_socket create_socket_perms;
Dan Walsh 3eaa99
Dan Walsh 3eaa99
kernel_read_system_state(showmount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
corenet_all_recvfrom_unlabeled(showmount_t)
Dan Walsh 3eaa99
corenet_all_recvfrom_netlabel(showmount_t)
Dan Walsh 3eaa99
corenet_tcp_sendrecv_generic_if(showmount_t)
Dan Walsh 3eaa99
corenet_udp_sendrecv_generic_if(showmount_t)
Dan Walsh 3eaa99
corenet_tcp_sendrecv_generic_node(showmount_t)
Dan Walsh 3eaa99
corenet_udp_sendrecv_generic_node(showmount_t)
Dan Walsh 3eaa99
corenet_tcp_sendrecv_all_ports(showmount_t)
Dan Walsh 3eaa99
corenet_udp_sendrecv_all_ports(showmount_t)
Dan Walsh 3eaa99
corenet_tcp_bind_generic_node(showmount_t)
Dan Walsh 3eaa99
corenet_udp_bind_generic_node(showmount_t)
Dan Walsh 3eaa99
corenet_tcp_bind_all_rpc_ports(showmount_t)
Dan Walsh 3eaa99
corenet_udp_bind_all_rpc_ports(showmount_t)
Dan Walsh 3eaa99
corenet_tcp_connect_all_ports(showmount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
files_read_etc_files(showmount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
miscfiles_read_localization(showmount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
sysnet_dns_name_resolve(showmount_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
userdom_use_user_terminals(showmount_t)