8bd6789954
devices module
416 lines
11 KiB
Plaintext
416 lines
11 KiB
Plaintext
|
|
policy_module(init,1.0)
|
|
|
|
########################################
|
|
#
|
|
# Declarations
|
|
#
|
|
|
|
#
|
|
# init_t is the domain of the init process.
|
|
#
|
|
type init_t;
|
|
domain_type(init_t)
|
|
role system_r types init_t;
|
|
|
|
#
|
|
# init_exec_t is the type of the init program.
|
|
#
|
|
type init_exec_t;
|
|
kernel_userland_entry(init_t,init_exec_t)
|
|
domain_entry_file(init_t,init_exec_t)
|
|
|
|
#
|
|
# init_var_run_t is the type for /var/run/shutdown.pid.
|
|
#
|
|
type init_var_run_t;
|
|
files_pid_file(init_var_run_t)
|
|
|
|
#
|
|
# initctl_t is the type of the named pipe created
|
|
# by init during initialization. This pipe is used
|
|
# to communicate with init.
|
|
#
|
|
type initctl_t;
|
|
files_file_type(initctl_t)
|
|
|
|
type initrc_t;
|
|
domain_type(initrc_t)
|
|
role system_r types initrc_t;
|
|
|
|
type initrc_exec_t;
|
|
domain_entry_file(initrc_t,initrc_exec_t)
|
|
|
|
type initrc_devpts_t;
|
|
fs_associate(initrc_devpts_t)
|
|
fs_associate_noxattr(initrc_devpts_t)
|
|
term_pty(initrc_devpts_t)
|
|
|
|
type initrc_var_run_t;
|
|
files_pid_file(initrc_var_run_t)
|
|
|
|
type initrc_state_t;
|
|
files_file_type(initrc_state_t)
|
|
|
|
type initrc_tmp_t;
|
|
files_tmp_file(initrc_tmp_t)
|
|
|
|
########################################
|
|
#
|
|
# Init local policy
|
|
#
|
|
|
|
# Use capabilities. old rule:
|
|
allow init_t self:capability ~sys_module;
|
|
# is ~sys_module really needed? observed:
|
|
# sys_boot
|
|
# sys_tty_config
|
|
# kill: now provided by domain_kill_all_domains()
|
|
# setuid (from /sbin/shutdown)
|
|
# sys_chroot (from /usr/bin/chroot): now provided by corecmd_chroot_exec_chroot()
|
|
|
|
allow init_t self:fifo_file rw_file_perms;
|
|
|
|
# Re-exec itself
|
|
allow init_t init_exec_t:file { getattr read ioctl execute execute_no_trans };
|
|
|
|
# For /var/run/shutdown.pid.
|
|
allow init_t init_var_run_t:file { create getattr read append write setattr unlink };
|
|
files_create_pid(init_t,init_var_run_t)
|
|
|
|
allow init_t initctl_t:fifo_file { create getattr read append write setattr unlink };
|
|
fs_associate_tmpfs(initctl_t)
|
|
dev_create_dev_node(init_t,initctl_t,fifo_file)
|
|
|
|
# Modify utmp.
|
|
allow init_t initrc_var_run_t:file { rw_file_perms setattr };
|
|
|
|
# Run init scripts.
|
|
domain_auto_trans(init_t,initrc_exec_t,initrc_t)
|
|
|
|
kernel_set_boolean(init_t)
|
|
kernel_read_system_state(init_t)
|
|
dev_read_sysfs(init_t)
|
|
kernel_share_state(init_t)
|
|
|
|
term_use_all_terms(init_t)
|
|
|
|
corecmd_chroot_exec_chroot(init_t)
|
|
corecmd_exec_bin(init_t)
|
|
corecmd_exec_sbin(init_t)
|
|
|
|
domain_kill_all_domains(init_t)
|
|
domain_signal_all_domains(init_t)
|
|
domain_signull_all_domains(init_t)
|
|
domain_sigstop_all_domains(init_t)
|
|
domain_sigstop_all_domains(init_t)
|
|
domain_sigchld_all_domains(init_t)
|
|
|
|
files_read_generic_etc_files(init_t)
|
|
files_rw_generic_pids(init_t)
|
|
files_dontaudit_search_isid_type_dir(init_t)
|
|
files_manage_etc_runtime_files(init_t)
|
|
# Run /etc/X11/prefdm:
|
|
files_exec_generic_etc_files(init_t)
|
|
# file descriptors inherited from the rootfs:
|
|
files_dontaudit_rw_root_file(init_t)
|
|
files_dontaudit_rw_root_chr_dev(init_t)
|
|
|
|
libs_use_ld_so(init_t)
|
|
libs_use_shared_libs(init_t)
|
|
libs_rw_ld_so_cache(init_t)
|
|
|
|
logging_send_syslog_msg(init_t)
|
|
logging_rw_generic_logs(init_t)
|
|
|
|
selinux_read_config(init_t)
|
|
|
|
miscfiles_read_localization(init_t)
|
|
|
|
ifdef(`distro_redhat',`
|
|
fs_use_tmpfs_character_devices(init_t)
|
|
fs_create_tmpfs_data(init_t,initctl_t,fifo_file)
|
|
')
|
|
|
|
optional_policy(`authlogin.te',`
|
|
auth_rw_login_records(init_t)
|
|
')
|
|
|
|
# Run the shell in the sysadm_t domain for single-user mode.
|
|
optional_policy(`userdomain.te',`
|
|
userdom_shell_domtrans_sysadm(init_t)
|
|
')
|
|
|
|
########################################
|
|
#
|
|
# Init script local policy
|
|
#
|
|
|
|
allow initrc_t self:process { getpgid setsched setpgid setrlimit getsched };
|
|
allow initrc_t self:capability ~{ sys_admin sys_module };
|
|
allow initrc_t self:passwd rootok;
|
|
|
|
# Allow IPC with self
|
|
allow initrc_t self:unix_dgram_socket create_socket_perms;
|
|
allow initrc_t self:unix_stream_socket { create listen accept ioctl read getattr write setattr append bind connect getopt setopt shutdown connectto };
|
|
allow initrc_t self:tcp_socket create_stream_socket_perms;
|
|
allow initrc_t self:udp_socket create_socket_perms;
|
|
allow initrc_t self:fifo_file rw_file_perms;
|
|
allow initrc_t self:netlink_route_socket r_netlink_socket_perms;
|
|
|
|
allow initrc_t init_t:fd use;
|
|
|
|
allow initrc_t initrc_exec_t:file { getattr read ioctl execute execute_no_trans };
|
|
|
|
allow initrc_t initrc_state_t:dir create_dir_perms;
|
|
allow initrc_t initrc_state_t:file create_file_perms;
|
|
allow initrc_t initrc_state_t:lnk_file { create read getattr setattr unlink rename };
|
|
|
|
allow initrc_t initrc_var_run_t:file create_file_perms;
|
|
files_create_pid(initrc_t,initrc_var_run_t)
|
|
|
|
allow initrc_t initrc_tmp_t:file create_file_perms;
|
|
allow initrc_t initrc_tmp_t:dir create_dir_perms;
|
|
files_create_tmp_files(initrc_t,initrc_tmp_t, { file dir })
|
|
|
|
kernel_read_system_state(initrc_t)
|
|
kernel_read_software_raid_state(initrc_t)
|
|
kernel_read_network_state(initrc_t)
|
|
kernel_read_ring_buffer(initrc_t)
|
|
kernel_change_ring_buffer_level(initrc_t)
|
|
kernel_clear_ring_buffer(initrc_t)
|
|
kernel_get_sysvipc_info(initrc_t)
|
|
dev_read_sysfs(initrc_t)
|
|
dev_rw_sysfs(initrc_t)
|
|
kernel_read_all_sysctl(initrc_t)
|
|
kernel_rw_all_sysctl(initrc_t)
|
|
kernel_get_selinux_enforcement_mode(initrc_t)
|
|
dev_list_usbfs(initrc_t)
|
|
# for lsof which is used by alsa shutdown:
|
|
kernel_dontaudit_getattr_message_if(initrc_t)
|
|
|
|
bootloader_read_kernel_symbol_table(initrc_t)
|
|
|
|
corenet_tcp_sendrecv_all_if(initrc_t)
|
|
corenet_raw_sendrecv_all_if(initrc_t)
|
|
corenet_udp_sendrecv_all_if(initrc_t)
|
|
corenet_tcp_sendrecv_all_nodes(initrc_t)
|
|
corenet_raw_sendrecv_all_nodes(initrc_t)
|
|
corenet_udp_sendrecv_all_nodes(initrc_t)
|
|
corenet_tcp_sendrecv_all_ports(initrc_t)
|
|
corenet_udp_sendrecv_all_ports(initrc_t)
|
|
corenet_tcp_bind_all_nodes(initrc_t)
|
|
corenet_udp_bind_all_nodes(initrc_t)
|
|
|
|
dev_read_rand(initrc_t)
|
|
dev_read_urand(initrc_t)
|
|
dev_write_rand(initrc_t)
|
|
dev_write_urand(initrc_t)
|
|
dev_read_framebuffer(initrc_t)
|
|
dev_read_realtime_clock(initrc_t)
|
|
dev_read_snd_mixer_dev(initrc_t)
|
|
dev_write_snd_mixer_dev(initrc_t)
|
|
dev_setattr_all_chr_files(initrc_t)
|
|
dev_read_lvm_control(initrc_t)
|
|
dev_delete_lvm_control(initrc_t)
|
|
# Wants to remove udev.tbl:
|
|
dev_del_generic_symlinks(initrc_t)
|
|
|
|
fs_register_binary_executable_type(initrc_t)
|
|
# cjp: not sure why these are here; should use mount policy
|
|
fs_mount_all_fs(initrc_t)
|
|
fs_unmount_all_fs(initrc_t)
|
|
fs_remount_all_fs(initrc_t)
|
|
fs_getattr_all_fs(initrc_t)
|
|
|
|
storage_getattr_fixed_disk(initrc_t)
|
|
storage_setattr_fixed_disk(initrc_t)
|
|
storage_setattr_removable_device(initrc_t)
|
|
|
|
term_use_all_terms(initrc_t)
|
|
term_reset_tty_labels(initrc_t)
|
|
|
|
auth_rw_login_records(initrc_t)
|
|
auth_rw_lastlog(initrc_t)
|
|
auth_read_pam_pid(initrc_t)
|
|
auth_delete_pam_pid(initrc_t)
|
|
auth_list_pam_console_data(initrc_t)
|
|
|
|
corecmd_exec_bin(initrc_t)
|
|
corecmd_exec_sbin(initrc_t)
|
|
corecmd_exec_shell(initrc_t)
|
|
corecmd_exec_ls(initrc_t)
|
|
|
|
domain_kill_all_domains(initrc_t)
|
|
domain_signal_all_domains(initrc_t)
|
|
domain_signull_all_domains(initrc_t)
|
|
domain_sigstop_all_domains(initrc_t)
|
|
domain_sigstop_all_domains(initrc_t)
|
|
domain_sigchld_all_domains(initrc_t)
|
|
domain_read_all_domains_state(initrc_t)
|
|
domain_getsession_all_domains(initrc_t)
|
|
domain_use_wide_inherit_fd(initrc_t)
|
|
# for lsof which is used by alsa shutdown:
|
|
domain_dontaudit_getattr_all_udp_sockets(initrc_t)
|
|
domain_dontaudit_getattr_all_tcp_sockets(initrc_t)
|
|
domain_dontaudit_getattr_all_unix_dgram_sockets(initrc_t)
|
|
domain_dontaudit_getattr_all_unnamed_pipes(initrc_t)
|
|
|
|
files_getattr_all_files(initrc_t)
|
|
files_delete_all_tmp_files(initrc_t)
|
|
files_delete_all_lock_files(initrc_t)
|
|
files_read_all_pids(initrc_t)
|
|
files_delete_all_pids(initrc_t)
|
|
files_read_generic_etc_files(initrc_t)
|
|
files_manage_etc_runtime_files(initrc_t)
|
|
files_manage_generic_lock_files(initrc_t)
|
|
files_exec_generic_etc_files(initrc_t)
|
|
files_read_usr_files(initrc_t)
|
|
files_manage_urandom_seed(initrc_t)
|
|
files_manage_spools(initrc_t)
|
|
|
|
libs_rw_ld_so_cache(initrc_t)
|
|
libs_use_ld_so(initrc_t)
|
|
libs_use_shared_libs(initrc_t)
|
|
libs_exec_lib_files(initrc_t)
|
|
|
|
logging_send_syslog_msg(initrc_t)
|
|
logging_rw_generic_logs(initrc_t)
|
|
logging_read_all_logs(initrc_t)
|
|
logging_append_all_logs(initrc_t)
|
|
|
|
miscfiles_read_localization(initrc_t)
|
|
|
|
modutils_read_module_conf(initrc_t)
|
|
|
|
selinux_read_config(initrc_t)
|
|
|
|
sysnet_read_config(initrc_t)
|
|
|
|
udev_rw_db(initrc_t)
|
|
|
|
userdom_read_all_user_data(initrc_t)
|
|
# Allow access to the sysadm TTYs. Note that this will give access to the
|
|
# TTYs to any process in the initrc_t domain. Therefore, daemons and such
|
|
# started from init should be placed in their own domain.
|
|
userdom_use_sysadm_terms(initrc_t)
|
|
|
|
ifdef(`distro_debian', `
|
|
fs_create_tmpfs_data(initrc_t,initrc_var_run_t,dir)
|
|
')
|
|
|
|
ifdef(`distro_redhat',`
|
|
# this is from kmodule, which should get its own policy:
|
|
allow initrc_t self:capability sys_admin;
|
|
|
|
# Red Hat systems seem to have a stray
|
|
# fd open from the initrd
|
|
kernel_dontaudit_use_fd(initrc_t)
|
|
files_dontaudit_read_root_file(initrc_t)
|
|
|
|
kernel_set_enforcement_mode(initrc_t)
|
|
|
|
# Create and read /boot/kernel.h and /boot/System.map.
|
|
# Redhat systems typically create this file at boot time.
|
|
bootloader_create_runtime_file(initrc_t)
|
|
bootloader_rw_boot_symlinks(initrc_t)
|
|
|
|
# These seem to be from the initrd
|
|
# during device initialization:
|
|
dev_create_dir(initrc_t)
|
|
dev_rwx_zero_dev(initrc_t)
|
|
dev_rx_raw_memory(initrc_t)
|
|
dev_wx_raw_memory(initrc_t)
|
|
storage_raw_read_fixed_disk(initrc_t)
|
|
storage_raw_write_fixed_disk(initrc_t)
|
|
|
|
fs_use_tmpfs_character_devices(initrc_t)
|
|
|
|
files_create_boot_flag(initrc_t)
|
|
|
|
# readahead asks for these
|
|
mta_read_aliases(initrc_t)
|
|
')
|
|
|
|
optional_policy(`hotplug.te',`
|
|
dev_read_usbfs(initrc_t)
|
|
|
|
# init scripts run /etc/hotplug/usb.rc
|
|
hotplug_read_config(initrc_t)
|
|
|
|
modutils_read_kernel_module_dependencies(initrc_t)
|
|
')
|
|
|
|
optional_policy(`lvm.te',`
|
|
#allow initrc_t lvm_control_t:chr_file unlink;
|
|
|
|
dev_read_lvm_control(initrc_t)
|
|
dev_create_generic_chr_file(initrc_t)
|
|
')
|
|
|
|
optional_policy(`rhgb.te',`
|
|
corecmd_shell_entry_type(initrc_t)
|
|
')
|
|
|
|
optional_policy(`rpm.te',`
|
|
# bash tries to access a block device in the initrd
|
|
kernel_dontaudit_getattr_unlabeled_blk_dev(initrc_t)
|
|
|
|
# for a bug in rm
|
|
files_dontaudit_write_all_pids(initrc_t)
|
|
|
|
# bash tries ioctl for some reason
|
|
files_dontaudit_ioctl_all_pids(initrc_t)
|
|
|
|
# why is this needed:
|
|
rpm_manage_db(initrc_t)
|
|
') dnl end rpm.te
|
|
|
|
ifdef(`TODO',`
|
|
|
|
# Mount and unmount file systems.
|
|
allow initrc_t { file_t default_t }:dir { read search getattr mounton };
|
|
|
|
# Set device ownerships/modes.
|
|
allow initrc_t xconsole_device_t:fifo_file setattr;
|
|
|
|
# for lsof in shutdown scripts
|
|
can_kerberos(initrc_t)
|
|
dontaudit initrc_t krb5_conf_t:file write;
|
|
allow initrc_t krb5_conf_t:file r_file_perms;
|
|
|
|
#
|
|
# These rules are here to allow init scripts to su
|
|
#
|
|
optional_policy(`su.te', `
|
|
su_restricted_domain(initrc,system)
|
|
role system_r types initrc_su_t;
|
|
')
|
|
|
|
ifdef(`distro_debian', `
|
|
allow initrc_t { etc_t device_t }:dir setattr;
|
|
|
|
# for storing state under /dev/shm
|
|
allow initrc_t tmpfs_t:dir setattr;
|
|
file_type_auto_trans(initrc_t, tmpfs_t, fixed_disk_device_t, blk_file)
|
|
')
|
|
|
|
ifdef(`distro_redhat', `
|
|
# readahead asks for these
|
|
allow initrc_t var_lib_nfs_t:file r_file_perms;
|
|
')
|
|
|
|
ifdef(`targeted_policy', `
|
|
domain_auto_trans(unconfined_t, initrc_exec_t, initrc_t)
|
|
allow unconfined_t initrc_t:dbus { acquire_svc send_msg };
|
|
allow initrc_t unconfined_t:dbus { acquire_svc send_msg };
|
|
domain_trans(initrc_t, shell_exec_t, unconfined_t)
|
|
')
|
|
|
|
#
|
|
# Shutting down xinet causes these
|
|
#
|
|
# Rsync
|
|
dontaudit initrc_t mail_spool_t:lnk_file read;
|
|
') dnl end TODO
|