2018-05-29 19:54:16 +02:00
|
|
|
# fastbootd (used in recovery init.rc for /sbin/fastbootd)
|
|
|
|
|
|
|
|
# Declare the domain unconditionally so we can always reference it
|
|
|
|
# in neverallow rules.
|
|
|
|
type fastbootd, domain;
|
|
|
|
|
|
|
|
# But the allow rules are only included in the recovery policy.
|
|
|
|
# Otherwise fastbootd is only allowed the domain rules.
|
|
|
|
recovery_only(`
|
|
|
|
# fastbootd can only use HALs in passthrough mode
|
|
|
|
passthrough_hal_client_domain(fastbootd, hal_bootctl)
|
|
|
|
|
|
|
|
# Access /dev/usb-ffs/fastbootd/ep0
|
|
|
|
allow fastbootd functionfs:dir search;
|
|
|
|
allow fastbootd functionfs:file rw_file_perms;
|
|
|
|
|
2018-10-12 18:26:05 +02:00
|
|
|
allowxperm fastbootd functionfs:file ioctl { FUNCTIONFS_ENDPOINT_DESC };
|
2018-05-29 19:54:16 +02:00
|
|
|
# Log to serial
|
2019-03-20 23:36:26 +01:00
|
|
|
allow fastbootd kmsg_device:chr_file { open getattr write };
|
2018-05-29 19:54:16 +02:00
|
|
|
|
|
|
|
# battery info
|
|
|
|
allow fastbootd sysfs_batteryinfo:file r_file_perms;
|
|
|
|
|
|
|
|
allow fastbootd device:dir r_dir_perms;
|
|
|
|
|
|
|
|
# Reboot the device
|
|
|
|
set_prop(fastbootd, powerctl_prop)
|
|
|
|
|
|
|
|
# Read serial number of the device from system properties
|
|
|
|
get_prop(fastbootd, serialno_prop)
|
|
|
|
|
2019-02-15 22:58:20 +01:00
|
|
|
# For dev/block/by-name dir
|
|
|
|
allow fastbootd block_device:dir r_dir_perms;
|
|
|
|
|
|
|
|
# Needed for DM_DEV_CREATE ioctl call
|
|
|
|
allow fastbootd self:capability sys_admin;
|
|
|
|
|
2018-05-29 19:54:16 +02:00
|
|
|
# Set sys.usb.ffs.ready.
|
|
|
|
set_prop(fastbootd, ffs_prop)
|
|
|
|
set_prop(fastbootd, exported_ffs_prop)
|
|
|
|
|
|
|
|
unix_socket_connect(fastbootd, recovery, recovery)
|
|
|
|
|
|
|
|
# Required for flashing
|
|
|
|
allow fastbootd dm_device:chr_file rw_file_perms;
|
|
|
|
allow fastbootd dm_device:blk_file rw_file_perms;
|
|
|
|
|
2019-03-22 21:55:13 +01:00
|
|
|
allow fastbootd super_block_device_type:blk_file rw_file_perms;
|
2018-09-12 21:42:59 +02:00
|
|
|
allow fastbootd {
|
|
|
|
boot_block_device
|
|
|
|
metadata_block_device
|
|
|
|
system_block_device
|
|
|
|
userdata_block_device
|
|
|
|
}:blk_file { w_file_perms getattr ioctl };
|
|
|
|
|
2019-01-23 04:05:29 +01:00
|
|
|
# For disabling/wiping GSI.
|
|
|
|
allow fastbootd metadata_block_device:blk_file r_file_perms;
|
|
|
|
allow fastbootd {rootfs tmpfs}:dir mounton;
|
|
|
|
allow fastbootd metadata_file:dir search;
|
|
|
|
allow fastbootd gsi_metadata_file:dir r_dir_perms;
|
|
|
|
allow fastbootd gsi_metadata_file:file rw_file_perms;
|
|
|
|
|
2019-03-22 21:55:13 +01:00
|
|
|
allowxperm fastbootd super_block_device_type:blk_file ioctl { BLKIOMIN BLKALIGNOFF };
|
2018-10-30 23:39:28 +01:00
|
|
|
|
2018-09-12 21:42:59 +02:00
|
|
|
allowxperm fastbootd {
|
|
|
|
metadata_block_device
|
|
|
|
userdata_block_device
|
2019-02-21 20:37:39 +01:00
|
|
|
dm_device
|
2018-09-12 21:42:59 +02:00
|
|
|
}:blk_file ioctl { BLKSECDISCARD BLKDISCARD };
|
2018-05-29 19:54:16 +02:00
|
|
|
|
|
|
|
allow fastbootd misc_block_device:blk_file rw_file_perms;
|
|
|
|
|
|
|
|
allow fastbootd proc_cmdline:file r_file_perms;
|
|
|
|
allow fastbootd rootfs:dir r_dir_perms;
|
2018-12-11 20:10:28 +01:00
|
|
|
|
|
|
|
# Needed to read fstab node from device tree.
|
2018-05-29 19:54:16 +02:00
|
|
|
allow fastbootd sysfs_dt_firmware_android:file r_file_perms;
|
2018-12-11 20:10:28 +01:00
|
|
|
allow fastbootd sysfs_dt_firmware_android:dir r_dir_perms;
|
2018-10-15 18:00:38 +02:00
|
|
|
|
2019-06-22 00:50:07 +02:00
|
|
|
# Needed because libdm reads sysfs to validate when a dm path is ready.
|
|
|
|
r_dir_file(fastbootd, sysfs_dm)
|
|
|
|
|
2018-12-11 20:10:28 +01:00
|
|
|
# Needed for realpath() call to resolve symlinks.
|
|
|
|
allow fastbootd block_device:dir getattr;
|
2018-10-15 18:00:38 +02:00
|
|
|
userdebug_or_eng(`
|
|
|
|
# Refined manipulation of /mnt/scratch, without these perms resorts
|
|
|
|
# to deleting scratch partition when partition(s) are flashed.
|
|
|
|
allow fastbootd self:process setfscreate;
|
2019-03-15 19:52:40 +01:00
|
|
|
allow fastbootd cache_file:dir search;
|
|
|
|
allow fastbootd proc_filesystems:file { getattr open read };
|
|
|
|
allow fastbootd self:capability sys_rawio;
|
|
|
|
dontaudit fastbootd kernel:system module_request;
|
|
|
|
allowxperm fastbootd dev_type:blk_file ioctl BLKROSET;
|
2018-10-15 18:00:38 +02:00
|
|
|
allow fastbootd overlayfs_file:dir { create_dir_perms mounton };
|
|
|
|
allow fastbootd {
|
|
|
|
system_file_type
|
|
|
|
unlabeled
|
|
|
|
vendor_file_type
|
|
|
|
}:dir { remove_name rmdir search write };
|
|
|
|
allow fastbootd {
|
|
|
|
overlayfs_file
|
|
|
|
system_file_type
|
|
|
|
unlabeled
|
|
|
|
vendor_file_type
|
|
|
|
}:{ file lnk_file } unlink;
|
|
|
|
allow fastbootd tmpfs:dir rw_dir_perms;
|
|
|
|
allow fastbootd labeledfs:filesystem { mount unmount };
|
|
|
|
get_prop(fastbootd, persistent_properties_ready_prop)
|
|
|
|
')
|
2018-05-29 19:54:16 +02:00
|
|
|
')
|
|
|
|
|
|
|
|
###
|
|
|
|
### neverallow rules
|
|
|
|
###
|
|
|
|
|
|
|
|
# Write permission is required to wipe userdata
|
|
|
|
# until recovery supports vold.
|
|
|
|
neverallow fastbootd {
|
|
|
|
data_file_type
|
|
|
|
}:file { no_x_file_perms };
|