2017-09-28 23:34:36 +02:00
|
|
|
# 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
|
2019-03-20 23:36:26 +01:00
|
|
|
allow vendor_init kmsg_device:chr_file { open getattr write };
|
2017-09-28 23:34:36 +02:00
|
|
|
|
|
|
|
# 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;
|
2018-10-11 00:48:15 +02:00
|
|
|
allow vendor_init cgroup:file w_file_perms;
|
2017-09-28 23:34:36 +02:00
|
|
|
|
|
|
|
# /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.
|
2018-09-07 00:19:40 +02:00
|
|
|
allow vendor_init self:global_capability_class_set { dac_override dac_read_search };
|
2017-09-28 23:34:36 +02:00
|
|
|
|
|
|
|
# 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.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow vendor_init self:global_capability_class_set { chown fowner fsetid };
|
2017-09-28 23:34:36 +02:00
|
|
|
|
2018-04-13 02:30:56 +02:00
|
|
|
# mkdir with FBE requires reading /data/unencrypted/{ref,mode}.
|
|
|
|
allow vendor_init unencrypted_data_file:dir search;
|
|
|
|
allow vendor_init unencrypted_data_file:file r_file_perms;
|
|
|
|
|
2018-10-09 23:22:47 +02:00
|
|
|
# Set encryption policy on dirs in /data
|
|
|
|
allowxperm vendor_init data_file_type:dir ioctl {
|
|
|
|
FS_IOC_GET_ENCRYPTION_POLICY
|
|
|
|
FS_IOC_SET_ENCRYPTION_POLICY
|
|
|
|
};
|
|
|
|
|
2018-04-20 21:50:00 +02:00
|
|
|
allow vendor_init system_data_file:dir getattr;
|
|
|
|
|
2017-09-28 23:34:36 +02:00
|
|
|
allow vendor_init {
|
|
|
|
file_type
|
2018-01-22 23:18:31 +01:00
|
|
|
-core_data_file_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-exec_type
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
2018-06-29 04:10:00 +02:00
|
|
|
-mnt_product_file
|
2019-02-28 23:11:34 +01:00
|
|
|
-password_slot_metadata_file
|
2019-07-09 04:03:59 +02:00
|
|
|
-ota_metadata_file
|
2017-09-28 23:34:36 +02:00
|
|
|
-unlabeled
|
|
|
|
-vendor_file_type
|
2018-02-01 19:15:34 +01:00
|
|
|
-vold_metadata_file
|
2019-01-23 04:05:29 +01:00
|
|
|
-gsi_metadata_file
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2018-01-22 23:18:31 +01:00
|
|
|
}:dir { create search getattr open read setattr ioctl write add_name remove_name rmdir relabelfrom };
|
2017-09-28 23:34:36 +02:00
|
|
|
|
2018-11-16 18:53:40 +01:00
|
|
|
allow vendor_init unlabeled:{ dir notdevfile_class_set } { getattr relabelfrom };
|
|
|
|
|
2017-09-28 23:34:36 +02:00
|
|
|
allow vendor_init {
|
|
|
|
file_type
|
2018-01-22 23:18:31 +01:00
|
|
|
-core_data_file_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-exec_type
|
2019-02-28 23:11:34 +01:00
|
|
|
-password_slot_metadata_file
|
2019-07-09 04:03:59 +02:00
|
|
|
-ota_metadata_file
|
2017-09-28 23:34:36 +02:00
|
|
|
-runtime_event_log_tags_file
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-unlabeled
|
|
|
|
-vendor_file_type
|
2018-02-01 19:15:34 +01:00
|
|
|
-vold_metadata_file
|
2019-01-23 04:05:29 +01:00
|
|
|
-gsi_metadata_file
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2018-07-31 03:52:46 +02:00
|
|
|
}:file { create getattr open read write setattr relabelfrom unlink map };
|
2017-09-28 23:34:36 +02:00
|
|
|
|
|
|
|
allow vendor_init {
|
|
|
|
file_type
|
2018-01-22 23:18:31 +01:00
|
|
|
-core_data_file_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-exec_type
|
2019-02-28 23:11:34 +01:00
|
|
|
-password_slot_metadata_file
|
2019-07-09 04:03:59 +02:00
|
|
|
-ota_metadata_file
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-unlabeled
|
|
|
|
-vendor_file_type
|
2018-02-01 19:15:34 +01:00
|
|
|
-vold_metadata_file
|
2019-01-23 04:05:29 +01:00
|
|
|
-gsi_metadata_file
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2017-09-28 23:34:36 +02:00
|
|
|
}:{ sock_file fifo_file } { create getattr open read setattr relabelfrom unlink };
|
|
|
|
|
|
|
|
allow vendor_init {
|
|
|
|
file_type
|
2018-10-16 09:02:49 +02:00
|
|
|
-apex_mnt_dir
|
2018-01-22 23:18:31 +01:00
|
|
|
-core_data_file_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-exec_type
|
2019-02-28 23:11:34 +01:00
|
|
|
-password_slot_metadata_file
|
2019-07-09 04:03:59 +02:00
|
|
|
-ota_metadata_file
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-unlabeled
|
|
|
|
-vendor_file_type
|
2018-02-01 19:15:34 +01:00
|
|
|
-vold_metadata_file
|
2019-01-23 04:05:29 +01:00
|
|
|
-gsi_metadata_file
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2017-09-28 23:34:36 +02:00
|
|
|
}:lnk_file { create getattr setattr relabelfrom unlink };
|
|
|
|
|
|
|
|
allow vendor_init {
|
|
|
|
file_type
|
2018-01-22 23:18:31 +01:00
|
|
|
-core_data_file_type
|
|
|
|
-exec_type
|
2018-06-29 04:10:00 +02:00
|
|
|
-mnt_product_file
|
2019-02-28 23:11:34 +01:00
|
|
|
-password_slot_metadata_file
|
2019-07-09 04:03:59 +02:00
|
|
|
-ota_metadata_file
|
2018-09-27 19:21:37 +02:00
|
|
|
-system_file_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-vendor_file_type
|
2018-02-01 19:15:34 +01:00
|
|
|
-vold_metadata_file
|
2019-01-23 04:05:29 +01:00
|
|
|
-gsi_metadata_file
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2017-09-28 23:34:36 +02:00
|
|
|
}: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
|
2018-05-09 16:20:45 +02:00
|
|
|
-keychord_device
|
2017-09-28 23:34:36 +02:00
|
|
|
-sdcard_type
|
|
|
|
-rootfs
|
|
|
|
-proc_uid_time_in_state
|
2017-11-10 23:10:19 +01:00
|
|
|
-proc_uid_concurrent_active_time
|
|
|
|
-proc_uid_concurrent_policy_time
|
2018-07-31 03:52:46 +02:00
|
|
|
}:file { open read setattr map };
|
2017-09-28 23:34:36 +02:00
|
|
|
|
|
|
|
allow vendor_init {
|
|
|
|
fs_type
|
|
|
|
-contextmount_type
|
|
|
|
-sdcard_type
|
|
|
|
-rootfs
|
|
|
|
-proc_uid_time_in_state
|
2017-11-10 23:10:19 +01:00
|
|
|
-proc_uid_concurrent_active_time
|
|
|
|
-proc_uid_concurrent_policy_time
|
2017-09-28 23:34:36 +02:00
|
|
|
}:dir { open read setattr search };
|
|
|
|
|
|
|
|
# chown/chmod on devices, e.g. /dev/ttyHS0
|
|
|
|
allow vendor_init {
|
|
|
|
dev_type
|
2018-05-09 16:20:45 +02:00
|
|
|
-keychord_device
|
2017-09-28 23:34:36 +02:00
|
|
|
-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.
|
Start the process of locking down proc/net
Files in /proc/net leak information. This change is the first step in
determining which files apps may use, whitelisting benign access, and
otherwise removing access while providing safe alternative APIs.
To that end, this change:
* Introduces the proc_net_type attribute which will assigned to any
new SELinux types in /proc/net to avoid removing access to privileged
processes. These processes may be evaluated later, but are lower
priority than apps.
* Labels /proc/net/{tcp,tcp6,udp,udp6} as proc_net_vpn due to existing
use by VPN apps. This may be replaced by an alternative API.
* Audits all other proc/net access for apps.
* Audits proc/net access for other processes which are currently
granted broad read access to /proc/net but should not be including
storaged, zygote, clatd, logd, preopt2cachename and vold.
Bug: 9496886
Bug: 68016944
Test: Boot Taimen-userdebug. On both wifi and cellular: stream youtube
navigate maps, send text message, make voice call, make video call.
Verify no avc "granted" messages in the logs.
Test: A few VPN apps including "VPN Monster", "Turbo VPN", and
"Freighter". Verify no logspam with the current setup.
Test: atest CtsNativeNetTestCases
Test: atest netd_integration_test
Test: atest QtaguidPermissionTest
Test: atest FileSystemPermissionTest
Change-Id: I7e49f796a25cf68bc698c6c9206e24af3ae11457
Merged-In: I7e49f796a25cf68bc698c6c9206e24af3ae11457
(cherry picked from commit 087318957f26e921d62f2e234fc14bff3c59030e)
2018-04-10 21:47:48 +02:00
|
|
|
r_dir_file(vendor_init, proc_net_type)
|
|
|
|
allow vendor_init proc_net_type:file w_file_perms;
|
2017-11-09 23:51:26 +01:00
|
|
|
allow vendor_init self:global_capability_class_set net_admin;
|
2017-09-28 23:34:36 +02:00
|
|
|
|
|
|
|
# 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
|
2018-07-31 03:52:46 +02:00
|
|
|
allow vendor_init serialno_prop:file { getattr open read map };
|
2017-09-28 23:34:36 +02:00
|
|
|
|
|
|
|
# Vendor init can perform operations on trusted and security Extended Attributes
|
2017-11-09 23:51:26 +01:00
|
|
|
allow vendor_init self:global_capability_class_set sys_admin;
|
2017-10-19 09:54:49 +02:00
|
|
|
|
2018-04-11 23:56:47 +02:00
|
|
|
# Raw writes to misc block device
|
|
|
|
allow vendor_init misc_block_device:blk_file w_file_perms;
|
|
|
|
|
2019-03-14 18:45:33 +01:00
|
|
|
# vendor_init is using bootstrap bionic
|
|
|
|
allow vendor_init system_bootstrap_lib_file:dir r_dir_perms;
|
|
|
|
allow vendor_init system_bootstrap_lib_file:file { execute read open getattr map };
|
|
|
|
|
2018-06-01 12:28:59 +02:00
|
|
|
# Everything is labeled as rootfs in recovery mode. Vendor init has to execute
|
|
|
|
# the dynamic linker and shared libraries.
|
|
|
|
recovery_only(`
|
|
|
|
allow vendor_init rootfs:file { r_file_perms execute };
|
|
|
|
')
|
|
|
|
|
2018-01-20 00:21:42 +01:00
|
|
|
not_compatible_property(`
|
|
|
|
set_prop(vendor_init, {
|
|
|
|
property_type
|
2020-01-28 06:43:57 +01:00
|
|
|
-system_internal_property_type
|
|
|
|
-system_restricted_property_type
|
2018-01-20 00:21:42 +01:00
|
|
|
})
|
|
|
|
')
|
|
|
|
|
2018-09-27 19:21:37 +02:00
|
|
|
# Get file context
|
|
|
|
allow vendor_init file_contexts_file:file r_file_perms;
|
|
|
|
|
2019-11-27 19:06:03 +01:00
|
|
|
set_prop(vendor_init, apk_verity_prop)
|
2018-04-09 05:07:32 +02:00
|
|
|
set_prop(vendor_init, bluetooth_a2dp_offload_prop)
|
2019-03-18 04:07:32 +01:00
|
|
|
set_prop(vendor_init, bluetooth_audio_hal_prop)
|
2018-11-06 00:03:16 +01:00
|
|
|
set_prop(vendor_init, cpu_variant_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(vendor_init, debug_prop)
|
2018-06-20 23:08:02 +02:00
|
|
|
set_prop(vendor_init, exported_audio_prop)
|
2018-04-09 05:07:32 +02:00
|
|
|
set_prop(vendor_init, exported_bluetooth_prop)
|
2020-01-06 13:25:00 +01:00
|
|
|
set_prop(vendor_init, exported_camera_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(vendor_init, exported_config_prop)
|
|
|
|
set_prop(vendor_init, exported_dalvik_prop)
|
|
|
|
set_prop(vendor_init, exported_default_prop)
|
|
|
|
set_prop(vendor_init, exported_ffs_prop)
|
|
|
|
set_prop(vendor_init, exported_overlay_prop)
|
|
|
|
set_prop(vendor_init, exported_pm_prop)
|
|
|
|
set_prop(vendor_init, exported_radio_prop)
|
|
|
|
set_prop(vendor_init, exported_system_radio_prop)
|
2018-04-09 05:07:32 +02:00
|
|
|
set_prop(vendor_init, exported_wifi_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(vendor_init, exported2_config_prop)
|
|
|
|
set_prop(vendor_init, exported2_system_prop)
|
|
|
|
set_prop(vendor_init, exported2_vold_prop)
|
|
|
|
set_prop(vendor_init, exported3_default_prop)
|
2018-03-27 06:41:47 +02:00
|
|
|
set_prop(vendor_init, exported3_radio_prop)
|
2020-04-28 22:24:54 +02:00
|
|
|
set_prop(vendor_init, incremental_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(vendor_init, logd_prop)
|
|
|
|
set_prop(vendor_init, log_tag_prop)
|
|
|
|
set_prop(vendor_init, log_prop)
|
2020-01-25 01:31:58 +01:00
|
|
|
set_prop(vendor_init, rebootescrow_hal_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(vendor_init, serialno_prop)
|
2020-04-10 14:00:30 +02:00
|
|
|
set_prop(vendor_init, storage_config_prop)
|
2020-01-08 21:49:27 +01:00
|
|
|
set_prop(vendor_init, userspace_reboot_config_prop)
|
2019-11-06 22:14:58 +01:00
|
|
|
set_prop(vendor_init, vehicle_hal_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(vendor_init, vendor_default_prop)
|
2018-03-30 03:21:31 +02:00
|
|
|
set_prop(vendor_init, vendor_security_patch_level_prop)
|
2020-01-02 09:41:43 +01:00
|
|
|
set_prop(vendor_init, vndk_prop)
|
2020-01-30 02:28:39 +01:00
|
|
|
set_prop(vendor_init, virtual_ab_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(vendor_init, wifi_log_prop)
|
|
|
|
|
|
|
|
get_prop(vendor_init, exported2_radio_prop)
|
|
|
|
get_prop(vendor_init, exported3_system_prop)
|
2019-06-15 02:00:16 +02:00
|
|
|
get_prop(vendor_init, theme_prop)
|
2018-06-28 23:47:52 +02:00
|
|
|
|
2019-11-14 23:18:40 +01:00
|
|
|
get_prop(vendor_init, ota_prop)
|
|
|
|
|
2018-06-28 23:47:52 +02:00
|
|
|
###
|
|
|
|
### neverallow rules
|
|
|
|
###
|
|
|
|
|
|
|
|
# Vendor init shouldn't communicate with any vendor process, nor most system processes.
|
|
|
|
neverallow_establish_socket_comms(vendor_init, { domain -init -logd -su -vendor_init });
|
|
|
|
|
|
|
|
# The vendor_init domain is only entered via an exec based transition from the
|
|
|
|
# init domain, never via setcon().
|
|
|
|
neverallow domain vendor_init:process dyntransition;
|
|
|
|
neverallow { domain -init } vendor_init:process transition;
|
|
|
|
neverallow vendor_init { file_type fs_type -init_exec }:file entrypoint;
|
|
|
|
|
|
|
|
# Never read/follow symlinks created by shell or untrusted apps.
|
2018-08-03 00:54:23 +02:00
|
|
|
neverallow vendor_init { app_data_file privapp_data_file }:lnk_file read;
|
2018-06-28 23:47:52 +02:00
|
|
|
neverallow vendor_init shell_data_file:lnk_file read;
|
|
|
|
# Init should not be creating subdirectories in /data/local/tmp
|
|
|
|
neverallow vendor_init shell_data_file:dir { write add_name remove_name };
|
|
|
|
|
|
|
|
# init should never execute a program without changing to another domain.
|
|
|
|
neverallow vendor_init { file_type fs_type }:file execute_no_trans;
|
|
|
|
|
|
|
|
# Init never adds or uses services via service_manager.
|
|
|
|
neverallow vendor_init service_manager_type:service_manager { add find };
|
|
|
|
neverallow vendor_init servicemanager:service_manager list;
|
2018-09-13 20:07:14 +02:00
|
|
|
|
|
|
|
# vendor_init should never be ptraced
|
|
|
|
neverallow * vendor_init:process ptrace;
|