2022-01-06 13:55:54 +00:00
|
|
|
policy_module(selinux)
|
2005-06-14 20:40:09 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Declarations
|
|
|
|
#
|
|
|
|
|
2011-09-26 13:53:23 +00:00
|
|
|
## <desc>
|
|
|
|
## <p>
|
2021-03-05 21:06:44 +00:00
|
|
|
## Boolean to determine whether the system permits loading policy, and setting
|
|
|
|
## enforcing mode. Set this to true and you have to reboot to set it back.
|
2011-09-26 13:53:23 +00:00
|
|
|
## </p>
|
|
|
|
## </desc>
|
|
|
|
gen_bool(secure_mode_policyload,false)
|
|
|
|
|
2021-03-05 21:06:44 +00:00
|
|
|
## <desc>
|
|
|
|
## <p>
|
|
|
|
## Boolean to determine whether the system permits setting Booelan values.
|
|
|
|
## </p>
|
|
|
|
## </desc>
|
|
|
|
gen_bool(secure_mode_setbool,false)
|
|
|
|
|
2009-01-13 13:01:48 +00:00
|
|
|
attribute boolean_type;
|
2005-07-05 20:59:51 +00:00
|
|
|
attribute can_load_policy;
|
|
|
|
attribute can_setenforce;
|
|
|
|
attribute can_setsecparam;
|
2006-05-19 15:15:45 +00:00
|
|
|
attribute selinux_unconfined_type;
|
2005-07-05 20:59:51 +00:00
|
|
|
|
2021-03-19 19:03:47 +00:00
|
|
|
type boolean_t, boolean_type;
|
|
|
|
genfscon selinuxfs /booleans/ -- gen_context(system_u:object_r:boolean_t,s0)
|
|
|
|
|
2011-09-26 14:44:27 +00:00
|
|
|
type secure_mode_policyload_t;
|
|
|
|
selinux_labeled_boolean(secure_mode_policyload_t, secure_mode_policyload)
|
|
|
|
|
2016-12-06 12:28:10 +00:00
|
|
|
#
|
2005-06-14 20:40:09 +00:00
|
|
|
# security_t is the target type when checking
|
|
|
|
# the permissions in the security class. It is also
|
|
|
|
# applied to selinuxfs inodes.
|
|
|
|
#
|
2021-03-19 19:03:47 +00:00
|
|
|
type security_t;
|
2012-03-25 12:42:37 +00:00
|
|
|
files_mountpoint(security_t)
|
2005-06-28 17:48:59 +00:00
|
|
|
fs_type(security_t)
|
2005-09-26 20:26:32 +00:00
|
|
|
mls_trusted_object(security_t)
|
2006-10-04 17:25:34 +00:00
|
|
|
sid security gen_context(system_u:object_r:security_t,mls_systemhigh)
|
2005-10-06 19:33:06 +00:00
|
|
|
genfscon selinuxfs / gen_context(system_u:object_r:security_t,s0)
|
2008-03-14 14:55:34 +00:00
|
|
|
genfscon securityfs / gen_context(system_u:object_r:security_t,s0)
|
2005-07-05 20:59:51 +00:00
|
|
|
|
2015-11-04 20:10:29 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Controlled setenforce access
|
|
|
|
#
|
|
|
|
|
2006-05-19 15:15:45 +00:00
|
|
|
neverallow ~{ selinux_unconfined_type can_setenforce } security_t:security setenforce;
|
2015-11-04 20:10:29 +00:00
|
|
|
|
|
|
|
allow can_setenforce security_t:dir list_dir_perms;
|
|
|
|
allow can_setenforce security_t:file rw_file_perms;
|
|
|
|
|
|
|
|
dev_search_sysfs(can_setenforce)
|
|
|
|
|
2021-03-19 19:39:38 +00:00
|
|
|
if(secure_mode_policyload) {
|
|
|
|
dontaudit can_setenforce security_t:security setenforce;
|
|
|
|
} else {
|
2015-11-04 20:10:29 +00:00
|
|
|
allow can_setenforce security_t:security setenforce;
|
|
|
|
}
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Controlled load_policy access
|
|
|
|
#
|
|
|
|
|
|
|
|
neverallow ~{ selinux_unconfined_type can_load_policy } security_t:security load_policy;
|
|
|
|
|
|
|
|
allow can_load_policy security_t:dir list_dir_perms;
|
|
|
|
allow can_load_policy security_t:file rw_file_perms;
|
|
|
|
|
|
|
|
dev_search_sysfs(can_load_policy)
|
|
|
|
|
2021-03-19 19:39:38 +00:00
|
|
|
if(secure_mode_policyload) {
|
|
|
|
dontaudit can_load_policy security_t:security load_policy;
|
|
|
|
} else {
|
2015-11-04 20:10:29 +00:00
|
|
|
allow can_load_policy security_t:security load_policy;
|
|
|
|
}
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Controlled security parameters access
|
|
|
|
#
|
|
|
|
|
2006-05-19 15:15:45 +00:00
|
|
|
neverallow ~{ selinux_unconfined_type can_setsecparam } security_t:security setsecparam;
|
|
|
|
|
2015-11-04 20:10:29 +00:00
|
|
|
allow can_setsecparam security_t:dir list_dir_perms;
|
|
|
|
allow can_setsecparam security_t:file rw_file_perms;
|
|
|
|
allow can_setsecparam security_t:security setsecparam;
|
|
|
|
auditallow can_setsecparam security_t:security setsecparam;
|
|
|
|
|
|
|
|
dev_search_sysfs(can_setsecparam)
|
|
|
|
|
2006-05-19 15:15:45 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Unconfined access to this module
|
|
|
|
#
|
|
|
|
|
|
|
|
# use SELinuxfs
|
2008-10-16 16:09:20 +00:00
|
|
|
allow selinux_unconfined_type security_t:dir list_dir_perms;
|
|
|
|
allow selinux_unconfined_type security_t:file rw_file_perms;
|
2009-01-13 13:01:48 +00:00
|
|
|
allow selinux_unconfined_type boolean_type:file read_file_perms;
|
2006-05-19 15:15:45 +00:00
|
|
|
|
|
|
|
# Access the security API.
|
2021-03-05 21:06:44 +00:00
|
|
|
allow selinux_unconfined_type security_t:security { compute_av compute_create compute_member check_context compute_relabel compute_user setsecparam setcheckreqprot read_policy validate_trans };
|
2011-09-26 14:44:27 +00:00
|
|
|
|
2021-03-19 19:39:38 +00:00
|
|
|
if (secure_mode_policyload) {
|
|
|
|
dontaudit selinux_unconfined_type security_t:security { load_policy setenforce };
|
|
|
|
} else {
|
2011-09-26 14:44:27 +00:00
|
|
|
allow selinux_unconfined_type security_t:security { load_policy setenforce };
|
2021-03-05 21:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 19:39:38 +00:00
|
|
|
if (secure_mode_setbool) {
|
|
|
|
dontaudit selinux_unconfined_type security_t:security setbool;
|
|
|
|
} else {
|
2021-03-05 21:06:44 +00:00
|
|
|
allow selinux_unconfined_type security_t:security setbool;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (secure_mode_policyload && !secure_mode_setbool) {
|
|
|
|
allow selinux_unconfined_type { boolean_type -secure_mode_policyload_t }:file write_file_perms;
|
2021-03-19 19:39:38 +00:00
|
|
|
} else {
|
|
|
|
dontaudit selinux_unconfined_type { boolean_type -secure_mode_policyload_t }:file write_file_perms;
|
2021-03-05 21:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!secure_mode_policyload && !secure_mode_setbool) {
|
|
|
|
allow selinux_unconfined_type boolean_type:file write_file_perms;
|
2021-03-19 19:39:38 +00:00
|
|
|
} else {
|
|
|
|
dontaudit selinux_unconfined_type boolean_type:file write_file_perms;
|
2006-05-19 15:15:45 +00:00
|
|
|
}
|