9b2e0cbeea
In kernel 4.7, the capability and capability2 classes were split apart from cap_userns and cap2_userns (see kernel commit 8e4ff6f228e4722cac74db716e308d1da33d744f). Since then, Android cannot be run in a container with SELinux in enforcing mode. This change applies the existing capability rules to user namespaces as well as the root namespace so that Android running in a container behaves the same on pre- and post-4.7 kernels. This is essentially: 1. New global_capability_class_set and global_capability2_class_set that match capability+cap_userns and capability2+cap2_userns, respectively. 2. s/self:capability/self:global_capability_class_set/g 3. s/self:capability2/self:global_capability2_class_set/g 4. Add cap_userns and cap2_userns to the existing capability_class_set so that it covers all capabilities. This set was used by several neverallow and dontaudit rules, and I confirmed that the new classes are still appropriate. Test: diff new policy against old and confirm that all new rules add only cap_userns or cap2_userns; Boot ARC++ on a device with the 4.12 kernel. Bug: crbug.com/754831 Change-Id: I4007eb3a2ecd01b062c4c78d9afee71c530df95f
210 lines
5.2 KiB
Text
210 lines
5.2 KiB
Text
# vendor_init is its own domain.
|
|
type vendor_init, domain, mlstrustedsubject;
|
|
|
|
# Communication to the main init process
|
|
allow vendor_init init:unix_stream_socket { read write };
|
|
|
|
# Logging to kmsg
|
|
allow vendor_init kmsg_device:chr_file { open write };
|
|
|
|
# Mount on /dev/usb-ffs/adb.
|
|
allow vendor_init device:dir mounton;
|
|
|
|
# Create and remove symlinks in /.
|
|
allow vendor_init rootfs:lnk_file { create unlink };
|
|
|
|
# Create cgroups mount points in tmpfs and mount cgroups on them.
|
|
allow vendor_init cgroup:dir create_dir_perms;
|
|
|
|
# /config
|
|
allow vendor_init configfs:dir mounton;
|
|
allow vendor_init configfs:dir create_dir_perms;
|
|
allow vendor_init configfs:{ file lnk_file } create_file_perms;
|
|
|
|
# Create directories under /dev/cpuctl after chowning it to system.
|
|
allow vendor_init self:global_capability_class_set dac_override;
|
|
|
|
# mkdir, symlink, write, rm/rmdir, chown/chmod, restorecon/restorecon_recursive from init.rc files.
|
|
# chown/chmod require open+read+setattr required for open()+fchown/fchmod().
|
|
# system/core/init.rc requires at least cache_file and data_file_type.
|
|
# init.<board>.rc files often include device-specific types, so
|
|
# we just allow all file types except /system files here.
|
|
allow vendor_init self:global_capability_class_set { chown fowner fsetid };
|
|
|
|
allow vendor_init {
|
|
file_type
|
|
-app_data_file
|
|
-bluetooth_data_file
|
|
-dalvikcache_data_file
|
|
-exec_type
|
|
-incident_data_file
|
|
-keystore_data_file
|
|
-misc_logd_file
|
|
-nfc_data_file
|
|
-property_data_file
|
|
-radio_data_file
|
|
-shell_data_file
|
|
-system_app_data_file
|
|
-system_file
|
|
-system_ndebug_socket
|
|
-unlabeled
|
|
-vendor_file_type
|
|
-vold_data_file
|
|
-zoneinfo_data_file
|
|
}:dir { create search getattr open read setattr ioctl };
|
|
|
|
allow vendor_init {
|
|
file_type
|
|
-app_data_file
|
|
-bluetooth_data_file
|
|
-dalvikcache_data_file
|
|
-exec_type
|
|
-incident_data_file
|
|
-keystore_data_file
|
|
-misc_logd_file
|
|
-nfc_data_file
|
|
-property_data_file
|
|
-radio_data_file
|
|
-shell_data_file
|
|
-system_app_data_file
|
|
-system_file
|
|
-system_ndebug_socket
|
|
-unlabeled
|
|
-vendor_file_type
|
|
-vold_data_file
|
|
-zoneinfo_data_file
|
|
}:dir { write add_name remove_name rmdir relabelfrom };
|
|
|
|
allow vendor_init {
|
|
file_type
|
|
-app_data_file
|
|
-bluetooth_data_file
|
|
-dalvikcache_data_file
|
|
-runtime_event_log_tags_file
|
|
-exec_type
|
|
-incident_data_file
|
|
-keystore_data_file
|
|
-misc_logd_file
|
|
-nfc_data_file
|
|
-property_data_file
|
|
-radio_data_file
|
|
-shell_data_file
|
|
-system_app_data_file
|
|
-system_file
|
|
-system_ndebug_socket
|
|
-unlabeled
|
|
-vendor_file_type
|
|
-vold_data_file
|
|
-zoneinfo_data_file
|
|
}:file { create getattr open read write setattr relabelfrom unlink };
|
|
|
|
allow vendor_init {
|
|
file_type
|
|
-app_data_file
|
|
-bluetooth_data_file
|
|
-dalvikcache_data_file
|
|
-exec_type
|
|
-incident_data_file
|
|
-keystore_data_file
|
|
-misc_logd_file
|
|
-nfc_data_file
|
|
-property_data_file
|
|
-radio_data_file
|
|
-shell_data_file
|
|
-system_app_data_file
|
|
-system_file
|
|
-system_ndebug_socket
|
|
-unlabeled
|
|
-vendor_file_type
|
|
-vold_data_file
|
|
-zoneinfo_data_file
|
|
}:{ sock_file fifo_file } { create getattr open read setattr relabelfrom unlink };
|
|
|
|
allow vendor_init {
|
|
file_type
|
|
-app_data_file
|
|
-bluetooth_data_file
|
|
-dalvikcache_data_file
|
|
-exec_type
|
|
-incident_data_file
|
|
-keystore_data_file
|
|
-misc_logd_file
|
|
-nfc_data_file
|
|
-property_data_file
|
|
-radio_data_file
|
|
-shell_data_file
|
|
-system_app_data_file
|
|
-system_file
|
|
-system_ndebug_socket
|
|
-unlabeled
|
|
-vendor_file_type
|
|
-vold_data_file
|
|
-zoneinfo_data_file
|
|
}:lnk_file { create getattr setattr relabelfrom unlink };
|
|
|
|
allow vendor_init {
|
|
file_type
|
|
-system_file
|
|
-vendor_file_type
|
|
-exec_type
|
|
-vold_data_file
|
|
-keystore_data_file
|
|
}:dir_file_class_set relabelto;
|
|
|
|
allow vendor_init dev_type:dir create_dir_perms;
|
|
allow vendor_init dev_type:lnk_file create;
|
|
|
|
# Disable tracing by writing to /sys/kernel/debug/tracing/tracing_on
|
|
allow vendor_init debugfs_tracing:file w_file_perms;
|
|
|
|
# chown/chmod on pseudo files.
|
|
allow vendor_init {
|
|
fs_type
|
|
-contextmount_type
|
|
-sdcard_type
|
|
-rootfs
|
|
-proc_uid_time_in_state
|
|
}:file { open read setattr };
|
|
|
|
allow vendor_init {
|
|
fs_type
|
|
-contextmount_type
|
|
-sdcard_type
|
|
-rootfs
|
|
-proc_uid_time_in_state
|
|
}:dir { open read setattr search };
|
|
|
|
# chown/chmod on devices, e.g. /dev/ttyHS0
|
|
allow vendor_init {
|
|
dev_type
|
|
-kmem_device
|
|
-port_device
|
|
-lowpan_device
|
|
-hw_random_device
|
|
}:chr_file setattr;
|
|
|
|
allow vendor_init dev_type:blk_file getattr;
|
|
|
|
# Write to /proc/sys/net/ping_group_range and other /proc/sys/net files.
|
|
r_dir_file(vendor_init, proc_net)
|
|
allow vendor_init proc_net:file w_file_perms;
|
|
allow vendor_init self:global_capability_class_set net_admin;
|
|
|
|
# Write to /proc/sys/vm/page-cluster
|
|
allow vendor_init proc_page_cluster:file w_file_perms;
|
|
|
|
# Write to sysfs nodes.
|
|
allow vendor_init sysfs_type:dir r_dir_perms;
|
|
allow vendor_init sysfs_type:lnk_file read;
|
|
allow vendor_init { sysfs_type -sysfs_usermodehelper }:file rw_file_perms;
|
|
|
|
# setfscreatecon() for labeling directories and socket files.
|
|
allow vendor_init self:process { setfscreate };
|
|
|
|
r_dir_file(vendor_init, vendor_file_type)
|
|
|
|
# Vendor init can read properties
|
|
allow vendor_init serialno_prop:file { getattr open read };
|
|
|
|
# Vendor init can perform operations on trusted and security Extended Attributes
|
|
allow vendor_init self:global_capability_class_set sys_admin;
|