mediaserver.te 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. # mediaserver - multimedia daemon
  2. type mediaserver, domain;
  3. type mediaserver_exec, system_file_type, exec_type, file_type;
  4. type mediaserver_tmpfs, file_type;
  5. typeattribute mediaserver mlstrustedsubject;
  6. net_domain(mediaserver)
  7. r_dir_file(mediaserver, sdcard_type)
  8. r_dir_file(mediaserver, cgroup)
  9. # stat /proc/self
  10. allow mediaserver proc:lnk_file getattr;
  11. # open /vendor/lib/mediadrm
  12. allow mediaserver system_file:dir r_dir_perms;
  13. userdebug_or_eng(`
  14. # ptrace to processes in the same domain for memory leak detection
  15. allow mediaserver self:process ptrace;
  16. ')
  17. binder_use(mediaserver)
  18. binder_call(mediaserver, binderservicedomain)
  19. binder_call(mediaserver, appdomain)
  20. binder_service(mediaserver)
  21. allow mediaserver media_data_file:dir create_dir_perms;
  22. allow mediaserver media_data_file:file create_file_perms;
  23. allow mediaserver { app_data_file privapp_data_file }:file { append getattr ioctl lock map read write };
  24. allow mediaserver sdcard_type:file write;
  25. allow mediaserver gpu_device:chr_file rw_file_perms;
  26. allow mediaserver video_device:dir r_dir_perms;
  27. allow mediaserver video_device:chr_file rw_file_perms;
  28. set_prop(mediaserver, audio_prop)
  29. # Read resources from open apk files passed over Binder.
  30. allow mediaserver apk_data_file:file { read getattr };
  31. allow mediaserver asec_apk_file:file { read getattr };
  32. allow mediaserver ringtone_file:file { read getattr };
  33. # Read /data/data/com.android.providers.telephony files passed over Binder.
  34. allow mediaserver radio_data_file:file { read getattr };
  35. # Use pipes passed over Binder from app domains.
  36. allow mediaserver appdomain:fifo_file { getattr read write };
  37. allow mediaserver rpmsg_device:chr_file rw_file_perms;
  38. # Inter System processes communicate over named pipe (FIFO)
  39. allow mediaserver system_server:fifo_file r_file_perms;
  40. r_dir_file(mediaserver, media_rw_data_file)
  41. # Grant access to read files on appfuse.
  42. allow mediaserver app_fuse_file:file { read getattr };
  43. # Needed on some devices for playing DRM protected content,
  44. # but seems expected and appropriate for all devices.
  45. unix_socket_connect(mediaserver, drmserver, drmserver)
  46. # Needed on some devices for playing audio on paired BT device,
  47. # but seems appropriate for all devices.
  48. unix_socket_connect(mediaserver, bluetooth, bluetooth)
  49. add_service(mediaserver, mediaserver_service)
  50. allow mediaserver activity_service:service_manager find;
  51. allow mediaserver appops_service:service_manager find;
  52. allow mediaserver audio_service:service_manager find;
  53. allow mediaserver audioserver_service:service_manager find;
  54. allow mediaserver cameraserver_service:service_manager find;
  55. allow mediaserver batterystats_service:service_manager find;
  56. allow mediaserver drmserver_service:service_manager find;
  57. allow mediaserver mediaextractor_service:service_manager find;
  58. allow mediaserver mediacodec_service:service_manager find;
  59. allow mediaserver mediametrics_service:service_manager find;
  60. allow mediaserver media_session_service:service_manager find;
  61. allow mediaserver permission_service:service_manager find;
  62. allow mediaserver power_service:service_manager find;
  63. allow mediaserver processinfo_service:service_manager find;
  64. allow mediaserver scheduling_policy_service:service_manager find;
  65. allow mediaserver surfaceflinger_service:service_manager find;
  66. # for ModDrm/MediaPlayer
  67. allow mediaserver mediadrmserver_service:service_manager find;
  68. # For hybrid interfaces
  69. allow mediaserver hidl_token_hwservice:hwservice_manager find;
  70. # /oem access
  71. allow mediaserver oemfs:dir search;
  72. allow mediaserver oemfs:file r_file_perms;
  73. # /vendor apk access
  74. allow mediaserver vendor_app_file:file { read map getattr };
  75. use_drmservice(mediaserver)
  76. allow mediaserver drmserver:drmservice {
  77. consumeRights
  78. setPlaybackStatus
  79. openDecryptSession
  80. closeDecryptSession
  81. initializeDecryptUnit
  82. decrypt
  83. finalizeDecryptUnit
  84. pread
  85. };
  86. # only allow unprivileged socket ioctl commands
  87. allowxperm mediaserver self:{ rawip_socket tcp_socket udp_socket }
  88. ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
  89. # Access to /data/media.
  90. # This should be removed if sdcardfs is modified to alter the secontext for its
  91. # accesses to the underlying FS.
  92. allow mediaserver media_rw_data_file:dir create_dir_perms;
  93. allow mediaserver media_rw_data_file:file create_file_perms;
  94. # Access to media in /data/preloads
  95. allow mediaserver preloads_media_file:file { getattr read ioctl };
  96. allow mediaserver ion_device:chr_file r_file_perms;
  97. allow mediaserver hal_graphics_allocator:fd use;
  98. allow mediaserver hal_graphics_composer:fd use;
  99. allow mediaserver hal_camera:fd use;
  100. allow mediaserver system_server:fd use;
  101. # b/120491318 allow mediaserver to access void:fd
  102. allow mediaserver vold:fd use;
  103. hal_client_domain(mediaserver, hal_allocator)
  104. ###
  105. ### neverallow rules
  106. ###
  107. # mediaserver should never execute any executable without a
  108. # domain transition
  109. neverallow mediaserver { file_type fs_type }:file execute_no_trans;
  110. # do not allow privileged socket ioctl commands
  111. neverallowxperm mediaserver domain:{ rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls;