diff --git a/refpolicy/Changelog b/refpolicy/Changelog index 59c2a64..b96d3b2 100644 --- a/refpolicy/Changelog +++ b/refpolicy/Changelog @@ -3,6 +3,7 @@ apt (Erich Schubert) clamav (Erich Schubert) dpkg (Erich Schubert) + rhgb thunderbird tor (Erich Schubert) diff --git a/refpolicy/policy/modules/admin/firstboot.if b/refpolicy/policy/modules/admin/firstboot.if index 4214456..ceb0580 100644 --- a/refpolicy/policy/modules/admin/firstboot.if +++ b/refpolicy/policy/modules/admin/firstboot.if @@ -111,3 +111,20 @@ interface(`firstboot_write_pipes',` allow $1 firstboot_t:fifo_file write; ') +######################################## +## +## Read firstboot writable config files. +## +## +## +## The type of the process performing this action. +## +## +# +interface(`firstboot_read_rw_files',` + gen_require(` + type firstboot_rw_t; + ') + + allow $1 firstboot_rw_t:file r_file_perms; +') diff --git a/refpolicy/policy/modules/kernel/filesystem.if b/refpolicy/policy/modules/kernel/filesystem.if index d7b2f86..a2a105a 100644 --- a/refpolicy/policy/modules/kernel/filesystem.if +++ b/refpolicy/policy/modules/kernel/filesystem.if @@ -1960,7 +1960,7 @@ interface(`fs_search_ramfs',` type ramfs_t; ') - allow $1 ramfs_t:dir search; + allow $1 ramfs_t:dir search_dir_perms; ') ######################################## @@ -2019,6 +2019,26 @@ interface(`fs_dontaudit_read_ramfs_pipes',` ######################################## ## +## Create, read, write, and delete +## files on a ramfs filesystem. +## +## +## +## Domain allowed access. +## +## +# +interface(`fs_manage_ramfs_files',` + gen_require(` + type ramfs_t; + ') + + allow $1 ramfs_t:dir rw_dir_perms; + allow $1 ramfs_t:file manage_file_perms; +') + +######################################## +## ## Write to named pipe on a ramfs filesystem. ## ## @@ -2032,11 +2052,31 @@ interface(`fs_write_ramfs_pipes',` type ramfs_t; ') + allow $1 ramfs_t:dir search_dir_perms; allow $1 ramfs_t:fifo_file write; ') ######################################## ## +## Do not audit attempts to write to named +## pipes on a ramfs filesystem. +## +## +## +## Domain allowed access. +## +## +# +interface(`fs_dontaudit_write_ramfs_pipes',` + gen_require(` + type ramfs_t; + ') + + dontaudit $1 ramfs_t:fifo_file write; +') + +######################################## +## ## Read and write a named pipe on a ramfs filesystem. ## ## @@ -2050,11 +2090,32 @@ interface(`fs_rw_ramfs_pipes',` type ramfs_t; ') + allow $1 ramfs_t:dir search_dir_perms; allow $1 ramfs_t:fifo_file rw_file_perms; ') ######################################## ## +## Create, read, write, and delete +## named pipes on a ramfs filesystem. +## +## +## +## Domain allowed access. +## +## +# +interface(`fs_manage_ramfs_pipes',` + gen_require(` + type ramfs_t; + ') + + allow $1 ramfs_t:dir rw_dir_perms; + allow $1 ramfs_t:fifo_file manage_file_perms; +') + +######################################## +## ## Write to named socket on a ramfs filesystem. ## ## @@ -2073,6 +2134,26 @@ interface(`fs_write_ramfs_sockets',` ######################################## ## +## Create, read, write, and delete +## named sockets on a ramfs filesystem. +## +## +## +## Domain allowed access. +## +## +# +interface(`fs_manage_ramfs_sockets',` + gen_require(` + type ramfs_t; + ') + + allow $1 ramfs_t:dir rw_dir_perms; + allow $1 ramfs_t:sock_file manage_file_perms; +') + +######################################## +## ## Mount a ROM filesystem. ## ## diff --git a/refpolicy/policy/modules/services/rhgb.fc b/refpolicy/policy/modules/services/rhgb.fc new file mode 100644 index 0000000..9e5d31b --- /dev/null +++ b/refpolicy/policy/modules/services/rhgb.fc @@ -0,0 +1,4 @@ +# +# /usr +# +/usr/bin/rhgb -- gen_context(system_u:object_r:rhgb_exec_t,s0) diff --git a/refpolicy/policy/modules/services/rhgb.if b/refpolicy/policy/modules/services/rhgb.if new file mode 100644 index 0000000..639ece6 --- /dev/null +++ b/refpolicy/policy/modules/services/rhgb.if @@ -0,0 +1,126 @@ +## Red Hat Graphical Boot + +######################################## +## +## RHGB stub interface. No access allowed. +## +## +## +## N/A +## +## +# +interface(`rhgb_stub',` + gen_require(` + type rhgb_t; + ') +') + +######################################## +## +## Use a rhgb file descriptor. +## +## +## +## The type of the process performing this action. +## +## +# +interface(`rhgb_use_fds',` + gen_require(` + type rhgb_t; + ') + + allow $1 rhgb_t:fd use; +') + +######################################## +## +## Read and write to unix stream sockets. +## +## +## +## The type of the process performing this action. +## +## +# +interface(`rhgb_rw_stream_sockets',` + gen_require(` + type rhgb_t; + ') + + allow $1 rhgb_t:unix_stream_socket { read write }; +') + +######################################## +## +## Do not audit attempts to read and write +## rhgb unix domain stream sockets. +## +## +## +## The type of the process performing this action. +## +## +# +interface(`rhgb_dontaudit_rw_stream_sockets',` + gen_require(` + type rhgb_t; + ') + + dontaudit $1 rhgb_t:unix_stream_socket { read write }; +') + +######################################## +## +## Connected to rhgb unix stream socket. +## +## +## +## The type of the process performing this action. +## +## +# +interface(`rhgb_stream_connect',` + gen_require(` + type rhgb_t; + ') + + allow $1 rhgb_t:unix_stream_socket connectto; +') + +######################################## +## +## Read and write to rhgb shared memory. +## +## +## +## The type of the process performing this action. +## +## +# +interface(`rhgb_rw_shm',` + gen_require(` + type rhgb_t; + ') + + allow $1 rhgb_t:shm rw_shm_perms; +') + +######################################## +## +## Read and write to rhgb temporary file system. +## +## +## +## The type of the process performing this action. +## +## +# +interface(`rhgb_rw_tmpfs_files',` + gen_require(` + type rhgb_tmpfs_t; + ') + + allow $1 rhgb_tmpfs_t:file { read write }; +') diff --git a/refpolicy/policy/modules/services/rhgb.te b/refpolicy/policy/modules/services/rhgb.te new file mode 100644 index 0000000..99acd6b --- /dev/null +++ b/refpolicy/policy/modules/services/rhgb.te @@ -0,0 +1,149 @@ + +policy_module(rhgb,1.0.0) + +######################################## +# +# Declarations +# + +type rhgb_t; +type rhgb_exec_t; +init_daemon_domain(rhgb_t,rhgb_exec_t) + +type rhgb_devpts_t; +term_pty(rhgb_devpts_t) + +type rhgb_tmpfs_t; +files_tmpfs_file(rhgb_tmpfs_t) + +######################################## +# +# Local policy +# + +allow rhgb_t self:capability { sys_admin sys_tty_config }; +dontaudit rhgb_t self:capability sys_tty_config; +allow rhgb_t self:process signal_perms; +allow rhgb_t self:shm create_shm_perms; +allow rhgb_t self:unix_stream_socket create_stream_socket_perms; +allow rhgb_t self:fifo_file rw_file_perms; +allow rhgb_t self:tcp_socket create_socket_perms; +allow rhgb_t self:udp_socket create_socket_perms; + +allow rhgb_t rhgb_devpts_t:chr_file { rw_file_perms setattr }; +term_create_pty(rhgb_t,rhgb_devpts_t) + +allow rhgb_t rhgb_tmpfs_t:dir manage_dir_perms; +allow rhgb_t rhgb_tmpfs_t:file manage_file_perms; +allow rhgb_t rhgb_tmpfs_t:lnk_file create_lnk_perms; +allow rhgb_t rhgb_tmpfs_t:sock_file manage_file_perms; +allow rhgb_t rhgb_tmpfs_t:fifo_file manage_file_perms; +fs_tmpfs_filetrans(rhgb_t,rhgb_tmpfs_t,{ dir file lnk_file sock_file fifo_file }) + +kernel_read_kernel_sysctls(rhgb_t) +kernel_read_system_state(rhgb_t) + +corecmd_exec_bin(rhgb_t) +corecmd_exec_sbin(rhgb_t) + +corenet_tcp_sendrecv_generic_if(rhgb_t) +corenet_udp_sendrecv_generic_if(rhgb_t) +corenet_raw_sendrecv_generic_if(rhgb_t) +corenet_tcp_sendrecv_all_nodes(rhgb_t) +corenet_udp_sendrecv_all_nodes(rhgb_t) +corenet_raw_sendrecv_all_nodes(rhgb_t) +corenet_tcp_sendrecv_all_ports(rhgb_t) +corenet_udp_sendrecv_all_ports(rhgb_t) +corenet_non_ipsec_sendrecv(rhgb_t) +corenet_tcp_bind_all_nodes(rhgb_t) +corenet_udp_bind_all_nodes(rhgb_t) +corenet_tcp_connect_all_ports(rhgb_t) + +dev_read_sysfs(rhgb_t) + +domain_use_interactive_fds(rhgb_t) + +files_read_etc_files(rhgb_t) +files_read_etc_runtime_files(rhgb_t) +files_search_tmp(rhgb_t) +files_read_usr_files(rhgb_t) +files_mounton_mnt(rhgb_t) +files_dontaudit_read_default_files(rhgb_t) +files_dontaudit_search_pids(rhgb_t) +# for nscd +files_dontaudit_search_var(rhgb_t) + +fs_search_auto_mountpoints(rhgb_t) +fs_mount_ramfs(rhgb_t) +fs_unmount_ramfs(rhgb_t) +# for ramfs file systems +fs_manage_ramfs_files(rhgb_t) +fs_manage_ramfs_pipes(rhgb_t) +fs_manage_ramfs_sockets(rhgb_t) + +term_dontaudit_use_console(rhgb_t) +term_use_unallocated_ttys(rhgb_t) + +init_use_fds(rhgb_t) +init_use_script_ptys(rhgb_t) +init_write_initctl(rhgb_t) + +libs_use_ld_so(rhgb_t) +libs_use_shared_libs(rhgb_t) +# for localization +libs_read_lib_files(rhgb_t) + +logging_send_syslog_msg(rhgb_t) + +miscfiles_read_localization(rhgb_t) +miscfiles_read_fonts(rhgb_t) + +sysnet_read_config(rhgb_t) + +userdom_dontaudit_use_unpriv_user_fds(rhgb_t) + +xserver_read_xdm_xserver_tmp_files(rhgb_t) +xserver_kill_xdm_xserver(rhgb_t) +# for running setxkbmap +xserver_read_xkb_libs(rhgb_t) + +ifdef(`targeted_policy',` + term_dontaudit_use_generic_ptys(rhgb_t) + files_dontaudit_read_root_files(rhgb_t) +') + +optional_policy(`firstboot',` + firstboot_read_rw_files(rhgb_t) +') + +optional_policy(`nis',` + nis_use_ypbind(rhgb_t) +') + +optional_policy(`selinuxutil',` + seutil_sigchld_newrole(rhgb_t) +') + +optional_policy(`udev',` + udev_read_db(rhgb_t) +') + +ifdef(`TODO',` + #TODO + ifdef(`hide_broken_symptoms', ` + # for a bug in the X server + dontaudit mount_t rhgb_gph_t:fd use; + ') + #TODO this seems a bit much + allow domain rhgb_devpts_t:chr_file { read write }; + #TODO this (ie files_dontaudit_read_default_files(rhgb_t))doesn't make sense with the following + allow rhgb_t default_t:file { getattr read }; + #TODO + # for gnome-pty-helper + gph_domain(rhgb, system) + allow initrc_t rhgb_gph_t:fd use; + ifdef(`hide_broken_symptoms', ` + # it should not do this + dontaudit rhgb_t { staff_home_dir_t sysadm_home_dir_t }:dir search; + ') +') diff --git a/refpolicy/policy/modules/services/xserver.if b/refpolicy/policy/modules/services/xserver.if index 01c85c1..e4ea884 100644 --- a/refpolicy/policy/modules/services/xserver.if +++ b/refpolicy/policy/modules/services/xserver.if @@ -828,3 +828,79 @@ interface(`xserver_delete_log',` allow $1 xserver_log_t:dir rw_dir_perms; allow $1 xserver_log_t:file unlink; ') + +######################################## +## +## Read X keyboard extension libraries. +## +## +## +## Domain to not audit +## +## +# +interface(`xserver_read_xkb_libs',` + gen_require(` + type xkb_var_lib_t; + ') + + files_search_var_lib($1) + allow $1 xkb_var_lib_t:dir list_dir_perms; + allow $1 xkb_var_lib_t:file r_file_perms; + allow $1 xkb_var_lib_t:lnk_file { getattr read }; +') + +######################################## +## +## Read xdm temporary files. +## +## +## +## Domain to not audit +## +## +# +interface(`xserver_read_xdm_xserver_tmp_files',` + gen_require(` + type xdm_xserver_tmp_t; + ') + + allow $1 xdm_xserver_tmp_t:file { getattr read }; +') + +######################################## +## +## Kill XDM X servers +## +## +## +## Domain to not audit +## +## +# +interface(`xserver_kill_xdm_xserver',` + gen_require(` + type xdm_xserver_t; + ') + + allow $1 xdm_xserver_t:process sigkill; +') + +######################################## +## +## Do not audit attempts to read and write to +## a XDM X server socket. +## +## +## +## Domain to not audit +## +## +# +interface(`xserver_dontaudit_rw_xdm_xserver_tcp_sockets',` + gen_require(` + type xdm_xserver_t; + ') + + dontaudit $1 xdm_xserver_t:tcp_socket { read write }; +') diff --git a/refpolicy/policy/modules/services/xserver.te b/refpolicy/policy/modules/services/xserver.te index 64e7d0c..2d7bfba 100644 --- a/refpolicy/policy/modules/services/xserver.te +++ b/refpolicy/policy/modules/services/xserver.te @@ -429,6 +429,11 @@ ifdef(`targeted_policy',` unconfined_domtrans(xdm_xserver_t) ') +optional_policy(`rhgb',` + rhgb_rw_shm(xdm_xserver_t) + rhgb_rw_tmpfs_files(xdm_xserver_t) +') + ifdef(`TODO',` allow xdm_t xconsole_device_t:fifo_file { getattr setattr }; diff --git a/refpolicy/policy/modules/system/fstools.te b/refpolicy/policy/modules/system/fstools.te index e581595..f6d0610 100644 --- a/refpolicy/policy/modules/system/fstools.te +++ b/refpolicy/policy/modules/system/fstools.te @@ -167,3 +167,8 @@ optional_policy(`cron',` optional_policy(`nis',` nis_use_ypbind(fsadm_t) ') + +optional_policy(`rhgb',` + fs_dontaudit_write_ramfs_pipes(fsadm_t) + rhgb_stub(fsadm_t) +') diff --git a/refpolicy/policy/modules/system/init.te b/refpolicy/policy/modules/system/init.te index ea78ffd..0b559a8 100644 --- a/refpolicy/policy/modules/system/init.te +++ b/refpolicy/policy/modules/system/init.te @@ -660,6 +660,11 @@ optional_policy(`quota',` optional_policy(`rhgb',` corecmd_shell_entry_type(initrc_t) + fs_write_ramfs_sockets(initrc_t) + fs_search_ramfs(initrc_t) + + rhgb_rw_stream_sockets(initrc_t) + rhgb_stream_connect(initrc_t) ') optional_policy(`rpm',` diff --git a/refpolicy/policy/modules/system/modutils.te b/refpolicy/policy/modules/system/modutils.te index 9254b81..6d863ab 100644 --- a/refpolicy/policy/modules/system/modutils.te +++ b/refpolicy/policy/modules/system/modutils.te @@ -143,6 +143,16 @@ optional_policy(`nscd',` nscd_socket_use(insmod_t) ') +optional_policy(`rhgb',` + fs_manage_ramfs_files(insmod_t) + + rhgb_use_fds(insmod_t) + + ifdef(`hide_broken_symptoms',` + xserver_dontaudit_rw_xdm_xserver_tcp_sockets(insmod_t) + ') +') + optional_policy(`rpm',` rpm_rw_pipes(insmod_t) ') diff --git a/refpolicy/policy/modules/system/mount.te b/refpolicy/policy/modules/system/mount.te index 0c77a48..190f3bd 100644 --- a/refpolicy/policy/modules/system/mount.te +++ b/refpolicy/policy/modules/system/mount.te @@ -128,6 +128,14 @@ optional_policy(`apm',` apm_use_fds(mount_t) ') +optional_policy(`rhgb',` + ifdef(`hide_broken_symptoms',` + # for a bug in the X server + rhgb_dontaudit_rw_stream_sockets(mount_t) + term_dontaudit_use_ptmx(mount_t) + ') +') + # for kernel package installation optional_policy(`rpm',` rpm_rw_pipes(mount_t)