1*e4a36f41SAndroid Build Coastguard Workertypeattribute logd coredomain; 2*e4a36f41SAndroid Build Coastguard Worker 3*e4a36f41SAndroid Build Coastguard Workerinit_daemon_domain(logd) 4*e4a36f41SAndroid Build Coastguard Worker 5*e4a36f41SAndroid Build Coastguard Worker# Access device logging gating property 6*e4a36f41SAndroid Build Coastguard Workerget_prop(logd, device_logging_prop) 7*e4a36f41SAndroid Build Coastguard Worker 8*e4a36f41SAndroid Build Coastguard Worker# logd is not allowed to write anywhere other than /data/misc/logd, and then 9*e4a36f41SAndroid Build Coastguard Worker# only on userdebug or eng builds 10*e4a36f41SAndroid Build Coastguard Workerneverallow logd { 11*e4a36f41SAndroid Build Coastguard Worker file_type 12*e4a36f41SAndroid Build Coastguard Worker -runtime_event_log_tags_file 13*e4a36f41SAndroid Build Coastguard Worker # shell_data_file access is needed to dump bugreports 14*e4a36f41SAndroid Build Coastguard Worker -shell_data_file 15*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-coredump_file -misc_logd_file') 16*e4a36f41SAndroid Build Coastguard Worker with_native_coverage(`-method_trace_data_file') 17*e4a36f41SAndroid Build Coastguard Worker}:file { create write append }; 18*e4a36f41SAndroid Build Coastguard Worker 19*e4a36f41SAndroid Build Coastguard Worker# protect the event-log-tags file 20*e4a36f41SAndroid Build Coastguard Workerneverallow { 21*e4a36f41SAndroid Build Coastguard Worker domain 22*e4a36f41SAndroid Build Coastguard Worker -appdomain # covered below 23*e4a36f41SAndroid Build Coastguard Worker -bootstat 24*e4a36f41SAndroid Build Coastguard Worker -dumpstate 25*e4a36f41SAndroid Build Coastguard Worker -init 26*e4a36f41SAndroid Build Coastguard Worker -logd 27*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-logpersist') 28*e4a36f41SAndroid Build Coastguard Worker -servicemanager 29*e4a36f41SAndroid Build Coastguard Worker -system_server 30*e4a36f41SAndroid Build Coastguard Worker -surfaceflinger 31*e4a36f41SAndroid Build Coastguard Worker -zygote 32*e4a36f41SAndroid Build Coastguard Worker} runtime_event_log_tags_file:file no_rw_file_perms; 33*e4a36f41SAndroid Build Coastguard Worker 34*e4a36f41SAndroid Build Coastguard Workerneverallow { 35*e4a36f41SAndroid Build Coastguard Worker appdomain 36*e4a36f41SAndroid Build Coastguard Worker -bluetooth 37*e4a36f41SAndroid Build Coastguard Worker -platform_app 38*e4a36f41SAndroid Build Coastguard Worker -priv_app 39*e4a36f41SAndroid Build Coastguard Worker -radio 40*e4a36f41SAndroid Build Coastguard Worker -shell 41*e4a36f41SAndroid Build Coastguard Worker userdebug_or_eng(`-su') 42*e4a36f41SAndroid Build Coastguard Worker -system_app 43*e4a36f41SAndroid Build Coastguard Worker} runtime_event_log_tags_file:file no_rw_file_perms; 44*e4a36f41SAndroid Build Coastguard Worker 45*e4a36f41SAndroid Build Coastguard Worker# Only binder communication between logd and system_server is allowed 46*e4a36f41SAndroid Build Coastguard Workerbinder_use(logd) 47*e4a36f41SAndroid Build Coastguard Workerbinder_service(logd) 48*e4a36f41SAndroid Build Coastguard Workerbinder_call(logd, system_server) 49*e4a36f41SAndroid Build Coastguard Worker 50*e4a36f41SAndroid Build Coastguard Workeradd_service(logd, logd_service) 51*e4a36f41SAndroid Build Coastguard Workerallow logd logcat_service:service_manager find; 52*e4a36f41SAndroid Build Coastguard Worker 53*e4a36f41SAndroid Build Coastguard Worker# Read access to pseudo filesystems. 54*e4a36f41SAndroid Build Coastguard Workerr_dir_file(logd, cgroup) 55*e4a36f41SAndroid Build Coastguard Workerr_dir_file(logd, cgroup_v2) 56*e4a36f41SAndroid Build Coastguard Workerr_dir_file(logd, proc_kmsg) 57*e4a36f41SAndroid Build Coastguard Workerr_dir_file(logd, proc_meminfo) 58*e4a36f41SAndroid Build Coastguard Worker 59*e4a36f41SAndroid Build Coastguard Workerallow logd self:global_capability_class_set { setuid setgid setpcap sys_nice audit_control }; 60*e4a36f41SAndroid Build Coastguard Workerallow logd self:global_capability2_class_set syslog; 61*e4a36f41SAndroid Build Coastguard Workerallow logd self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_write }; 62*e4a36f41SAndroid Build Coastguard Workerallow logd kernel:system syslog_read; 63*e4a36f41SAndroid Build Coastguard Workerallow logd kmsg_device:chr_file { getattr w_file_perms }; 64*e4a36f41SAndroid Build Coastguard Workerallow logd system_data_file:{ file lnk_file } r_file_perms; 65*e4a36f41SAndroid Build Coastguard Workerallow logd packages_list_file:file r_file_perms; 66*e4a36f41SAndroid Build Coastguard Workerallow logd pstorefs:dir search; 67*e4a36f41SAndroid Build Coastguard Workerallow logd pstorefs:file r_file_perms; 68*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 69*e4a36f41SAndroid Build Coastguard Worker # Access to /data/misc/logd/event-log-tags 70*e4a36f41SAndroid Build Coastguard Worker allow logd misc_logd_file:dir r_dir_perms; 71*e4a36f41SAndroid Build Coastguard Worker allow logd misc_logd_file:file rw_file_perms; 72*e4a36f41SAndroid Build Coastguard Worker') 73*e4a36f41SAndroid Build Coastguard Workerallow logd runtime_event_log_tags_file:file rw_file_perms; 74*e4a36f41SAndroid Build Coastguard Worker 75*e4a36f41SAndroid Build Coastguard Workerr_dir_file(logd, domain) 76*e4a36f41SAndroid Build Coastguard Worker 77*e4a36f41SAndroid Build Coastguard Workerallow logd kernel:system syslog_mod; 78*e4a36f41SAndroid Build Coastguard Worker 79*e4a36f41SAndroid Build Coastguard Workercontrol_logd(logd) 80*e4a36f41SAndroid Build Coastguard Workerread_runtime_log_tags(logd) 81*e4a36f41SAndroid Build Coastguard Worker 82*e4a36f41SAndroid Build Coastguard Workerallow runtime_event_log_tags_file tmpfs:filesystem associate; 83*e4a36f41SAndroid Build Coastguard Worker# Typically harmlessly blindly trying to access via liblog 84*e4a36f41SAndroid Build Coastguard Worker# event tag mapping while in the untrusted_app domain. 85*e4a36f41SAndroid Build Coastguard Worker# Access for that domain is controlled and gated via the 86*e4a36f41SAndroid Build Coastguard Worker# event log tag service (albeit at a performance penalty, 87*e4a36f41SAndroid Build Coastguard Worker# expected to be locally cached). 88*e4a36f41SAndroid Build Coastguard Workerdontaudit domain runtime_event_log_tags_file:file { map open read }; 89*e4a36f41SAndroid Build Coastguard Worker 90*e4a36f41SAndroid Build Coastguard Worker# Logd sets defaults if certain properties are empty. 91*e4a36f41SAndroid Build Coastguard Workerset_prop(logd, logd_prop) 92*e4a36f41SAndroid Build Coastguard Worker 93*e4a36f41SAndroid Build Coastguard Worker### 94*e4a36f41SAndroid Build Coastguard Worker### Neverallow rules 95*e4a36f41SAndroid Build Coastguard Worker### 96*e4a36f41SAndroid Build Coastguard Worker### logd should NEVER do any of this 97*e4a36f41SAndroid Build Coastguard Worker 98*e4a36f41SAndroid Build Coastguard Worker# Block device access. 99*e4a36f41SAndroid Build Coastguard Workerneverallow logd dev_type:blk_file { read write }; 100*e4a36f41SAndroid Build Coastguard Worker 101*e4a36f41SAndroid Build Coastguard Worker# ptrace any other app 102*e4a36f41SAndroid Build Coastguard Workerneverallow logd domain:process ptrace; 103*e4a36f41SAndroid Build Coastguard Worker 104*e4a36f41SAndroid Build Coastguard Worker# ... and nobody may ptrace me (except on userdebug or eng builds) 105*e4a36f41SAndroid Build Coastguard Workerneverallow { domain userdebug_or_eng(`-crash_dump -llkd') } logd:process ptrace; 106*e4a36f41SAndroid Build Coastguard Worker 107*e4a36f41SAndroid Build Coastguard Worker# Write to /system. 108*e4a36f41SAndroid Build Coastguard Workerneverallow logd system_file_type:dir_file_class_set write; 109*e4a36f41SAndroid Build Coastguard Worker 110*e4a36f41SAndroid Build Coastguard Worker# Write to files in /data/data or system files on /data 111*e4a36f41SAndroid Build Coastguard Workerneverallow logd { 112*e4a36f41SAndroid Build Coastguard Worker app_data_file_type 113*e4a36f41SAndroid Build Coastguard Worker system_data_file 114*e4a36f41SAndroid Build Coastguard Worker packages_list_file 115*e4a36f41SAndroid Build Coastguard Worker -shell_data_file # for bugreports 116*e4a36f41SAndroid Build Coastguard Worker}:dir_file_class_set write; 117*e4a36f41SAndroid Build Coastguard Worker 118*e4a36f41SAndroid Build Coastguard Worker# Only init is allowed to enter the logd domain via exec() 119*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } logd:process transition; 120*e4a36f41SAndroid Build Coastguard Workerneverallow * logd:process dyntransition; 121*e4a36f41SAndroid Build Coastguard Worker 122*e4a36f41SAndroid Build Coastguard Worker# protect the event-log-tags file 123*e4a36f41SAndroid Build Coastguard Workerneverallow { 124*e4a36f41SAndroid Build Coastguard Worker domain 125*e4a36f41SAndroid Build Coastguard Worker -init 126*e4a36f41SAndroid Build Coastguard Worker -logd 127*e4a36f41SAndroid Build Coastguard Worker} runtime_event_log_tags_file:file no_w_file_perms; 128