Chris PeBenito e181fe
# Copyright (C) 2005 Tresys Technology, LLC
Chris PeBenito e181fe
Chris PeBenito 960373
policy_module(kernel,1.0)
Chris PeBenito 960373
Chris PeBenito 18f25a
# assertion related attributes
Chris PeBenito a266e3
attribute can_load_policy;
Chris PeBenito a266e3
attribute can_setenforce;
Chris PeBenito a266e3
attribute can_setsecparam;
Chris PeBenito a266e3
attribute can_load_kernmodule;
Chris PeBenito a266e3
attribute can_receive_kernel_messages;
Chris PeBenito a266e3
Chris PeBenito 18f25a
# constraint related attributes
Chris PeBenito 18f25a
attribute can_change_process_identity;
Chris PeBenito 18f25a
attribute can_change_process_role;
Chris PeBenito 18f25a
attribute can_change_object_identity;
Chris PeBenito 18f25a
Chris PeBenito a266e3
#
Chris PeBenito b4cd15
# kernel_t is the domain of kernel threads.
Chris PeBenito b4cd15
# It is also the target type when checking permissions in the system class.
Chris PeBenito b4cd15
# 
Chris PeBenito a266e3
type kernel_t, can_load_kernmodule, can_load_policy;
Chris PeBenito b4cd15
role system_r types kernel_t;
Chris PeBenito a266e3
domain_make_domain(kernel_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# unlabeled_t is the type of unlabeled objects.
Chris PeBenito b4cd15
# Objects that have no known labeling information or that
Chris PeBenito b4cd15
# have labels that are no longer valid are treated as having this type.
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
type unlabeled_t;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# 
Chris PeBenito b4cd15
# security_t is the target type when checking
Chris PeBenito b4cd15
# the permissions in the security class.  It is also
Chris PeBenito b4cd15
# applied to selinuxfs inodes.
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
type security_t;
Chris PeBenito a266e3
filesystem_make_filesystem(security_t)
Chris PeBenito e32c0d
genfscon selinuxfs / context_template(system_u:object_r:security_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# sysfs_t is the type for /sys
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
type sysfs_t;
Chris PeBenito a2d824
files_make_mountpoint(sysfs_t)
Chris PeBenito b4cd15
filesystem_make_filesystem(sysfs_t)
Chris PeBenito e32c0d
genfscon sysfs / context_template(system_u:object_r:sysfs_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# usbfs_t is the type for /proc/bus/usb
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
type usbfs_t alias usbdevfs_t;
Chris PeBenito a2d824
files_make_mountpoint(usbfs_t)
Chris PeBenito b4cd15
filesystem_make_filesystem(usbfs_t)
Chris PeBenito e32c0d
genfscon usbfs / context_template(system_u:object_r:usbfs_t,s0)
Chris PeBenito e32c0d
genfscon usbdevfs / context_template(system_u:object_r:usbfs_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# Procfs types
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type proc_t;
Chris PeBenito a2d824
files_make_mountpoint(proc_t)
Chris PeBenito 075c4f
filesystem_make_filesystem(proc_t)
Chris PeBenito e32c0d
genfscon proc / context_template(system_u:object_r:proc_t,s0)
Chris PeBenito e32c0d
genfscon proc /sysvipc context_template(system_u:object_r:proc_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# kernel message interface
Chris PeBenito b4cd15
type proc_kmsg_t;
Chris PeBenito e32c0d
genfscon proc /kmsg context_template(system_u:object_r:proc_kmsg_t,s0)
Chris PeBenito b4cd15
neverallow ~can_receive_kernel_messages proc_kmsg_t:file ~getattr;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc kcore: inaccessible
Chris PeBenito b4cd15
type proc_kcore_t;
Chris PeBenito b4cd15
neverallow * proc_kcore_t:file ~getattr;
Chris PeBenito e32c0d
genfscon proc /kcore context_template(system_u:object_r:proc_kcore_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type proc_mdstat_t;
Chris PeBenito e32c0d
genfscon proc /mdstat context_template(system_u:object_r:proc_mdstat_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type proc_net_t;
Chris PeBenito e32c0d
genfscon proc /net context_template(system_u:object_r:proc_net_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# Sysctl types
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/irq directory and files
Chris PeBenito b4cd15
type sysctl_irq_t;
Chris PeBenito e32c0d
genfscon proc /irq context_template(system_u:object_r:sysctl_irq_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/net/rpc directory and files
Chris PeBenito b4cd15
type sysctl_rpc_t;
Chris PeBenito e32c0d
genfscon proc /net/rpc context_template(system_u:object_r:sysctl_rpc_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/sys directory, base directory of sysctls
Chris PeBenito b4cd15
type sysctl_t;
Chris PeBenito d490eb
files_make_mountpoint(sysctl_t)
Chris PeBenito e32c0d
genfscon proc /sys context_template(system_u:object_r:sysctl_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/sys/fs directory and files
Chris PeBenito b4cd15
type sysctl_fs_t;
Chris PeBenito a2d824
files_make_mountpoint(sysctl_fs_t)
Chris PeBenito e32c0d
genfscon proc /sys/fs context_template(system_u:object_r:sysctl_fs_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/sys/kernel directory and files
Chris PeBenito b4cd15
type sysctl_kernel_t;
Chris PeBenito e32c0d
genfscon proc /sys/kernel context_template(system_u:object_r:sysctl_kernel_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/sys/kernel/modprobe file
Chris PeBenito b4cd15
type sysctl_modprobe_t;
Chris PeBenito e32c0d
genfscon proc /sys/kernel/modprobe context_template(system_u:object_r:sysctl_modprobe_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/sys/kernel/hotplug file
Chris PeBenito b4cd15
type sysctl_hotplug_t;
Chris PeBenito e32c0d
genfscon proc /sys/kernel/hotplug context_template(system_u:object_r:sysctl_hotplug_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/sys/net directory and files
Chris PeBenito b4cd15
type sysctl_net_t;
Chris PeBenito e32c0d
genfscon proc /sys/net context_template(system_u:object_r:sysctl_net_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/sys/net/unix directory and files
Chris PeBenito b4cd15
type sysctl_net_unix_t;
Chris PeBenito e32c0d
genfscon proc /sys/net/unix context_template(system_u:object_r:sysctl_net_unix_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/sys/vm directory and files
Chris PeBenito b4cd15
type sysctl_vm_t;
Chris PeBenito e32c0d
genfscon proc /sys/vm context_template(system_u:object_r:sysctl_vm_t,s0)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# /proc/sys/dev directory and files
Chris PeBenito b4cd15
type sysctl_dev_t;
Chris PeBenito e32c0d
genfscon proc /sys/dev context_template(system_u:object_r:sysctl_dev_t,s0)
Chris PeBenito a266e3
Chris PeBenito a266e3
########################################
Chris PeBenito a266e3
#
Chris PeBenito a266e3
# kernel local policy
Chris PeBenito a266e3
#
Chris PeBenito a266e3
Chris PeBenito a266e3
# Use capabilities. need to investigate which capabilities are actually used
Chris PeBenito a266e3
allow kernel_t self:capability *;
Chris PeBenito a266e3
Chris PeBenito a266e3
# Other possible mount points for the root fs are in files
Chris PeBenito a266e3
allow kernel_t unlabeled_t:dir mounton;
Chris PeBenito a266e3
Chris PeBenito a266e3
# old general_domain_access()
Chris PeBenito a266e3
allow kernel_t self:shm { associate getattr setattr create destroy read write lock unix_read unix_write };
Chris PeBenito a266e3
allow kernel_t self:sem { associate getattr setattr create destroy read write unix_read unix_write };
Chris PeBenito a266e3
allow kernel_t self:msg { send receive };
Chris PeBenito a266e3
allow kernel_t self:msgq { associate getattr setattr create destroy read write enqueue unix_read unix_write };
Chris PeBenito a266e3
allow kernel_t self:unix_dgram_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito a266e3
allow kernel_t self:unix_stream_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown listen accept };
Chris PeBenito a266e3
allow kernel_t self:unix_dgram_socket sendto;
Chris PeBenito a266e3
allow kernel_t self:unix_stream_socket connectto;
Chris PeBenito a266e3
allow kernel_t self:fifo_file { read getattr lock ioctl write append };
Chris PeBenito a266e3
allow kernel_t self:fd use;
Chris PeBenito a266e3
Chris PeBenito a266e3
# old general_proc_read_access():
Chris PeBenito a266e3
allow kernel_t proc_t:dir { getattr search read };
Chris PeBenito a266e3
allow kernel_t proc_t:{ lnk_file file } { getattr read };
Chris PeBenito a266e3
allow kernel_t proc_net_t:dir { getattr search read };
Chris PeBenito a266e3
allow kernel_t proc_net_t:file { getattr read };
Chris PeBenito a266e3
allow kernel_t proc_mdstat_t:file { getattr read }; 
Chris PeBenito a266e3
allow kernel_t proc_kcore_t:file getattr;
Chris PeBenito a266e3
allow kernel_t proc_kmsg_t:file getattr;
Chris PeBenito a266e3
allow kernel_t sysctl_t:dir { getattr search read };
Chris PeBenito a266e3
allow kernel_t sysctl_kernel_t:dir { getattr search read };
Chris PeBenito a266e3
allow kernel_t sysctl_kernel_t:file { getattr read };
Chris PeBenito a266e3
Chris PeBenito a266e3
# old base_file_read_access():
Chris PeBenito a266e3
files_list_home_directories(kernel_t)
Chris PeBenito 3ce6cb
files_read_general_application_resources(kernel_t)
Chris PeBenito a266e3
selinux_read_config(kernel_t)
Chris PeBenito a266e3
Chris PeBenito a266e3
selinux_read_binary_policy(kernel_t)
Chris PeBenito a266e3
allow kernel_t security_t:dir { read search getattr };
Chris PeBenito a266e3
allow kernel_t security_t:file { getattr read write };
Chris PeBenito a266e3
allow kernel_t security_t:security load_policy;
Chris PeBenito a266e3
auditallow kernel_t security_t:security load_policy;
Chris PeBenito a266e3
Chris PeBenito a266e3
libraries_use_dynamic_loader(kernel_t)
Chris PeBenito dd14d0
libraries_use_shared_libraries(kernel_t)
Chris PeBenito a266e3
Chris PeBenito a266e3
corecommands_execute_shell(kernel_t)
Chris PeBenito a266e3
Chris PeBenito a266e3
terminal_use_console(kernel_t)
Chris PeBenito a266e3
domain_signal_all_domains(kernel_t)
Chris PeBenito a266e3
Chris PeBenito a266e3
# Mount root file system.  Used when loading a policy
Chris PeBenito a266e3
# from initrd, then mounting the root filesystem
Chris PeBenito a266e3
filesystem_mount_all_filesystems(kernel_t)
Chris PeBenito a266e3
Chris PeBenito a266e3
# /proc/sys/kernel/modprobe is set to /bin/true if not using modules.
Chris PeBenito a266e3
corecommands_execute_general_programs(kernel_t)
Chris PeBenito a266e3
Chris PeBenito a266e3
logging_send_system_log_message(kernel_t)
Chris PeBenito a266e3
Chris PeBenito a266e3
# Kernel-generated traffic, e.g. ICMP replies.
Chris PeBenito a266e3
corenetwork_network_raw_on_all_interfaces(kernel_t)
Chris PeBenito a266e3
corenetwork_network_raw_on_all_nodes(kernel_t)
Chris PeBenito a266e3
Chris PeBenito a266e3
# Kernel-generated traffic, e.g. TCP resets.
Chris PeBenito a266e3
corenetwork_network_tcp_on_all_interfaces(kernel_t)
Chris PeBenito a266e3
corenetwork_network_tcp_on_all_nodes(kernel_t)
Chris PeBenito a266e3
Chris PeBenito a266e3
neverallow ~can_load_policy security_t:security load_policy;
Chris PeBenito a266e3
neverallow ~can_setenforce security_t:security setenforce;
Chris PeBenito a266e3
neverallow ~can_setsecparam security_t:security setsecparam;
Chris PeBenito a266e3
Chris PeBenito a266e3
# enabling dyntransition breaks process tranquility.  If you dont
Chris PeBenito a266e3
# know what this means or dont understand the implications of a
Chris PeBenito a266e3
# dynamic transition, you shouldnt be using it!!!
Chris PeBenito a266e3
neverallow * *:process { setcurrent dyntransition };
Chris PeBenito a266e3
Chris PeBenito a266e3
neverallow ~can_load_kernmodule *:capability sys_module;