Chris PeBenito 31b7c0
#DESC Modutil - Dynamic module utilities
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser  
Chris PeBenito 31b7c0
# X-Debian-Packages: modutils
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the module utility domains.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
type modules_dep_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
type modules_conf_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
type modules_object_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`IS_INITRD', `', `
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the depmod_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
type depmod_t, domain;
Chris PeBenito 31b7c0
role system_r types depmod_t;
Chris PeBenito 31b7c0
role sysadm_r types depmod_t;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
uses_shlib(depmod_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
r_dir_file(depmod_t, src_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
type depmod_exec_t, file_type, exec_type, sysadmfile;
Chris PeBenito 31b7c0
domain_auto_trans(initrc_t, depmod_exec_t, depmod_t)
Chris PeBenito 31b7c0
allow depmod_t { bin_t sbin_t }:dir search;
Chris PeBenito 31b7c0
can_exec(depmod_t, depmod_exec_t)
Chris PeBenito 31b7c0
ifdef(`targeted_policy', `', `
Chris PeBenito 31b7c0
domain_auto_trans(sysadm_t, depmod_exec_t, depmod_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Inherit and use descriptors from init and login programs.
Chris PeBenito 31b7c0
allow depmod_t { init_t privfd }:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow depmod_t { etc_t etc_runtime_t }:file { getattr read };
Chris PeBenito 31b7c0
allow depmod_t { device_t proc_t }:dir search;
Chris PeBenito 31b7c0
allow depmod_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
allow depmod_t fs_t:filesystem getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# read system.map
Chris PeBenito 31b7c0
allow depmod_t boot_t:dir search;
Chris PeBenito 31b7c0
allow depmod_t boot_t:file { getattr read };
Chris PeBenito 31b7c0
allow depmod_t system_map_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read conf.modules.
Chris PeBenito 31b7c0
allow depmod_t modules_conf_t:file r_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Create modules.dep.
Chris PeBenito 31b7c0
file_type_auto_trans(depmod_t, modules_object_t, modules_dep_t, file)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read module objects.
Chris PeBenito 31b7c0
allow depmod_t modules_object_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow depmod_t modules_object_t:{ file lnk_file } r_file_perms;
Chris PeBenito 31b7c0
allow depmod_t modules_object_t:file unlink;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access terminals.
Chris PeBenito 31b7c0
can_access_pty(depmod_t, initrc)
Chris PeBenito 31b7c0
allow depmod_t { console_device_t admin_tty_type }:chr_file rw_file_perms;
Chris PeBenito 31b7c0
ifdef(`gnome-pty-helper.te', `allow depmod_t sysadm_gph_t:fd use;')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read System.map from home directories.
Chris PeBenito 31b7c0
allow depmod_t { home_root_t staff_home_dir_t sysadm_home_dir_t }:dir r_dir_perms;
Chris PeBenito 31b7c0
r_dir_file(depmod_t, { staff_home_t sysadm_home_t })
Chris PeBenito 31b7c0
')dnl end IS_INITRD
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the insmod_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
type insmod_t, domain, privlog, sysctl_kernel_writer, privmem, privsysmod ifdef(`unlimitedUtils', `, admin, etc_writer, fs_domain, auth_write, privowner, privmodule' ), mlsfilewrite, nscd_client_domain
Chris PeBenito 31b7c0
;
Chris PeBenito 31b7c0
role system_r types insmod_t;
Chris PeBenito 31b7c0
role sysadm_r types insmod_t;
Chris PeBenito 31b7c0
type insmod_exec_t, file_type, exec_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
bool secure_mode_insmod false;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
can_ypbind(insmod_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`unlimitedUtils', `
Chris PeBenito 31b7c0
unconfined_domain(insmod_t) 
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
uses_shlib(insmod_t)
Chris PeBenito 31b7c0
read_locale(insmod_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for SSP
Chris PeBenito 31b7c0
allow insmod_t urandom_device_t:chr_file read;
Chris PeBenito 31b7c0
allow insmod_t lib_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t { bin_t sbin_t }:dir search;
Chris PeBenito 31b7c0
allow insmod_t { bin_t sbin_t }:lnk_file read;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t self:dir search;
Chris PeBenito 31b7c0
allow insmod_t self:lnk_file read;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t usr_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t privfd:fd use;
Chris PeBenito 31b7c0
can_access_pty(insmod_t, initrc)
Chris PeBenito 31b7c0
allow insmod_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito 31b7c0
ifdef(`gnome-pty-helper.te', `allow insmod_t sysadm_gph_t:fd use;')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t { agp_device_t apm_bios_t }:chr_file { read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t sound_device_t:chr_file { read ioctl write };
Chris PeBenito 31b7c0
allow insmod_t zero_device_t:chr_file read;
Chris PeBenito 31b7c0
allow insmod_t memory_device_t:chr_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read module config and dependency information
Chris PeBenito 31b7c0
allow insmod_t { modules_conf_t modules_dep_t }:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read module objects.
Chris PeBenito 31b7c0
r_dir_file(insmod_t, modules_object_t)
Chris PeBenito 31b7c0
# for locking
Chris PeBenito 31b7c0
allow insmod_t modules_object_t:file write;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t { var_t var_log_t }:dir search;
Chris PeBenito 31b7c0
ifdef(`xserver.te', `
Chris PeBenito 31b7c0
allow insmod_t xserver_log_t:file getattr;
Chris PeBenito 31b7c0
allow insmod_t xserver_misc_device_t:chr_file { read write };
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
rw_dir_create_file(insmod_t, var_log_ksyms_t)
Chris PeBenito 31b7c0
allow insmod_t { etc_t etc_runtime_t }:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t self:udp_socket create_socket_perms;
Chris PeBenito 31b7c0
allow insmod_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 31b7c0
allow insmod_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
allow insmod_t self:rawip_socket create_socket_perms;
Chris PeBenito 31b7c0
allow insmod_t self:capability { dac_override kill net_raw sys_tty_config };
Chris PeBenito 31b7c0
allow insmod_t domain:process signal;
Chris PeBenito 31b7c0
allow insmod_t self:process { fork signal_perms };
Chris PeBenito 31b7c0
allow insmod_t device_t:dir search;
Chris PeBenito 31b7c0
allow insmod_t etc_runtime_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for loading modules at boot time
Chris PeBenito 31b7c0
allow insmod_t { init_t initrc_t }:fd use;
Chris PeBenito 31b7c0
allow insmod_t initrc_t:fifo_file { getattr read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t fs_t:filesystem getattr;
Chris PeBenito 31b7c0
allow insmod_t sysfs_t:dir search;
Chris PeBenito 31b7c0
allow insmod_t { usbfs_t usbdevfs_t }:dir search;
Chris PeBenito 31b7c0
allow insmod_t { usbfs_t usbdevfs_t debugfs_t }:filesystem mount;
Chris PeBenito 31b7c0
r_dir_file(insmod_t, debugfs_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Rules for /proc/sys/kernel/tainted
Chris PeBenito 31b7c0
read_sysctl(insmod_t)
Chris PeBenito 31b7c0
allow insmod_t proc_t:dir search;
Chris PeBenito 31b7c0
allow insmod_t sysctl_kernel_t:file { setattr rw_file_perms };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t proc_t:file rw_file_perms;
Chris PeBenito 31b7c0
allow insmod_t proc_t:lnk_file read;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Write to /proc/mtrr.
Chris PeBenito 31b7c0
allow insmod_t mtrr_device_t:file write;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read /proc/sys/kernel/hotplug.
Chris PeBenito 31b7c0
allow insmod_t sysctl_hotplug_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow insmod_t device_t:dir read;
Chris PeBenito 31b7c0
allow insmod_t devpts_t:dir { getattr search };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
if (!secure_mode_insmod) {
Chris PeBenito 31b7c0
domain_auto_trans(privmodule, insmod_exec_t, insmod_t)
Chris PeBenito 31b7c0
allow insmod_t self:capability sys_module;
Chris PeBenito 31b7c0
}dnl end if !secure_mode_insmod
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
can_exec(insmod_t, { insmod_exec_t shell_exec_t bin_t sbin_t etc_t })
Chris PeBenito 31b7c0
allow insmod_t devtty_t:chr_file rw_file_perms;
Chris PeBenito 31b7c0
allow insmod_t privmodule:process sigchld;
Chris PeBenito 31b7c0
dontaudit sysadm_t self:capability sys_module;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`mount.te', `
Chris PeBenito 31b7c0
# Run mount in the mount_t domain.
Chris PeBenito 31b7c0
domain_auto_trans(insmod_t, mount_exec_t, mount_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
# for when /var is not mounted early in the boot
Chris PeBenito 31b7c0
dontaudit insmod_t file_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for nscd
Chris PeBenito 31b7c0
dontaudit insmod_t var_run_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`crond.te', `
Chris PeBenito 31b7c0
rw_dir_create_file(system_crond_t, var_log_ksyms_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`IS_INITRD', `', `
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the update_modules_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
type update_modules_t, domain, privlog;
Chris PeBenito 31b7c0
type update_modules_exec_t, file_type, exec_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
role system_r types update_modules_t;
Chris PeBenito 31b7c0
role sysadm_r types update_modules_t;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
domain_auto_trans({ initrc_t sysadm_t }, update_modules_exec_t, update_modules_t)
Chris PeBenito 31b7c0
allow update_modules_t privfd:fd use;
Chris PeBenito 31b7c0
allow update_modules_t init_t:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow update_modules_t device_t:dir { getattr search };
Chris PeBenito 31b7c0
allow update_modules_t { console_device_t devtty_t }:chr_file rw_file_perms;
Chris PeBenito 31b7c0
can_access_pty(update_modules_t, initrc)
Chris PeBenito 31b7c0
allow update_modules_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
can_exec(update_modules_t, insmod_exec_t)
Chris PeBenito 31b7c0
allow update_modules_t urandom_device_t:chr_file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
dontaudit update_modules_t sysadm_home_dir_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
uses_shlib(update_modules_t)
Chris PeBenito 31b7c0
read_locale(update_modules_t)
Chris PeBenito 31b7c0
allow update_modules_t lib_t:file { getattr read };
Chris PeBenito 31b7c0
allow update_modules_t self:process { fork sigchld };
Chris PeBenito 31b7c0
allow update_modules_t self:fifo_file rw_file_perms;
Chris PeBenito 31b7c0
allow update_modules_t self:file { getattr read };
Chris PeBenito 31b7c0
allow update_modules_t modules_dep_t:file rw_file_perms;
Chris PeBenito 31b7c0
file_type_auto_trans(update_modules_t, modules_object_t, modules_conf_t, file)
Chris PeBenito 31b7c0
domain_auto_trans(update_modules_t, depmod_exec_t, depmod_t)
Chris PeBenito 31b7c0
can_exec(update_modules_t, { shell_exec_t bin_t sbin_t update_modules_exec_t etc_t })
Chris PeBenito 31b7c0
allow update_modules_t { sbin_t bin_t }:lnk_file read;
Chris PeBenito 31b7c0
allow update_modules_t { sbin_t bin_t }:dir search;
Chris PeBenito 31b7c0
allow update_modules_t { etc_t etc_runtime_t }:file r_file_perms;
Chris PeBenito 31b7c0
allow update_modules_t etc_t:lnk_file read;
Chris PeBenito 31b7c0
allow update_modules_t fs_t:filesystem getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow update_modules_t proc_t:dir search;
Chris PeBenito 31b7c0
allow update_modules_t proc_t:file r_file_perms;
Chris PeBenito 31b7c0
allow update_modules_t { self proc_t }:lnk_file read;
Chris PeBenito 31b7c0
read_sysctl(update_modules_t)
Chris PeBenito 31b7c0
allow update_modules_t self:dir search;
Chris PeBenito 31b7c0
allow update_modules_t self:unix_stream_socket create_socket_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
file_type_auto_trans(update_modules_t, etc_t, modules_conf_t, file)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
tmp_domain(update_modules)
Chris PeBenito 31b7c0
')dnl end IS_INITRD