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