Chris PeBenito e181fe
Chris PeBenito 960373
policy_module(kernel,1.0)
Chris PeBenito 960373
Chris PeBenito ff7bc1
########################################
Chris PeBenito ff7bc1
#
Chris PeBenito ff7bc1
# Declarations
Chris PeBenito ff7bc1
#
Chris PeBenito ff7bc1
Chris PeBenito 18f25a
# assertion related attributes
Chris PeBenito a266e3
attribute can_load_kernmodule;
Chris PeBenito a266e3
attribute can_receive_kernel_messages;
Chris PeBenito a266e3
Chris PeBenito 712566
neverallow ~can_load_kernmodule self:capability sys_module;
Chris PeBenito 712566
Chris PeBenito d25063
# domains with unconfined access to kernel resources
Chris PeBenito d25063
attribute kern_unconfined;
Chris PeBenito d25063
Chris PeBenito d25063
# regular entries in proc
Chris PeBenito d25063
attribute proc_type;
Chris PeBenito d25063
Chris PeBenito d25063
# sysctls
Chris PeBenito d25063
attribute sysctl_type;
Chris PeBenito d25063
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 605ba2
type kernel_t, can_load_kernmodule; # mlsprocread, mlsprocwrite, privrangetrans
Chris PeBenito b4cd15
role system_r types kernel_t;
Chris PeBenito fb0a3a
domain_base_type(kernel_t)
Chris PeBenito cff75c
sid kernel context_template(system_u:system_r:kernel_t,s0 - s9:c0.c127, c0.c127)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito a1fcff
# DebugFS
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
Chris PeBenito a1fcff
type debugfs_t;
Chris PeBenito a1fcff
fs_type(debugfs_t)
Chris PeBenito a1fcff
allow debugfs_t self:filesystem associate;
Chris PeBenito a1fcff
genfscon debugfs / context_template(system_u:object_r:debugfs_t,s0)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
#
Chris PeBenito b4cd15
# Procfs types
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito d25063
type proc_t, proc_type;
Chris PeBenito c9428d
files_mountpoint(proc_t)
Chris PeBenito cbca03
fs_type(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 d25063
type proc_kmsg_t, proc_type;
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 d25063
type proc_kcore_t, proc_type;
Chris PeBenito d25063
neverallow { domain -kern_unconfined } 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 d25063
type proc_mdstat_t, proc_type;
Chris PeBenito e32c0d
genfscon proc /mdstat context_template(system_u:object_r:proc_mdstat_t,s0)
Chris PeBenito b4cd15
Chris PeBenito d25063
type proc_net_t, proc_type;
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 d25063
# /proc/sys directory, base directory of sysctls
Chris PeBenito d25063
type sysctl_t, sysctl_type;
Chris PeBenito d25063
files_mountpoint(sysctl_t)
Chris PeBenito d25063
sid sysctl context_template(system_u:object_r:sysctl_t,s0)
Chris PeBenito d25063
genfscon proc /sys context_template(system_u:object_r:sysctl_t,s0)
Chris PeBenito d25063
Chris PeBenito b4cd15
# /proc/irq directory and files
Chris PeBenito d25063
type sysctl_irq_t, sysctl_type;
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 d25063
type sysctl_rpc_t, sysctl_type;
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/fs directory and files
Chris PeBenito d25063
type sysctl_fs_t, sysctl_type;
Chris PeBenito c9428d
files_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 d25063
type sysctl_kernel_t, sysctl_type;
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 d25063
type sysctl_modprobe_t, sysctl_type;
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 d25063
type sysctl_hotplug_t, sysctl_type;
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 d25063
type sysctl_net_t, sysctl_type;
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 d25063
type sysctl_net_unix_t, sysctl_type;
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 d25063
type sysctl_vm_t, sysctl_type;
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 d25063
type sysctl_dev_t, sysctl_type;
Chris PeBenito e32c0d
genfscon proc /sys/dev context_template(system_u:object_r:sysctl_dev_t,s0)
Chris PeBenito a266e3
Chris PeBenito d25063
#
Chris PeBenito d25063
# unlabeled_t is the type of unlabeled objects.
Chris PeBenito d25063
# Objects that have no known labeling information or that
Chris PeBenito d25063
# have labels that are no longer valid are treated as having this type.
Chris PeBenito d25063
#
Chris PeBenito d25063
type unlabeled_t;
Chris PeBenito d25063
sid unlabeled context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
Chris PeBenito d25063
# These initial sids are no longer used, and can be removed:
Chris PeBenito d25063
sid any_socket		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid file_labels		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid icmp_socket		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid igmp_packet		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid init		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid kmod		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid netmsg		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid policy		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid scmp_packet		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid sysctl_modprobe 	context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid sysctl_fs		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid sysctl_kernel	context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid sysctl_net		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid sysctl_net_unix	context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid sysctl_vm		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid sysctl_dev		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
sid tcp_socket		context_template(system_u:object_r:unlabeled_t,s0)
Chris PeBenito d25063
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 c2c00b
allow kernel_t self:shm create_shm_perms;
Chris PeBenito c2c00b
allow kernel_t self:sem create_sem_perms;
Chris PeBenito a266e3
allow kernel_t self:msg { send receive };
Chris PeBenito c2c00b
allow kernel_t self:msgq create_msgq_perms;
Chris PeBenito c2c00b
allow kernel_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito c2c00b
allow kernel_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito a266e3
allow kernel_t self:unix_dgram_socket sendto;
Chris PeBenito a266e3
allow kernel_t self:unix_stream_socket connectto;
Chris PeBenito c2c00b
allow kernel_t self:fifo_file rw_file_perms;
Chris PeBenito a266e3
allow kernel_t self:fd use;
Chris PeBenito a266e3
Chris PeBenito a266e3
# old general_proc_read_access():
Chris PeBenito c2c00b
allow kernel_t proc_t:dir r_dir_perms;
Chris PeBenito c2c00b
allow kernel_t proc_t:{ lnk_file file } r_file_perms;
Chris PeBenito c2c00b
allow kernel_t proc_net_t:dir r_dir_perms;
Chris PeBenito c2c00b
allow kernel_t proc_net_t:file r_file_perms;
Chris PeBenito c2c00b
allow kernel_t proc_mdstat_t:file r_file_perms;
Chris PeBenito a266e3
allow kernel_t proc_kcore_t:file getattr;
Chris PeBenito a266e3
allow kernel_t proc_kmsg_t:file getattr;
Chris PeBenito c2c00b
allow kernel_t sysctl_t:dir r_dir_perms;
Chris PeBenito c2c00b
allow kernel_t sysctl_kernel_t:dir r_dir_perms;
Chris PeBenito c2c00b
allow kernel_t sysctl_kernel_t:file r_file_perms;
Chris PeBenito a266e3
Chris PeBenito 605ba2
# cjp: this seems questionable
Chris PeBenito 605ba2
allow kernel_t unlabeled_t:fifo_file rw_file_perms;
Chris PeBenito 605ba2
Chris PeBenito a154cd
# Kernel-generated traffic e.g., ICMP replies:
Chris PeBenito a154cd
corenet_raw_sendrecv_all_if(kernel_t)
Chris PeBenito a154cd
corenet_raw_sendrecv_all_nodes(kernel_t)
Chris PeBenito a154cd
# Kernel-generated traffic e.g., TCP resets:
Chris PeBenito 0fd9dc
corenet_tcp_sendrecv_all_if(kernel_t)
Chris PeBenito 0fd9dc
corenet_tcp_sendrecv_all_nodes(kernel_t)
Chris PeBenito a154cd
Chris PeBenito 605ba2
dev_read_sysfs(kernel_t)
Chris PeBenito 605ba2
dev_search_usbfs(kernel_t)
Chris PeBenito a154cd
Chris PeBenito a154cd
# Mount root file system.  Used when loading a policy
Chris PeBenito a154cd
# from initrd, then mounting the root filesystem
Chris PeBenito a154cd
fs_mount_all_fs(kernel_t)
Chris PeBenito a154cd
Chris PeBenito 605ba2
selinux_load_policy(kernel_t)
Chris PeBenito 605ba2
Chris PeBenito 605ba2
term_use_console(kernel_t)
Chris PeBenito 605ba2
Chris PeBenito c9428d
corecmd_exec_shell(kernel_t)
Chris PeBenito c9428d
corecmd_list_sbin(kernel_t)
Chris PeBenito a154cd
# /proc/sys/kernel/modprobe is set to /bin/true if not using modules.
Chris PeBenito c9428d
corecmd_exec_bin(kernel_t)
Chris PeBenito a154cd
Chris PeBenito a154cd
domain_signal_all_domains(kernel_t)
Chris PeBenito 605ba2
domain_search_all_domains_state(kernel_t)
Chris PeBenito 588ffa
Chris PeBenito c9428d
files_list_root(kernel_t)
Chris PeBenito 712566
files_list_etc(kernel_t)
Chris PeBenito c9428d
files_list_home(kernel_t)
Chris PeBenito c9428d
files_read_usr_files(kernel_t)
Chris PeBenito 588ffa
Chris PeBenito cf6a7d
ifdef(`TODO',`
Chris PeBenito cf6a7d
ifdef(`targeted_policy', `
Chris PeBenito cf6a7d
unconfined_domain(kernel_t)
Chris PeBenito cf6a7d
')
Chris PeBenito cf6a7d
ifdef(`mls_policy', `
Chris PeBenito cf6a7d
# run init with maximum MLS range
Chris PeBenito cf6a7d
range_transition kernel_t init_exec_t s0 - s9:c0.c127;
Chris PeBenito cf6a7d
')
Chris PeBenito cf6a7d
') dnl end TODO
Chris PeBenito cf6a7d
Chris PeBenito 588ffa
########################################
Chris PeBenito 588ffa
#
Chris PeBenito 588ffa
# Unlabeled process local policy
Chris PeBenito 588ffa
#
Chris PeBenito 588ffa
Chris PeBenito c98340
ifdef(`targeted_policy',`
Chris PeBenito c98340
	allow unlabeled_t self:filesystem associate;
Chris PeBenito c98340
')