Chris PeBenito e181fe
# Copyright (C) 2005 Tresys Technology, LLC
Chris PeBenito e181fe
Chris PeBenito 960373
policy_module(bootloader,1.0)
Chris PeBenito 960373
Chris PeBenito a2d824
########################################
Chris PeBenito a2d824
#
Chris PeBenito a2d824
# Declarations
Chris PeBenito a2d824
#
Chris PeBenito a2d824
Chris PeBenito 5f75f5
attribute can_modify_kernel_modules;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# boot_t is the type for files in /boot
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
type boot_t;
Chris PeBenito b4cd15
files_make_file(boot_t)
Chris PeBenito a2d824
files_make_mountpoint(boot_t)
Chris PeBenito b4cd15
Chris PeBenito 5f75f5
#
Chris PeBenito 5f75f5
# boot_runtime_t is the type for /boot/kernel.h,
Chris PeBenito 5f75f5
# which is automatically generated at boot time.
Chris PeBenito 5f75f5
# only for Red Hat
Chris PeBenito 5f75f5
#
Chris PeBenito 70dcf7
type boot_runtime_t;
Chris PeBenito 70dcf7
files_make_file(boot_runtime_t)
Chris PeBenito 70dcf7
Chris PeBenito 5f75f5
type bootloader_t;
Chris PeBenito 5f75f5
domain_make_domain(bootloader_t)
Chris PeBenito 5f75f5
Chris PeBenito 5f75f5
type bootloader_exec_t;
Chris PeBenito 5f75f5
domain_make_entrypoint_file(bootloader_t,bootloader_exec_t)
Chris PeBenito 5f75f5
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# bootloader_etc_t is the configuration file,
Chris PeBenito b4cd15
# grub.conf, lilo.conf, etc.
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
type bootloader_etc_t alias etc_bootloader_t;
Chris PeBenito b4cd15
files_make_file(bootloader_etc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# The temp file is used for initrd creation;
Chris PeBenito b4cd15
# it consists of files and device nodes
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
type bootloader_tmp_t;
Chris PeBenito b4cd15
files_make_file(bootloader_tmp_t)
Chris PeBenito b4cd15
devices_make_device_node(bootloader_tmp_t)
Chris PeBenito b4cd15
Chris PeBenito 5f75f5
# kernel modules
Chris PeBenito 5f75f5
type modules_object_t;
Chris PeBenito 5f75f5
files_make_file(modules_object_t)
Chris PeBenito 5f75f5
Chris PeBenito 5f75f5
neverallow ~can_modify_kernel_modules modules_object_t:file { create append write };
Chris PeBenito 5f75f5
Chris PeBenito 5f75f5
#
Chris PeBenito 5f75f5
# system_map_t is for the system.map files in /boot
Chris PeBenito 5f75f5
#
Chris PeBenito 5f75f5
type system_map_t;
Chris PeBenito 5f75f5
files_make_file(system_map_t)
Chris PeBenito 5f75f5
Chris PeBenito 8a0da1
########################################
Chris PeBenito 8a0da1
#
Chris PeBenito 8a0da1
# bootloader local policy
Chris PeBenito 8a0da1
#
Chris PeBenito 8a0da1
Chris PeBenito b4cd15
allow bootloader_t self:capability { dac_read_search fsetid sys_rawio sys_admin mknod chown };
Chris PeBenito b4cd15
allow bootloader_t self:process { sigkill sigstop signull signal };
Chris PeBenito b4cd15
allow bootloader_t self:fifo_file { getattr read write };
Chris PeBenito b4cd15
Chris PeBenito a266e3
kernel_get_core_interface_attributes(bootloader_t)
Chris PeBenito b4cd15
kernel_read_system_state(bootloader_t)
Chris PeBenito b4cd15
kernel_read_software_raid_state(bootloader_t)
Chris PeBenito b4cd15
kernel_read_kernel_sysctl(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
storage_raw_read_fixed_disk(bootloader_t)
Chris PeBenito b4cd15
storage_raw_write_fixed_disk(bootloader_t)
Chris PeBenito b4cd15
storage_raw_read_removable_device(bootloader_t)
Chris PeBenito b4cd15
storage_raw_write_removable_device(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito a266e3
devices_get_all_character_device_attributes(bootloader_t)
Chris PeBenito a266e3
devices_set_all_block_device_attributes(bootloader_t)
Chris PeBenito b4cd15
# for reading BIOS data (cjp: ?)
Chris PeBenito b4cd15
devices_raw_read_memory(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito a2d824
init_get_control_channel_attributes(bootloader_t)
Chris PeBenito a2d824
init_script_use_pseudoterminal(bootloader_t)
Chris PeBenito a2d824
init_script_use_file_descriptors(bootloader_t)
Chris PeBenito a2d824
Chris PeBenito a2d824
domain_use_widely_inheritable_file_descriptors(bootloader_t)
Chris PeBenito a2d824
Chris PeBenito b4cd15
libraries_use_dynamic_loader(bootloader_t)
Chris PeBenito b4cd15
libraries_read_shared_libraries(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
files_read_general_system_config(bootloader_t)
Chris PeBenito b4cd15
files_read_runtime_system_config(bootloader_t)
Chris PeBenito b4cd15
files_read_system_source_code(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito bf9e1e
logging_send_system_log_message(bootloader_t)
Chris PeBenito bf9e1e
Chris PeBenito b4cd15
# uncomment the following line if you use "lilo -p"
Chris PeBenito b4cd15
#files_create_private_config(bootloader_t,bootloader_etc_t)
Chris PeBenito b4cd15
#allow bootloader_t bootloader_etc_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito b4cd15
Chris PeBenito 219bcf
filesystem_get_persistent_filesystem_attributes(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
terminal_use_controlling_terminal(bootloader_t)
Chris PeBenito a2d824
terminal_get_user_terminal_attributes(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow bootloader_t bootloader_etc_t:file { getattr read };
Chris PeBenito b4cd15
Chris PeBenito a2d824
optional_policy(modutils.te,`
Chris PeBenito b4cd15
modutils_insmod_execute(insmod_t)
Chris PeBenito b4cd15
')
Chris PeBenito b4cd15
Chris PeBenito b4cd15
miscfiles_read_localization(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
devices_ignore_modify_generic_devices(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
########################################
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# mkinitrd policy
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito 5f75f5
allow bootloader_t modules_object_t:dir { getattr search read };
Chris PeBenito 5f75f5
allow bootloader_t modules_object_t:file { getattr read };
Chris PeBenito 5f75f5
Chris PeBenito b4cd15
files_read_general_system_resources(bootloader_t)
Chris PeBenito b4cd15
bootloader_install_initrd(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
devices_get_random_data(bootloader_t)
Chris PeBenito b4cd15
devices_get_pseudorandom_data(bootloader_t)
Chris PeBenito a2d824
Chris PeBenito b4cd15
corecommands_execute_general_programs(bootloader_t)
Chris PeBenito b4cd15
corecommands_execute_system_programs(bootloader_t)
Chris PeBenito b4cd15
corecommands_execute_shell(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
selinux_read_binary_policy(bootloader_t)
Chris PeBenito b4cd15
selinux_read_load_policy_binary(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
modutils_read_kernel_module_dependencies(bootloader_t)
Chris PeBenito b4cd15
modutils_read_kernel_module_loading_config(bootloader_t)
Chris PeBenito bf9e1e
modutils_insmod_execute(bootloader_t)
Chris PeBenito bf9e1e
modutils_depmod_execute(bootloader_t)
Chris PeBenito bf9e1e
modutils_update_modules_execute(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
logging_modify_system_logs(bootloader_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
files_create_private_tmp_data(bootloader_t,bootloader_tmp_t,{ dir file lnk_file chr_file blk_file })
Chris PeBenito b4cd15
allow bootloader_t bootloader_tmp_t:dir { create read getattr lock setattr ioctl link unlink rename search add_name remove_name reparent write rmdir };
Chris PeBenito b4cd15
allow bootloader_t bootloader_tmp_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito b4cd15
allow bootloader_t bootloader_tmp_t:chr_file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito b4cd15
allow bootloader_t bootloader_tmp_t:blk_file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito b4cd15
allow bootloader_t bootloader_tmp_t:lnk_file { create read getattr setattr unlink rename };
Chris PeBenito b4cd15
# for tune2fs (cjp: ?)
Chris PeBenito b4cd15
files_create_private_root_dir_entry(bootloader_t,bootloader_tmp_t)
Chris PeBenito b4cd15
Chris PeBenito 300981
optional_policy(`fsadm.te', `
Chris PeBenito 8a0da1
filesystemtools_execute(bootloader_t)
Chris PeBenito 8a0da1
')
Chris PeBenito 8a0da1
Chris PeBenito a2d824
ifdef(`distro_debian', `
Chris PeBenito a2d824
allow bootloader_t bootloader_tmp_t:{ dir file } { relabelfrom relabelto };
Chris PeBenito a2d824
allow bootloader_t modules_object_t:file { relabelfrom relabelto unlink };
Chris PeBenito a2d824
allow bootloader_t boot_t:file relabelfrom;
Chris PeBenito a2d824
')
Chris PeBenito a2d824
Chris PeBenito a2d824
ifdef(`distro_redhat', `
Chris PeBenito a2d824
files_make_mountpoint(bootloader_tmp_t)
Chris PeBenito a2d824
Chris PeBenito a2d824
# for mke2fs
Chris PeBenito a2d824
mount_transition(bootloader_t)
Chris PeBenito a2d824
allow bootloader_t modules_object_t:lnk_file { getattr read };
Chris PeBenito a2d824
Chris PeBenito a2d824
# new file system defaults to file_t, granting file_t access is still bad.
Chris PeBenito a2d824
allow bootloader_t self:unix_stream_socket { create ioctl read getattr write setattr append bind getopt setopt shutdown };
Chris PeBenito a2d824
allow bootloader_t boot_runtime_t:file { read getattr unlink };
Chris PeBenito a2d824
Chris PeBenito a2d824
# for memlock
Chris PeBenito a2d824
devices_get_zeros(bootloader_t)
Chris PeBenito a2d824
allow bootloader_t self:capability ipc_lock;
Chris PeBenito a2d824
')
Chris PeBenito a2d824
Chris PeBenito b4cd15
ifdef(`TODO',`
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# admin runs bootloader:
Chris PeBenito b4cd15
domain_auto_trans(sysadm_t, bootloader_exec_t, bootloader_t)
Chris PeBenito b4cd15
allow bootloader_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
role system_r types bootloader_t;
Chris PeBenito b4cd15
allow bootloader_t initrc_t:fifo_file { read write };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow bootloader_t lib_t:file { getattr read };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow bootloader_t sysfs_t:dir getattr;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow bootloader_t var_t:dir search;
Chris PeBenito b4cd15
allow bootloader_t var_t:file { getattr read };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# LVM2 / Device Mapper's /dev/mapper/control
Chris PeBenito b4cd15
# maybe we should change the labeling for this
Chris PeBenito a2d824
optional_policy(`lvm.te', `
Chris PeBenito a2d824
lvm_transition(bootloader_t)
Chris PeBenito b4cd15
allow bootloader_t lvm_control_t:chr_file rw_file_perms;
Chris PeBenito b4cd15
allow lvm_t bootloader_tmp_t:file rw_file_perms;
Chris PeBenito b4cd15
r_dir_file(bootloader_t, lvm_etc_t)
Chris PeBenito b4cd15
')
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`distro_debian', `
Chris PeBenito b4cd15
allow bootloader_t { usr_t lib_t fsadm_exec_t }:file relabelto;
Chris PeBenito b4cd15
allow bootloader_t { usr_t lib_t fsadm_exec_t }:file create_file_perms;
Chris PeBenito b4cd15
allow bootloader_t tmpfs_t:dir r_dir_perms;
Chris PeBenito b4cd15
allow bootloader_t initrc_var_run_t:dir r_dir_perms;
Chris PeBenito b4cd15
allow bootloader_t var_lib_t:dir search;
Chris PeBenito b4cd15
allow bootloader_t dpkg_var_lib_t:dir r_dir_perms;
Chris PeBenito b4cd15
allow bootloader_t dpkg_var_lib_t:file { getattr read };
Chris PeBenito b4cd15
# for /usr/share/initrd-tools/scripts
Chris PeBenito b4cd15
can_exec(bootloader_t, usr_t)
Chris PeBenito b4cd15
')
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`distro_redhat', `
Chris PeBenito b4cd15
# new file system defaults to file_t, granting file_t access is still bad.
Chris PeBenito b4cd15
allow bootloader_t file_t:dir create_dir_perms;
Chris PeBenito b4cd15
allow bootloader_t file_t:{ file blk_file chr_file } create_file_perms;
Chris PeBenito b4cd15
allow bootloader_t file_t:lnk_file create_lnk_perms;
Chris PeBenito b4cd15
')
Chris PeBenito b4cd15
Chris PeBenito b4cd15
dontaudit bootloader_t selinux_config_t:dir search;
Chris PeBenito b4cd15
dontaudit bootloader_t { staff_home_dir_t sysadm_home_dir_t }:dir search;
Chris PeBenito b4cd15
dontaudit bootloader_t devpts_t:dir create_dir_perms;
Chris PeBenito b4cd15
# for nscd
Chris PeBenito b4cd15
dontaudit bootloader_t var_run_t:dir search;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
') dnl end TODO