Home | History | Annotate | Download | only in sepolicy
      1 # mediaserver - multimedia daemon
      2 type mediaserver, domain, domain_deprecated;
      3 type mediaserver_exec, exec_type, file_type;
      4 
      5 typeattribute mediaserver mlstrustedsubject;
      6 
      7 net_domain(mediaserver)
      8 init_daemon_domain(mediaserver)
      9 
     10 r_dir_file(mediaserver, sdcard_type)
     11 
     12 # stat /proc/self
     13 allow mediaserver proc:lnk_file getattr;
     14 
     15 # open /vendor/lib/mediadrm
     16 allow mediaserver system_file:dir r_dir_perms;
     17 
     18 userdebug_or_eng(`
     19   # ptrace to processes in the same domain for memory leak detection
     20   allow mediaserver self:process ptrace;
     21 ')
     22 
     23 binder_use(mediaserver)
     24 binder_call(mediaserver, binderservicedomain)
     25 binder_call(mediaserver, { appdomain autoplay_app })
     26 binder_service(mediaserver)
     27 
     28 allow mediaserver media_data_file:dir create_dir_perms;
     29 allow mediaserver media_data_file:file create_file_perms;
     30 allow mediaserver app_data_file:dir search;
     31 allow mediaserver app_data_file:file rw_file_perms;
     32 allow mediaserver sdcard_type:file write;
     33 allow mediaserver gpu_device:chr_file rw_file_perms;
     34 allow mediaserver video_device:dir r_dir_perms;
     35 allow mediaserver video_device:chr_file rw_file_perms;
     36 
     37 set_prop(mediaserver, audio_prop)
     38 
     39 # XXX Label with a specific type?
     40 allow mediaserver sysfs:file r_file_perms;
     41 
     42 # Read resources from open apk files passed over Binder.
     43 allow mediaserver apk_data_file:file { read getattr };
     44 allow mediaserver asec_apk_file:file { read getattr };
     45 allow mediaserver ringtone_file:file { read getattr };
     46 
     47 # Read /data/data/com.android.providers.telephony files passed over Binder.
     48 allow mediaserver radio_data_file:file { read getattr };
     49 
     50 # Use pipes passed over Binder from app domains.
     51 allow mediaserver { appdomain autoplay_app }:fifo_file { getattr read write };
     52 
     53 allow mediaserver rpmsg_device:chr_file rw_file_perms;
     54 
     55 # Inter System processes communicate over named pipe (FIFO)
     56 allow mediaserver system_server:fifo_file r_file_perms;
     57 
     58 r_dir_file(mediaserver, media_rw_data_file)
     59 
     60 # Grant access to read files on appfuse.
     61 allow mediaserver app_fuse_file:file { read getattr };
     62 
     63 # Read/[write] to /proc/net/xt_qtaguid/ctrl and /dev/xt_qtaguid
     64 allow mediaserver qtaguid_proc:file rw_file_perms;
     65 allow mediaserver qtaguid_device:chr_file r_file_perms;
     66 
     67 # Allow abstract socket connection
     68 allow mediaserver rild:unix_stream_socket { connectto read write setopt };
     69 
     70 # Needed on some devices for playing DRM protected content,
     71 # but seems expected and appropriate for all devices.
     72 unix_socket_connect(mediaserver, drmserver, drmserver)
     73 
     74 # Needed on some devices for playing audio on paired BT device,
     75 # but seems appropriate for all devices.
     76 unix_socket_connect(mediaserver, bluetooth, bluetooth)
     77 
     78 # Connect to tee service.
     79 allow mediaserver tee:unix_stream_socket connectto;
     80 
     81 allow mediaserver activity_service:service_manager find;
     82 allow mediaserver appops_service:service_manager find;
     83 allow mediaserver audioserver_service:service_manager find;
     84 allow mediaserver cameraserver_service:service_manager find;
     85 allow mediaserver batterystats_service:service_manager find;
     86 allow mediaserver drmserver_service:service_manager find;
     87 allow mediaserver mediaextractor_service:service_manager find;
     88 allow mediaserver mediacodec_service:service_manager find;
     89 allow mediaserver mediaserver_service:service_manager { add find };
     90 allow mediaserver media_session_service:service_manager find;
     91 allow mediaserver permission_service:service_manager find;
     92 allow mediaserver power_service:service_manager find;
     93 allow mediaserver processinfo_service:service_manager find;
     94 allow mediaserver scheduling_policy_service:service_manager find;
     95 allow mediaserver surfaceflinger_service:service_manager find;
     96 
     97 # /oem access
     98 allow mediaserver oemfs:dir search;
     99 allow mediaserver oemfs:file r_file_perms;
    100 
    101 use_drmservice(mediaserver)
    102 allow mediaserver drmserver:drmservice {
    103     consumeRights
    104     setPlaybackStatus
    105     openDecryptSession
    106     closeDecryptSession
    107     initializeDecryptUnit
    108     decrypt
    109     finalizeDecryptUnit
    110     pread
    111 };
    112 
    113 # only allow unprivileged socket ioctl commands
    114 allowxperm mediaserver self:{ rawip_socket tcp_socket udp_socket }
    115   ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
    116 
    117 # Access to /data/media.
    118 # This should be removed if sdcardfs is modified to alter the secontext for its
    119 # accesses to the underlying FS.
    120 allow mediaserver media_rw_data_file:dir create_dir_perms;
    121 allow mediaserver media_rw_data_file:file create_file_perms;
    122 
    123 # Access to /data/preloads
    124 allow mediaserver preloads_data_file:file { getattr read ioctl };
    125 
    126 ###
    127 ### neverallow rules
    128 ###
    129 
    130 # mediaserver should never execute any executable without a
    131 # domain transition
    132 neverallow mediaserver { file_type fs_type }:file execute_no_trans;
    133 
    134 # do not allow privileged socket ioctl commands
    135 neverallowxperm mediaserver domain:{ rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls;
    136