Skip to content
Snippets Groups Projects
Commit d99e6d5f authored by Stephen Smalley's avatar Stephen Smalley
Browse files

Restrict the ability to set SELinux enforcing mode to init.


Also make su and shell permissive in non-user builds to allow
use of setenforce without violating the neverallow rule.

Change-Id: Ie76ee04e90d5a76dfaa5f56e9e3eb7e283328a3f
Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
parent 51ce2f00
No related branches found
No related tags found
No related merge requests found
...@@ -11,8 +11,10 @@ MLS_SENS=1 ...@@ -11,8 +11,10 @@ MLS_SENS=1
MLS_CATS=1024 MLS_CATS=1024
ifeq ($(TARGET_BUILD_VARIANT),user) ifeq ($(TARGET_BUILD_VARIANT),user)
BOARD_SEPOLICY_IGNORE+=external/sepolicy/shell.te
BOARD_SEPOLICY_IGNORE+=external/sepolicy/su.te BOARD_SEPOLICY_IGNORE+=external/sepolicy/su.te
else else
BOARD_SEPOLICY_IGNORE+=external/sepolicy/shell_user.te
BOARD_SEPOLICY_IGNORE+=external/sepolicy/su_user.te BOARD_SEPOLICY_IGNORE+=external/sepolicy/su_user.te
endif endif
......
...@@ -131,8 +131,8 @@ neverallow { domain -relabeltodomain } *:dir_file_class_set relabelto; ...@@ -131,8 +131,8 @@ neverallow { domain -relabeltodomain } *:dir_file_class_set relabelto;
### neverallow rules ### neverallow rules
### ###
# Only init should be able to load SELinux policies # Only init should be able to load SELinux policies and set enforcing mode.
neverallow { domain -init } kernel:security load_policy; neverallow { domain -init } kernel:security { load_policy setenforce };
# Only init, ueventd and system_server should be able to access HW RNG # Only init, ueventd and system_server should be able to access HW RNG
neverallow { domain -init -system_server -ueventd -unconfineddomain } hw_random_device:chr_file *; neverallow { domain -init -system_server -ueventd -unconfineddomain } hw_random_device:chr_file *;
......
...@@ -8,4 +8,4 @@ relabelto_domain(init) ...@@ -8,4 +8,4 @@ relabelto_domain(init)
allow init unlabeled:filesystem mount; allow init unlabeled:filesystem mount;
allow init {fs_type dev_type file_type}:dir_file_class_set relabelto; allow init {fs_type dev_type file_type}:dir_file_class_set relabelto;
allow init kernel:security load_policy; allow init kernel:security { load_policy setenforce };
...@@ -6,3 +6,6 @@ unconfined_domain(shell) ...@@ -6,3 +6,6 @@ unconfined_domain(shell)
# Run app_process. # Run app_process.
# XXX Split into its own domain? # XXX Split into its own domain?
app_domain(shell) app_domain(shell)
# shell is also permissive to permit setenforce.
permissive shell;
# Domain for shell processes spawned by ADB
type shell, domain;
type shell_exec, exec_type, file_type;
unconfined_domain(shell)
# Run app_process.
# XXX Split into its own domain?
app_domain(shell)
...@@ -4,3 +4,6 @@ domain_auto_trans(shell, su_exec, su) ...@@ -4,3 +4,6 @@ domain_auto_trans(shell, su_exec, su)
# su is unconfined. # su is unconfined.
unconfined_domain(su) unconfined_domain(su)
# su is also permissive to permit setenforce.
permissive su;
...@@ -250,13 +250,9 @@ allow $1 rootfs:file r_file_perms; ...@@ -250,13 +250,9 @@ allow $1 rootfs:file r_file_perms;
##################################### #####################################
# selinux_manage_policy(domain) # selinux_manage_policy(domain)
# Ability to manage policy files, # Ability to manage policy files and
# trigger runtime reload, change # trigger runtime reload.
# enforcing mode, manipulate booleans
# and access kernel logs.
define(`selinux_manage_policy', ` define(`selinux_manage_policy', `
selinux_setenforce($1)
selinux_setbool($1)
security_access_policy($1) security_access_policy($1)
unix_socket_connect($1, property, init) unix_socket_connect($1, property, init)
allow $1 security_file:dir create_dir_perms; allow $1 security_file:dir create_dir_perms;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
###################################################### ######################################################
allow unconfineddomain self:capability_class_set *; allow unconfineddomain self:capability_class_set *;
allow unconfineddomain kernel:security ~load_policy; allow unconfineddomain kernel:security ~{ load_policy setenforce };
allow unconfineddomain kernel:system *; allow unconfineddomain kernel:system *;
allow unconfineddomain self:memprotect *; allow unconfineddomain self:memprotect *;
allow unconfineddomain domain:process *; allow unconfineddomain domain:process *;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment