75806ef3c5
Ideally, public should only contain APIs (types / attributes) for vendor. The other statements like allow/neverallow/typeattributes are regarded as implementation detail for platform and should be in private. Bug: 232023812 Test: m selinux_policy Test: diff <(git diff --staged | grep "^-" | cut -b2- | sort) \ <(git diff --staged | grep "^+" | cut -b2- | sort) Test: remove comments on plat_sepolicy.cil, replace base_typeattr_* to base_typeattr and then compare old and new plat_sepolicy.cil Change-Id: I5e7d2da4465ab0216de6bacdf03077d37f6ffe12
212 lines
7.2 KiB
Text
212 lines
7.2 KiB
Text
typeattribute recovery coredomain;
|
|
|
|
# The allow rules are only included in the recovery policy.
|
|
# Otherwise recovery is only allowed the domain rules.
|
|
recovery_only(`
|
|
# Reboot the device
|
|
set_prop(recovery, powerctl_prop)
|
|
|
|
# Read serial number of the device from system properties
|
|
get_prop(recovery, serialno_prop)
|
|
|
|
# Set sys.usb.ffs.ready when starting minadbd for sideload.
|
|
get_prop(recovery, ffs_config_prop)
|
|
set_prop(recovery, ffs_control_prop)
|
|
|
|
# Set sys.usb.config when switching into fastboot.
|
|
set_prop(recovery, usb_control_prop)
|
|
set_prop(recovery, usb_prop)
|
|
|
|
# Read ro.boot.bootreason
|
|
get_prop(recovery, bootloader_boot_reason_prop)
|
|
|
|
# Read storage properties (for correctly formatting filesystems)
|
|
get_prop(recovery, storage_config_prop)
|
|
|
|
set_prop(recovery, gsid_prop)
|
|
|
|
# These are needed to allow recovery to manage network
|
|
allow recovery self:netlink_route_socket { create write read nlmsg_readpriv nlmsg_read };
|
|
allow recovery self:global_capability_class_set net_admin;
|
|
allow recovery self:tcp_socket { create ioctl };
|
|
allowxperm recovery self:tcp_socket ioctl { SIOCGIFFLAGS SIOCSIFFLAGS };
|
|
|
|
# Start snapuserd for merging VABC updates
|
|
set_prop(recovery, ctl_snapuserd_prop)
|
|
|
|
# Needed to communicate with snapuserd to complete merges.
|
|
allow recovery snapuserd_socket:sock_file write;
|
|
allow recovery snapuserd:unix_stream_socket connectto;
|
|
allow recovery dm_user_device:dir r_dir_perms;
|
|
get_prop(recovery, snapuserd_prop)
|
|
|
|
# Set fastbootd protocol property
|
|
set_prop(recovery, fastbootd_protocol_prop)
|
|
|
|
get_prop(recovery, recovery_config_prop)
|
|
|
|
# Needed to read bootconfig parameters through libfs_mgr
|
|
allow recovery proc_bootconfig:file r_file_perms;
|
|
|
|
# Allow recovery to perform an update as update_engine would do.
|
|
typeattribute recovery update_engine_common;
|
|
# Recovery can use HIDL HALs in passthrough mode
|
|
passthrough_hal_client_domain(recovery, hal_bootctl)
|
|
|
|
# Recovery can use AIDL HALs in binder mode
|
|
binder_use(recovery)
|
|
hal_client_domain(recovery, hal_health)
|
|
|
|
allow recovery self:global_capability_class_set {
|
|
chown
|
|
dac_override
|
|
dac_read_search
|
|
fowner
|
|
setuid
|
|
setgid
|
|
sys_admin
|
|
sys_tty_config
|
|
};
|
|
|
|
# Run helpers from / or /system without changing domain.
|
|
r_dir_file(recovery, rootfs)
|
|
allow recovery rootfs:file execute_no_trans;
|
|
allow recovery system_file:file execute_no_trans;
|
|
allow recovery toolbox_exec:file rx_file_perms;
|
|
|
|
# Mount filesystems.
|
|
allow recovery rootfs:dir mounton;
|
|
allow recovery tmpfs:dir mounton;
|
|
allow recovery { fs_type enforce_debugfs_restriction(`-debugfs_type') }:filesystem ~relabelto;
|
|
allow recovery unlabeled:filesystem ~relabelto;
|
|
allow recovery contextmount_type:filesystem relabelto;
|
|
|
|
# We may be asked to set an SELinux label for a type not known to the
|
|
# currently loaded policy. Allow it.
|
|
allow recovery unlabeled:{ file lnk_file } { create_file_perms relabelfrom relabelto };
|
|
allow recovery unlabeled:dir { create_dir_perms relabelfrom relabelto };
|
|
|
|
# Get file contexts
|
|
allow recovery file_contexts_file:file r_file_perms;
|
|
|
|
# Write to /proc/sys/vm/drop_caches
|
|
allow recovery proc_drop_caches:file w_file_perms;
|
|
|
|
# Read /proc/swaps
|
|
allow recovery proc_swaps:file r_file_perms;
|
|
|
|
# Read kernel config through libvintf for OTA matching
|
|
allow recovery config_gz:file { open read getattr };
|
|
|
|
# Write to /sys/class/android_usb/android0/enable.
|
|
r_dir_file(recovery, sysfs_android_usb)
|
|
allow recovery sysfs_android_usb:file w_file_perms;
|
|
|
|
# Write to /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq.
|
|
allow recovery sysfs_devices_system_cpu:file w_file_perms;
|
|
|
|
allow recovery sysfs_batteryinfo:file r_file_perms;
|
|
|
|
# Read /sysfs/fs/ext4/features
|
|
r_dir_file(recovery, sysfs_fs_ext4_features)
|
|
|
|
# Read from /sys/class/leds/lcd-backlight/max_brightness and write to /s/c/l/l/brightness to
|
|
# control backlight brightness.
|
|
allow recovery sysfs_leds:dir r_dir_perms;
|
|
allow recovery sysfs_leds:file rw_file_perms;
|
|
allow recovery sysfs_leds:lnk_file read;
|
|
|
|
allow recovery kernel:system syslog_read;
|
|
|
|
# Access /dev/usb-ffs/adb/ep0
|
|
allow recovery functionfs:dir search;
|
|
allow recovery functionfs:file rw_file_perms;
|
|
allowxperm recovery functionfs:file ioctl FUNCTIONFS_ENDPOINT_DESC;
|
|
|
|
# Access to /sys/fs/selinux/policyvers for compatibility check
|
|
allow recovery selinuxfs:file r_file_perms;
|
|
|
|
# Required to e.g. wipe userdata/cache.
|
|
allow recovery device:dir r_dir_perms;
|
|
allow recovery block_device:dir r_dir_perms;
|
|
allow recovery dev_type:blk_file rw_file_perms;
|
|
allowxperm recovery { userdata_block_device metadata_block_device cache_block_device }:blk_file ioctl BLKPBSZGET;
|
|
|
|
# GUI
|
|
allow recovery graphics_device:chr_file rw_file_perms;
|
|
allow recovery graphics_device:dir r_dir_perms;
|
|
allow recovery input_device:dir r_dir_perms;
|
|
allow recovery input_device:chr_file r_file_perms;
|
|
allow recovery tty_device:chr_file rw_file_perms;
|
|
|
|
# Create /tmp/recovery.log and execute /tmp/update_binary.
|
|
allow recovery tmpfs:file { create_file_perms x_file_perms };
|
|
allow recovery tmpfs:dir create_dir_perms;
|
|
|
|
# Manage files on /cache and /cache/recovery
|
|
allow recovery { cache_file cache_recovery_file }:dir create_dir_perms;
|
|
allow recovery { cache_file cache_recovery_file }:file create_file_perms;
|
|
|
|
# Read /sys/class/thermal/*/temp for thermal info.
|
|
r_dir_file(recovery, sysfs_thermal)
|
|
|
|
# Read files on /oem.
|
|
r_dir_file(recovery, oemfs);
|
|
|
|
# Use setfscreatecon() to label files for OTA updates.
|
|
allow recovery self:process setfscreate;
|
|
|
|
# Allow recovery to create a fuse filesystem, and read files from it.
|
|
allow recovery fuse_device:chr_file rw_file_perms;
|
|
allow recovery fuse:dir r_dir_perms;
|
|
allow recovery fuse:file r_file_perms;
|
|
|
|
wakelock_use(recovery)
|
|
|
|
# This line seems suspect, as it should not really need to
|
|
# set scheduling parameters for a kernel domain task.
|
|
allow recovery kernel:process setsched;
|
|
|
|
# These are needed to update dynamic partitions in recovery.
|
|
r_dir_file(recovery, sysfs_dm)
|
|
allowxperm recovery super_block_device_type:blk_file ioctl { BLKIOMIN BLKALIGNOFF };
|
|
|
|
# Allow using libfiemap/gsid directly (no binder in recovery).
|
|
allow recovery gsi_metadata_file_type:dir search;
|
|
allow recovery ota_metadata_file:dir rw_dir_perms;
|
|
allow recovery ota_metadata_file:file create_file_perms;
|
|
|
|
# Allow mounting /metadata for writing update states
|
|
allow recovery metadata_file:dir { getattr mounton };
|
|
|
|
# Recovery uses liblogwrap to write fsck logs to kmsg, liblogwrap requires devpts.
|
|
allow recovery devpts:chr_file rw_file_perms;
|
|
allow recovery kmsg_device:chr_file { getattr w_file_perms };
|
|
')
|
|
|
|
###
|
|
### neverallow rules
|
|
###
|
|
|
|
# Recovery should never touch /data.
|
|
#
|
|
# In particular, if /data is encrypted, it is not accessible
|
|
# to recovery anyway.
|
|
#
|
|
# For now, we only enforce write/execute restrictions, as domain.te
|
|
# contains a number of read-only rules that apply to all
|
|
# domains, including recovery.
|
|
#
|
|
# TODO: tighten this up further.
|
|
neverallow recovery {
|
|
data_file_type
|
|
-cache_file
|
|
-cache_recovery_file
|
|
with_native_coverage(`-method_trace_data_file')
|
|
}:file { no_w_file_perms no_x_file_perms };
|
|
neverallow recovery {
|
|
data_file_type
|
|
-cache_file
|
|
-cache_recovery_file
|
|
with_native_coverage(`-method_trace_data_file')
|
|
}:dir no_w_dir_perms;
|