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