1# mediaserver - multimedia daemon
2type mediaserver, domain, domain_deprecated;
3type mediaserver_exec, exec_type, file_type;
4
5typeattribute mediaserver mlstrustedsubject;
6
7net_domain(mediaserver)
8init_daemon_domain(mediaserver)
9
10r_dir_file(mediaserver, sdcard_type)
11
12# stat /proc/self
13allow mediaserver proc:lnk_file getattr;
14
15# open /vendor/lib/mediadrm
16allow mediaserver system_file:dir r_dir_perms;
17
18userdebug_or_eng(`
19  # ptrace to processes in the same domain for memory leak detection
20  allow mediaserver self:process ptrace;
21')
22
23binder_use(mediaserver)
24binder_call(mediaserver, binderservicedomain)
25binder_call(mediaserver, { appdomain autoplay_app })
26binder_service(mediaserver)
27
28allow mediaserver media_data_file:dir create_dir_perms;
29allow mediaserver media_data_file:file create_file_perms;
30allow mediaserver app_data_file:dir search;
31allow mediaserver app_data_file:file rw_file_perms;
32allow mediaserver sdcard_type:file write;
33allow mediaserver gpu_device:chr_file rw_file_perms;
34allow mediaserver video_device:dir r_dir_perms;
35allow mediaserver video_device:chr_file rw_file_perms;
36
37set_prop(mediaserver, audio_prop)
38
39# XXX Label with a specific type?
40allow mediaserver sysfs:file r_file_perms;
41
42# Read resources from open apk files passed over Binder.
43allow mediaserver apk_data_file:file { read getattr };
44allow mediaserver asec_apk_file:file { read getattr };
45allow mediaserver ringtone_file:file { read getattr };
46
47# Read /data/data/com.android.providers.telephony files passed over Binder.
48allow mediaserver radio_data_file:file { read getattr };
49
50# Use pipes passed over Binder from app domains.
51allow mediaserver { appdomain autoplay_app }:fifo_file { getattr read write };
52
53allow mediaserver rpmsg_device:chr_file rw_file_perms;
54
55# Inter System processes communicate over named pipe (FIFO)
56allow mediaserver system_server:fifo_file r_file_perms;
57
58r_dir_file(mediaserver, media_rw_data_file)
59
60# Grant access to read files on appfuse.
61allow mediaserver app_fuse_file:file { read getattr };
62
63# Read/[write] to /proc/net/xt_qtaguid/ctrl and /dev/xt_qtaguid
64allow mediaserver qtaguid_proc:file rw_file_perms;
65allow mediaserver qtaguid_device:chr_file r_file_perms;
66
67# Allow abstract socket connection
68allow 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.
72unix_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.
76unix_socket_connect(mediaserver, bluetooth, bluetooth)
77
78# Connect to tee service.
79allow mediaserver tee:unix_stream_socket connectto;
80
81allow mediaserver activity_service:service_manager find;
82allow mediaserver appops_service:service_manager find;
83allow mediaserver audioserver_service:service_manager find;
84allow mediaserver cameraserver_service:service_manager find;
85allow mediaserver batterystats_service:service_manager find;
86allow mediaserver drmserver_service:service_manager find;
87allow mediaserver mediaextractor_service:service_manager find;
88allow mediaserver mediacodec_service:service_manager find;
89allow mediaserver mediaserver_service:service_manager { add find };
90allow mediaserver media_session_service:service_manager find;
91allow mediaserver permission_service:service_manager find;
92allow mediaserver power_service:service_manager find;
93allow mediaserver processinfo_service:service_manager find;
94allow mediaserver scheduling_policy_service:service_manager find;
95allow mediaserver surfaceflinger_service:service_manager find;
96
97# /oem access
98allow mediaserver oemfs:dir search;
99allow mediaserver oemfs:file r_file_perms;
100
101use_drmservice(mediaserver)
102allow 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
114allowxperm 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.
120allow mediaserver media_rw_data_file:dir create_dir_perms;
121allow mediaserver media_rw_data_file:file create_file_perms;
122
123# Access to /data/preloads
124allow 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
132neverallow mediaserver { file_type fs_type }:file execute_no_trans;
133
134# do not allow privileged socket ioctl commands
135neverallowxperm mediaserver domain:{ rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls;
136