apexd.te 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. typeattribute apexd coredomain;
  2. init_daemon_domain(apexd)
  3. # Allow creating, reading and writing of APEX files/dirs in the APEX data dir
  4. allow apexd apex_data_file:dir create_dir_perms;
  5. allow apexd apex_data_file:file create_file_perms;
  6. # Allow creating, reading and writing of APEX files/dirs in the APEX metadata dir
  7. allow apexd metadata_file:dir search;
  8. allow apexd apex_metadata_file:dir create_dir_perms;
  9. allow apexd apex_metadata_file:file create_file_perms;
  10. # allow apexd to create loop devices with /dev/loop-control
  11. allow apexd loop_control_device:chr_file rw_file_perms;
  12. # allow apexd to access loop devices
  13. allow apexd loop_device:blk_file rw_file_perms;
  14. allowxperm apexd loop_device:blk_file ioctl {
  15. LOOP_GET_STATUS64
  16. LOOP_SET_STATUS64
  17. LOOP_SET_FD
  18. LOOP_SET_BLOCK_SIZE
  19. LOOP_SET_DIRECT_IO
  20. LOOP_CLR_FD
  21. BLKFLSBUF
  22. };
  23. # allow apexd to access /dev/block
  24. allow apexd block_device:dir r_dir_perms;
  25. # allow apexd to access /dev/block/dm-* (device-mapper entries)
  26. allow apexd dm_device:chr_file rw_file_perms;
  27. allow apexd dm_device:blk_file rw_file_perms;
  28. # sys_admin is required to access the device-mapper and mount
  29. allow apexd self:global_capability_class_set sys_admin;
  30. # allow apexd to create a mount point in /apex
  31. allow apexd apex_mnt_dir:dir create_dir_perms;
  32. # allow apexd to mount in /apex
  33. allow apexd apex_mnt_dir:filesystem { mount unmount };
  34. allow apexd apex_mnt_dir:dir mounton;
  35. # allow apexd to create symlinks in /apex
  36. allow apexd apex_mnt_dir:lnk_file create_file_perms;
  37. # allow apexd to unlink apex files in /data/apex/active
  38. # note that apexd won't be able to unlink files in /data/app-staging/session_XXXX,
  39. # because it doesn't have write permission for staging_data_file object.
  40. allow apexd staging_data_file:file unlink;
  41. # allow apexd to read files from /data/app-staging and hardlink them to /data/apex.
  42. allow apexd staging_data_file:dir r_dir_perms;
  43. allow apexd staging_data_file:file { r_file_perms link };
  44. # Unmount and mount filesystems
  45. allow apexd labeledfs:filesystem { mount unmount };
  46. # /sys directory tree traversal
  47. allow apexd sysfs_type:dir search;
  48. # Configure read-ahead of dm-verity and loop devices
  49. # for dm-X
  50. allow apexd sysfs_dm:dir r_dir_perms;
  51. allow apexd sysfs_dm:file rw_file_perms;
  52. # for loopX
  53. allow apexd sysfs_loop:dir r_dir_perms;
  54. allow apexd sysfs_loop:file rw_file_perms;
  55. # Spawning a libbinder thread results in a dac_override deny,
  56. # /dev/cpuset/tasks is owned by system.
  57. #
  58. # See b/35323867#comment3
  59. dontaudit apexd self:global_capability_class_set { dac_override dac_read_search };
  60. # Allow apexd to log to the kernel.
  61. allow apexd kmsg_device:chr_file w_file_perms;
  62. # Allow apexd to reboot device. Required for rollbacks of apexes that are
  63. # not covered by rollback manager.
  64. set_prop(apexd, powerctl_prop)
  65. # Find the vold service, and call into vold to manage FS checkpoints
  66. allow apexd vold_service:service_manager find;
  67. binder_call(apexd, vold)
  68. # Apex pre- & post-install permission.
  69. # Allow self-execute for the fork mount helper.
  70. allow apexd apexd_exec:file execute_no_trans;
  71. # Unshare and make / private so that hooks cannot influence the
  72. # running system.
  73. allow apexd rootfs:dir mounton;
  74. # Allow to execute shell for pre- and postinstall scripts. A transition
  75. # rule is required, thus restricted to execute and not execute_no_trans.
  76. allow apexd shell_exec:file { r_file_perms execute };
  77. # apexd is using bootstrap bionic
  78. allow apexd system_bootstrap_lib_file:dir r_dir_perms;
  79. allow apexd system_bootstrap_lib_file:file { execute read open getattr map };
  80. # Allow transition to ART APEX preinstall domain.
  81. domain_auto_trans(apexd, art_apex_preinstall_exec, art_apex_preinstall)
  82. # Allow transition to ART APEX postinstall domain.
  83. domain_auto_trans(apexd, art_apex_postinstall_exec, art_apex_postinstall)
  84. # Allow transition to test APEX preinstall domain.
  85. userdebug_or_eng(`
  86. domain_auto_trans(apexd, apex_test_prepostinstall_exec, apex_test_prepostinstall)
  87. ')
  88. neverallow { domain -apexd -init } apex_data_file:dir no_w_dir_perms;
  89. neverallow { domain -apexd -init } apex_metadata_file:dir no_w_dir_perms;
  90. neverallow { domain -apexd -init -kernel } apex_data_file:file no_w_file_perms;
  91. neverallow { domain -apexd -init -kernel } apex_metadata_file:file no_w_file_perms;
  92. neverallow { domain -apexd } apex_mnt_dir:lnk_file no_w_file_perms;