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;
|
2021-02-12 00:18:11 +01:00
|
|
|
allow vendor_init cgroup_v2:dir create_dir_perms;
|
|
|
|
allow vendor_init cgroup_v2: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
|
2021-03-22 06:46:12 +01:00
|
|
|
-gsi_metadata_file_type
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2020-06-02 11:47:16 +02:00
|
|
|
-userspace_reboot_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
|
2021-03-22 06:46:12 +01:00
|
|
|
-gsi_metadata_file_type
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2020-05-11 13:49:07 +02:00
|
|
|
-apex_info_file
|
2020-06-02 11:47:16 +02:00
|
|
|
-userspace_reboot_metadata_file
|
2021-05-05 07:01:51 +02:00
|
|
|
enforce_debugfs_restriction(`-debugfs_type')
|
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
|
2021-03-22 06:46:12 +01:00
|
|
|
-gsi_metadata_file_type
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2020-06-02 11:47:16 +02:00
|
|
|
-userspace_reboot_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
|
2021-03-22 06:46:12 +01:00
|
|
|
-gsi_metadata_file_type
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2020-06-02 11:47:16 +02:00
|
|
|
-userspace_reboot_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
|
2021-03-22 06:46:12 +01:00
|
|
|
-gsi_metadata_file_type
|
2019-03-12 16:37:13 +01:00
|
|
|
-apex_metadata_file
|
2020-06-02 11:47:16 +02:00
|
|
|
-userspace_reboot_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
|
2021-06-23 10:21:49 +02:00
|
|
|
-fusefs_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-rootfs
|
|
|
|
-proc_uid_time_in_state
|
2017-11-10 23:10:19 +01:00
|
|
|
-proc_uid_concurrent_active_time
|
|
|
|
-proc_uid_concurrent_policy_time
|
2021-05-05 07:01:51 +02:00
|
|
|
enforce_debugfs_restriction(`-debugfs_type')
|
2018-07-31 03:52:46 +02:00
|
|
|
}:file { open read setattr map };
|
2017-09-28 23:34:36 +02:00
|
|
|
|
2021-05-05 07:01:51 +02:00
|
|
|
allow vendor_init tracefs_type:file { open read setattr map };
|
|
|
|
|
2017-09-28 23:34:36 +02:00
|
|
|
allow vendor_init {
|
|
|
|
fs_type
|
|
|
|
-contextmount_type
|
|
|
|
-sdcard_type
|
2021-06-23 10:21:49 +02:00
|
|
|
-fusefs_type
|
2017-09-28 23:34:36 +02:00
|
|
|
-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 };
|
|
|
|
|
|
|
|
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
|
2022-01-23 15:55:41 +01:00
|
|
|
use_bootstrap_libs(vendor_init)
|
2019-03-14 18:45:33 +01:00
|
|
|
|
2021-02-19 00:45:02 +01:00
|
|
|
# allow filesystem tuning
|
|
|
|
allow vendor_init userdata_sysdev:file create_file_perms;
|
|
|
|
|
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;
|
|
|
|
|
2021-02-03 19:39:31 +01:00
|
|
|
# Allow vendor_init to (re)set nice
|
|
|
|
allow vendor_init self:capability sys_nice;
|
|
|
|
|
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)
|
2021-06-19 01:59:41 +02:00
|
|
|
set_prop(vendor_init, camera2_extensions_prop)
|
2020-11-18 23:08:41 +01:00
|
|
|
set_prop(vendor_init, camerax_extensions_prop)
|
2018-11-06 00:03:16 +01:00
|
|
|
set_prop(vendor_init, cpu_variant_prop)
|
2020-05-12 15:51:48 +02:00
|
|
|
set_prop(vendor_init, dalvik_runtime_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(vendor_init, debug_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_default_prop)
|
|
|
|
set_prop(vendor_init, exported_overlay_prop)
|
|
|
|
set_prop(vendor_init, exported_pm_prop)
|
2020-04-27 16:49:15 +02:00
|
|
|
set_prop(vendor_init, ffs_control_prop)
|
2021-03-11 21:51:25 +01:00
|
|
|
set_prop(vendor_init, hw_timeout_multiplier_prop)
|
2020-04-28 22:24:54 +02:00
|
|
|
set_prop(vendor_init, incremental_prop)
|
2020-05-05 21:41:02 +02:00
|
|
|
set_prop(vendor_init, lmkd_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)
|
2021-02-17 18:54:30 +01:00
|
|
|
set_prop(vendor_init, qemu_hw_prop)
|
2020-07-28 08:17:24 +02:00
|
|
|
set_prop(vendor_init, radio_control_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)
|
2021-01-26 11:25:38 +01:00
|
|
|
set_prop(vendor_init, soc_prop)
|
2020-04-24 14:25:17 +02:00
|
|
|
set_prop(vendor_init, surfaceflinger_color_prop)
|
2020-04-27 14:13:01 +02:00
|
|
|
set_prop(vendor_init, usb_control_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)
|
2021-04-23 01:09:56 +02:00
|
|
|
set_prop(vendor_init, vold_post_fs_data_prop)
|
2020-06-25 14:20:42 +02:00
|
|
|
set_prop(vendor_init, wifi_hal_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
set_prop(vendor_init, wifi_log_prop)
|
2020-05-08 13:42:25 +02:00
|
|
|
set_prop(vendor_init, zram_control_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
|
2020-04-24 08:03:01 +02:00
|
|
|
get_prop(vendor_init, boot_status_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
get_prop(vendor_init, exported3_system_prop)
|
2020-05-13 18:38:40 +02:00
|
|
|
get_prop(vendor_init, ota_prop)
|
2020-09-11 03:51:58 +02:00
|
|
|
get_prop(vendor_init, power_debug_prop)
|
2020-05-13 18:38:40 +02:00
|
|
|
get_prop(vendor_init, provisioned_prop)
|
|
|
|
get_prop(vendor_init, retaildemo_prop)
|
2020-06-17 16:13:21 +02:00
|
|
|
get_prop(vendor_init, surfaceflinger_display_prop)
|
2021-04-06 06:46:16 +02:00
|
|
|
get_prop(vendor_init, test_harness_prop)
|
2019-06-15 02:00:16 +02:00
|
|
|
get_prop(vendor_init, theme_prop)
|
2021-05-21 03:06:03 +02:00
|
|
|
set_prop(vendor_init, dck_prop)
|
2018-06-28 23:47:52 +02:00
|
|
|
|
2019-11-14 23:18:40 +01:00
|
|
|
|
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;
|