fastbootd.te 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # fastbootd (used in recovery init.rc for /sbin/fastbootd)
  2. # Declare the domain unconditionally so we can always reference it
  3. # in neverallow rules.
  4. type fastbootd, domain;
  5. # But the allow rules are only included in the recovery policy.
  6. # Otherwise fastbootd is only allowed the domain rules.
  7. recovery_only(`
  8. # fastbootd can only use HALs in passthrough mode
  9. passthrough_hal_client_domain(fastbootd, hal_bootctl)
  10. # Access /dev/usb-ffs/fastbootd/ep0
  11. allow fastbootd functionfs:dir search;
  12. allow fastbootd functionfs:file rw_file_perms;
  13. allowxperm fastbootd functionfs:file ioctl { FUNCTIONFS_ENDPOINT_DESC };
  14. # Log to serial
  15. allow fastbootd kmsg_device:chr_file { open getattr write };
  16. # battery info
  17. allow fastbootd sysfs_batteryinfo:file r_file_perms;
  18. allow fastbootd device:dir r_dir_perms;
  19. # Reboot the device
  20. set_prop(fastbootd, powerctl_prop)
  21. # Read serial number of the device from system properties
  22. get_prop(fastbootd, serialno_prop)
  23. # For dev/block/by-name dir
  24. allow fastbootd block_device:dir r_dir_perms;
  25. # Needed for DM_DEV_CREATE ioctl call
  26. allow fastbootd self:capability sys_admin;
  27. # Set sys.usb.ffs.ready.
  28. set_prop(fastbootd, ffs_prop)
  29. set_prop(fastbootd, exported_ffs_prop)
  30. unix_socket_connect(fastbootd, recovery, recovery)
  31. # Required for flashing
  32. allow fastbootd dm_device:chr_file rw_file_perms;
  33. allow fastbootd dm_device:blk_file rw_file_perms;
  34. allow fastbootd super_block_device_type:blk_file rw_file_perms;
  35. allow fastbootd {
  36. boot_block_device
  37. metadata_block_device
  38. system_block_device
  39. userdata_block_device
  40. }:blk_file { w_file_perms getattr ioctl };
  41. # For disabling/wiping GSI.
  42. allow fastbootd metadata_block_device:blk_file r_file_perms;
  43. allow fastbootd {rootfs tmpfs}:dir mounton;
  44. allow fastbootd metadata_file:dir search;
  45. allow fastbootd gsi_metadata_file:dir r_dir_perms;
  46. allow fastbootd gsi_metadata_file:file rw_file_perms;
  47. allowxperm fastbootd super_block_device_type:blk_file ioctl { BLKIOMIN BLKALIGNOFF };
  48. allowxperm fastbootd {
  49. metadata_block_device
  50. userdata_block_device
  51. dm_device
  52. }:blk_file ioctl { BLKSECDISCARD BLKDISCARD };
  53. allow fastbootd misc_block_device:blk_file rw_file_perms;
  54. allow fastbootd proc_cmdline:file r_file_perms;
  55. allow fastbootd rootfs:dir r_dir_perms;
  56. # Needed to read fstab node from device tree.
  57. allow fastbootd sysfs_dt_firmware_android:file r_file_perms;
  58. allow fastbootd sysfs_dt_firmware_android:dir r_dir_perms;
  59. # Needed for realpath() call to resolve symlinks.
  60. allow fastbootd block_device:dir getattr;
  61. userdebug_or_eng(`
  62. # Refined manipulation of /mnt/scratch, without these perms resorts
  63. # to deleting scratch partition when partition(s) are flashed.
  64. allow fastbootd self:process setfscreate;
  65. allow fastbootd cache_file:dir search;
  66. allow fastbootd proc_filesystems:file { getattr open read };
  67. allow fastbootd self:capability sys_rawio;
  68. dontaudit fastbootd kernel:system module_request;
  69. allowxperm fastbootd dev_type:blk_file ioctl BLKROSET;
  70. allow fastbootd overlayfs_file:dir { create_dir_perms mounton };
  71. allow fastbootd {
  72. system_file_type
  73. unlabeled
  74. vendor_file_type
  75. }:dir { remove_name rmdir search write };
  76. allow fastbootd {
  77. overlayfs_file
  78. system_file_type
  79. unlabeled
  80. vendor_file_type
  81. }:{ file lnk_file } unlink;
  82. allow fastbootd tmpfs:dir rw_dir_perms;
  83. allow fastbootd labeledfs:filesystem { mount unmount };
  84. get_prop(fastbootd, persistent_properties_ready_prop)
  85. ')
  86. ')
  87. ###
  88. ### neverallow rules
  89. ###
  90. # Write permission is required to wipe userdata
  91. # until recovery supports vold.
  92. neverallow fastbootd {
  93. data_file_type
  94. }:file { no_x_file_perms };