1# android user-space log manager 2type logd, domain, mlstrustedsubject; 3type logd_exec, system_file_type, exec_type, file_type; 4 5# Read access to pseudo filesystems. 6r_dir_file(logd, cgroup) 7r_dir_file(logd, proc_kmsg) 8r_dir_file(logd, proc_meminfo) 9 10allow logd self:global_capability_class_set { setuid setgid setpcap sys_nice audit_control }; 11allow logd self:global_capability2_class_set syslog; 12allow logd self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_write }; 13allow logd kernel:system syslog_read; 14allow logd kmsg_device:chr_file { getattr w_file_perms }; 15allow logd system_data_file:{ file lnk_file } r_file_perms; 16allow logd packages_list_file:file r_file_perms; 17allow logd pstorefs:dir search; 18allow logd pstorefs:file r_file_perms; 19userdebug_or_eng(` 20 # Access to /data/misc/logd/event-log-tags 21 allow logd misc_logd_file:dir r_dir_perms; 22 allow logd misc_logd_file:file rw_file_perms; 23') 24allow logd runtime_event_log_tags_file:file rw_file_perms; 25 26r_dir_file(logd, domain) 27 28allow logd kernel:system syslog_mod; 29 30control_logd(logd) 31read_runtime_log_tags(logd) 32 33allow runtime_event_log_tags_file tmpfs:filesystem associate; 34# Typically harmlessly blindly trying to access via liblog 35# event tag mapping while in the untrusted_app domain. 36# Access for that domain is controlled and gated via the 37# event log tag service (albeit at a performance penalty, 38# expected to be locally cached). 39dontaudit domain runtime_event_log_tags_file:file { map open read }; 40 41# Logd sets defaults if certain properties are empty. 42set_prop(logd, logd_prop) 43 44### 45### Neverallow rules 46### 47### logd should NEVER do any of this 48 49# Block device access. 50neverallow logd dev_type:blk_file { read write }; 51 52# ptrace any other app 53neverallow logd domain:process ptrace; 54 55# ... and nobody may ptrace me (except on userdebug or eng builds) 56neverallow { domain userdebug_or_eng(`-crash_dump -llkd') } logd:process ptrace; 57 58# Write to /system. 59neverallow logd system_file:dir_file_class_set write; 60 61# Write to files in /data/data or system files on /data 62neverallow logd { app_data_file privapp_data_file system_data_file packages_list_file }:dir_file_class_set write; 63 64# Only init is allowed to enter the logd domain via exec() 65neverallow { domain -init } logd:process transition; 66neverallow * logd:process dyntransition; 67 68# protect the event-log-tags file 69neverallow { 70 domain 71 -init 72 -logd 73} runtime_event_log_tags_file:file no_w_file_perms; 74