Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Macros for X server domains.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#################################
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# xserver_domain(domain_prefix)
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Define a derived domain for the X server when executed
Chris PeBenito 0fbfa5
# by a user domain (e.g. via startx).  See the xdm_t domain
Chris PeBenito 0fbfa5
# in domains/program/xdm.te if using an X Display Manager.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# The type declarations for the executable type for this program 
Chris PeBenito 0fbfa5
# and the log type are provided separately in domains/program/xserver.te. 
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# FIXME!  The X server requires far too many privileges.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
undefine(`xserver_domain')
Chris PeBenito 0fbfa5
ifdef(`xserver.te', `
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
define(`xserver_domain',`
Chris PeBenito 0fbfa5
# Derived domain based on the calling user domain and the program.
Chris PeBenito 0fbfa5
ifdef(`distro_redhat', `
Chris PeBenito 0fbfa5
type $1_xserver_t, domain, privlog, privmem, privmodule, nscd_client_domain;
Chris PeBenito 0fbfa5
allow $1_xserver_t sysctl_modprobe_t:file { getattr read };
Chris PeBenito 0fbfa5
ifdef(`rpm.te', `
Chris PeBenito 0fbfa5
allow $1_xserver_t rpm_t:shm { unix_read unix_write read write associate getattr };
Chris PeBenito 0fbfa5
allow $1_xserver_t rpm_tmpfs_t:file { read write };
Chris PeBenito 0fbfa5
allow $1_xserver_t rpm_t:fd use;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
type $1_xserver_t, domain, privlog, privmem, nscd_client_domain;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for SSP
Chris PeBenito 0fbfa5
allow $1_xserver_t urandom_device_t:chr_file { getattr read ioctl };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Transition from the user domain to this domain.
Chris PeBenito 0fbfa5
ifelse($1, xdm, `
Chris PeBenito 0fbfa5
ifdef(`xdm.te', `
Chris PeBenito 0fbfa5
domain_auto_trans(xdm_t, xserver_exec_t, xdm_xserver_t)
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
domain_auto_trans($1_t, xserver_exec_t, $1_xserver_t)
Chris PeBenito 0fbfa5
')dnl end ifelse xdm
Chris PeBenito 0fbfa5
can_exec($1_xserver_t, xserver_exec_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
uses_shlib($1_xserver_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t texrel_shlib_t:file execmod;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
can_network($1_xserver_t)
Chris PeBenito 2705f9
allow $1_xserver_t port_type:tcp_socket name_connect;
Chris PeBenito 0fbfa5
can_ypbind($1_xserver_t)
Chris PeBenito 0fbfa5
allow $1_xserver_t xserver_port_t:tcp_socket name_bind;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for access within the domain
Chris PeBenito 0fbfa5
general_domain_access($1_xserver_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t self:process execmem;
Chris PeBenito 2705f9
# Until the X module loader is fixed.
Chris PeBenito 2705f9
allow $1_xserver_t self:process execheap;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t etc_runtime_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifelse($1, xdm, `
Chris PeBenito 0fbfa5
# The system role is authorised for the xdm and initrc domains
Chris PeBenito 0fbfa5
role system_r types xdm_xserver_t;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow xdm_xserver_t init_t:fd use;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
dontaudit xdm_xserver_t home_dir_type:dir { read search };
Chris PeBenito 2705f9
Chris PeBenito 2705f9
# Read all global and per user fonts
Chris PeBenito 2705f9
read_fonts($1_xserver_t, sysadm)
Chris PeBenito 2705f9
read_fonts($1_xserver_t, staff)
Chris PeBenito 2705f9
read_fonts($1_xserver_t, user)
Chris PeBenito 2705f9
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
# The user role is authorized for this domain.
Chris PeBenito 0fbfa5
role $1_r types $1_xserver_t;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t getty_t:fd use;
Chris PeBenito 0fbfa5
allow $1_xserver_t local_login_t:fd use;
Chris PeBenito 0fbfa5
allow $1_xserver_t $1_tty_device_t:chr_file { setattr rw_file_perms };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t $1_tmpfs_t:file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_t $1_xserver_tmpfs_t:file rw_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
can_unix_connect($1_t, $1_xserver_t)
Chris PeBenito 0fbfa5
Chris PeBenito 2705f9
# Read fonts
Chris PeBenito 2705f9
read_fonts($1_xserver_t, $1)
Chris PeBenito 2705f9
Chris PeBenito 0fbfa5
# Access the home directory.
Chris PeBenito 0fbfa5
allow $1_xserver_t home_root_t:dir search;
Chris PeBenito 0fbfa5
allow $1_xserver_t $1_home_dir_t:dir { getattr search };
Chris PeBenito 2705f9
Chris PeBenito 0fbfa5
ifdef(`xauth.te', `
Chris PeBenito 0fbfa5
domain_auto_trans($1_xserver_t, xauth_exec_t, $1_xauth_t)
Chris PeBenito 0fbfa5
allow $1_xserver_t $1_xauth_home_t:file { getattr read };
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
allow $1_xserver_t $1_home_t:file { getattr read };
Chris PeBenito 0fbfa5
')dnl end ifdef xauth
Chris PeBenito 0fbfa5
ifdef(`userhelper.te', `
Chris PeBenito 0fbfa5
allow $1_xserver_t userhelper_conf_t:dir search;
Chris PeBenito 0fbfa5
')dnl end ifdef userhelper
Chris PeBenito 0fbfa5
')dnl end ifelse xdm
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t self:process setsched;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t fs_t:filesystem getattr;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Xorg wants to check if kernel is tainted
Chris PeBenito 0fbfa5
read_sysctl($1_xserver_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Use capabilities.
Chris PeBenito 0fbfa5
# allow setuid/setgid for the wrapper program to change UID
Chris PeBenito 0fbfa5
# sys_rawio is for iopl access - should not be needed for frame-buffer
Chris PeBenito 0fbfa5
# sys_admin, locking shared mem?  chowning IPC message queues or semaphores?
Chris PeBenito 0fbfa5
# admin of APM bios?
Chris PeBenito 0fbfa5
# sys_nice is so that the X server can set a negative nice value
Chris PeBenito 0fbfa5
allow $1_xserver_t self:capability { dac_override fsetid setgid setuid ipc_owner sys_rawio sys_admin sys_nice sys_tty_config mknod net_bind_service };
Chris PeBenito 0fbfa5
allow $1_xserver_t nfs_t:dir { getattr search };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# memory_device_t access is needed if not using the frame buffer
Chris PeBenito 0fbfa5
#dontaudit $1_xserver_t memory_device_t:chr_file read;
Chris PeBenito 0fbfa5
allow $1_xserver_t memory_device_t:chr_file { rw_file_perms execute };
Chris PeBenito 0fbfa5
# net_bind_service is needed if you want your X server to allow TCP connections
Chris PeBenito 0fbfa5
# from other hosts, EG an XDM serving a network of X terms
Chris PeBenito 0fbfa5
# if you want good security you do not want this
Chris PeBenito 0fbfa5
# not sure why some people want chown, fsetid, and sys_tty_config.
Chris PeBenito 0fbfa5
#allow $1_xserver_t self:capability { net_bind_service chown fsetid sys_tty_config };
Chris PeBenito 0fbfa5
dontaudit $1_xserver_t self:capability chown;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for nscd
Chris PeBenito 0fbfa5
dontaudit $1_xserver_t var_run_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t mtrr_device_t:file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_xserver_t apm_bios_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_xserver_t framebuf_device_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_xserver_t device_t:lnk_file { getattr read };
Chris PeBenito 0fbfa5
allow $1_xserver_t devtty_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_xserver_t zero_device_t:chr_file { read write execute };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Type for temporary files.
Chris PeBenito 0fbfa5
tmp_domain($1_xserver, `', `{ dir file sock_file }')
Chris PeBenito 0fbfa5
file_type_auto_trans($1_xserver_t, xdm_xserver_tmp_t, $1_xserver_tmp_t, sock_file)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifelse($1, xdm, `
Chris PeBenito 0fbfa5
ifdef(`xdm.te', `
Chris PeBenito 0fbfa5
allow xdm_t xdm_xserver_tmp_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow xdm_t xdm_xserver_t:unix_stream_socket connectto;
Chris PeBenito 0fbfa5
allow xdm_t $1_xserver_t:process signal;
Chris PeBenito 0fbfa5
can_unix_connect(xdm_t, xdm_xserver_t)
Chris PeBenito 0fbfa5
allow xdm_t xdm_xserver_tmp_t:sock_file rw_file_perms;
Chris PeBenito 0fbfa5
allow xdm_t xdm_xserver_tmp_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow xdm_xserver_t xdm_t:process signal;
Chris PeBenito 0fbfa5
allow xdm_xserver_t xdm_t:shm rw_shm_perms;
Chris PeBenito 0fbfa5
allow xdm_t xdm_xserver_t:shm rw_shm_perms;
Chris PeBenito 0fbfa5
dontaudit xdm_xserver_t sysadm_t:shm { unix_read unix_write };
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
allow $1_t xdm_xserver_tmp_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_t xdm_xserver_t:unix_stream_socket connectto;
Chris PeBenito 0fbfa5
allow $1_t $1_xserver_t:process signal;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow the user domain to connect to the X server.
Chris PeBenito 0fbfa5
can_unix_connect($1_t, $1_xserver_t)
Chris PeBenito 0fbfa5
allow $1_t $1_xserver_tmp_t:sock_file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_t $1_xserver_tmp_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
ifdef(`xdm.te', `
Chris PeBenito 0fbfa5
allow $1_t xdm_tmp_t:sock_file unlink;
Chris PeBenito 0fbfa5
allow $1_xserver_t xdm_var_run_t:dir search;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Signal the user domain.
Chris PeBenito 0fbfa5
allow $1_xserver_t $1_t:process signal;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Communicate via System V shared memory.
Chris PeBenito 0fbfa5
allow $1_xserver_t $1_t:shm rw_shm_perms;
Chris PeBenito 0fbfa5
allow $1_t $1_xserver_t:shm rw_shm_perms;
Chris PeBenito 0fbfa5
allow $1_xserver_t initrc_t:shm rw_shm_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
')dnl end ifelse xdm
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Create files in /var/log with the xserver_log_t type.
Chris PeBenito 0fbfa5
allow $1_xserver_t var_t:dir search;
Chris PeBenito 0fbfa5
file_type_auto_trans($1_xserver_t, var_log_t, xserver_log_t, file)
Chris PeBenito 0fbfa5
allow $1_xserver_t xserver_log_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Access AGP device.
Chris PeBenito 0fbfa5
allow $1_xserver_t agp_device_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for other device nodes such as the NVidia binary-only driver
Chris PeBenito 0fbfa5
allow $1_xserver_t xserver_misc_device_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Access /proc/mtrr
Chris PeBenito 0fbfa5
allow $1_xserver_t proc_t:file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_xserver_t proc_t:lnk_file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Access /proc/sys/dev
Chris PeBenito 0fbfa5
allow $1_xserver_t sysctl_dev_t:dir search;
Chris PeBenito 0fbfa5
allow $1_xserver_t sysctl_dev_t:file { getattr read };
Chris PeBenito 0fbfa5
# Access /proc/bus/pci
Chris PeBenito 0fbfa5
allow $1_xserver_t proc_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Create and access /dev/dri devices.
Chris PeBenito 0fbfa5
allow $1_xserver_t device_t:dir { create setattr };
Chris PeBenito 0fbfa5
file_type_auto_trans($1_xserver_t, device_t, dri_device_t, chr_file)
Chris PeBenito 0fbfa5
# brought on by rhgb
Chris PeBenito 0fbfa5
allow $1_xserver_t mnt_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t tty_device_t:chr_file { setattr rw_file_perms };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Run helper programs in $1_xserver_t.
Chris PeBenito 0fbfa5
allow $1_xserver_t { bin_t sbin_t }:dir search;
Chris PeBenito 0fbfa5
allow $1_xserver_t etc_t:{ file lnk_file } { getattr read };
Chris PeBenito 0fbfa5
allow $1_xserver_t bin_t:lnk_file read;
Chris PeBenito 0fbfa5
can_exec($1_xserver_t, { bin_t shell_exec_t })
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Connect to xfs.
Chris PeBenito 0fbfa5
ifdef(`xfs.te', `
Chris PeBenito 0fbfa5
can_unix_connect($1_xserver_t, xfs_t)
Chris PeBenito 0fbfa5
allow $1_xserver_t xfs_tmp_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_xserver_t xfs_tmp_t:sock_file rw_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Bind to the X server socket in /tmp.
Chris PeBenito 0fbfa5
allow $1_xserver_t $1_xserver_tmp_t:unix_stream_socket name_bind;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
read_locale($1_xserver_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Type for tmpfs/shm files.
Chris PeBenito 0fbfa5
tmpfs_domain($1_xserver)
Chris PeBenito 0fbfa5
ifelse($1, xdm, `
Chris PeBenito 0fbfa5
ifdef(`xdm.te', `
Chris PeBenito 0fbfa5
allow xdm_xserver_t xdm_t:shm rw_shm_perms;
Chris PeBenito 0fbfa5
allow xdm_xserver_t xdm_tmpfs_t:file rw_file_perms;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
allow $1_xserver_t $1_t:shm rw_shm_perms;
Chris PeBenito 0fbfa5
rw_dir_file($1_xserver_t, $1_tmpfs_t)
Chris PeBenito 0fbfa5
')dnl end ifelse xdm
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
r_dir_file($1_xserver_t,sysfs_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Use the mouse.
Chris PeBenito 0fbfa5
allow $1_xserver_t mouse_device_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
# Allow xserver to read events - the synaptics touchpad
Chris PeBenito 0fbfa5
# driver reads raw events
Chris PeBenito 0fbfa5
allow $1_xserver_t event_device_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
ifdef(`pamconsole.te', `
Chris PeBenito 0fbfa5
allow $1_xserver_t pam_var_console_t:dir search;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
dontaudit $1_xserver_t selinux_config_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_xserver_t var_lib_t:dir search;
Chris PeBenito 2705f9
rw_dir_create_file($1_xserver_t, xkb_var_lib_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
')dnl end macro definition
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
define(`xserver_domain',`')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5