• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)
31userdebug_or_eng(`get_prop(logd, logpersistd_logging_prop)')
32
33r_dir_file(logd, domain)
34
35allow logd kernel:system syslog_mod;
36
37control_logd(logd)
38
39# case where logpersistd is actually logcat -f in logd context (nee: logcatd)
40userdebug_or_eng(`
41  unix_socket_connect(logd, logdr, logd)
42')
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# Write to /system.
56neverallow logd system_file:dir_file_class_set write;
57
58# Write to files in /data/data or system files on /data
59neverallow logd { app_data_file system_data_file }:dir_file_class_set write;
60
61# logd is not allowed to write anywhere other than /data/misc/logd, and then
62# only on userdebug or eng builds
63neverallow logd { file_type -logd_tmpfs userdebug_or_eng(` -misc_logd_file -coredump_file ') }:file { create write append };
64
65# logpersist is only allowed on userdebug/eng builds
66neverallow { domain userdebug_or_eng(`-logd -shell -dumpstate') } misc_logd_file:file no_rw_file_perms;
67neverallow { domain userdebug_or_eng(`-logd') } misc_logd_file:dir { add_name link relabelfrom remove_name rename reparent rmdir write };
68neverallow { domain -init } misc_logd_file:dir create;
69