1# android user-space log manager 2type logd, domain, domain_deprecated, mlstrustedsubject; 3type logd_exec, exec_type, file_type; 4 5init_daemon_domain(logd) 6 7# Read access to pseudo filesystems. 8r_dir_file(logd, proc) 9r_dir_file(logd, proc_net) 10 11allow logd self:capability { setuid setgid sys_nice audit_control }; 12allow logd self:capability2 syslog; 13allow logd self:netlink_audit_socket { create_socket_perms nlmsg_write }; 14allow logd kernel:system syslog_read; 15allow logd kmsg_device:chr_file w_file_perms; 16allow logd system_data_file:file r_file_perms; 17# logpersist is only allowed on userdebug and eng builds 18userdebug_or_eng(` 19 allow logd misc_logd_file:file create_file_perms; 20 allow logd misc_logd_file:dir rw_dir_perms; 21') 22allow logd pstorefs:dir search; 23allow logd pstorefs:file r_file_perms; 24 25# Set persist.sys. and sys.powerctl 26set_prop(logd, safemode_prop) 27set_prop(logd, powerctl_prop) 28 29# Access device logging gating property 30get_prop(logd, device_logging_prop) 31 32r_dir_file(logd, domain) 33 34allow logd kernel:system syslog_mod; 35 36control_logd(logd) 37 38# case where logpersistd is actually logcat -f in logd context (nee: logcatd) 39userdebug_or_eng(` 40 unix_socket_connect(logd, logdr, logd) 41') 42 43### 44### Neverallow rules 45### 46### logd should NEVER do any of this 47 48# Block device access. 49neverallow logd dev_type:blk_file { read write }; 50 51# ptrace any other app 52neverallow logd domain:process ptrace; 53 54# Write to /system. 55neverallow logd system_file:dir_file_class_set write; 56 57# Write to files in /data/data or system files on /data 58neverallow logd { app_data_file system_data_file }:dir_file_class_set write; 59 60# logd is not allowed to write anywhere other than /data/misc/logd, and then 61# only on userdebug or eng builds 62neverallow logd { file_type -logd_tmpfs userdebug_or_eng(` -misc_logd_file -coredump_file ') }:file { create write append }; 63 64# logpersist is only allowed on userdebug/eng builds 65neverallow { domain userdebug_or_eng(`-logd -shell -dumpstate') } misc_logd_file:file no_rw_file_perms; 66neverallow { domain userdebug_or_eng(`-logd') } misc_logd_file:dir { add_name link relabelfrom remove_name rename reparent rmdir write }; 67neverallow { domain -init } misc_logd_file:dir create; 68