2013-11-13 00:34:52 +01:00
|
|
|
# android user-space log manager
|
2016-09-24 23:26:45 +02:00
|
|
|
type logd, domain, mlstrustedsubject;
|
2018-09-27 19:21:37 +02:00
|
|
|
type logd_exec, system_file_type, exec_type, file_type;
|
2013-11-13 00:34:52 +01:00
|
|
|
|
2016-01-28 04:23:10 +01:00
|
|
|
# Read access to pseudo filesystems.
|
2016-09-10 01:27:17 +02:00
|
|
|
r_dir_file(logd, cgroup)
|
2017-09-13 23:34:56 +02:00
|
|
|
r_dir_file(logd, proc_kmsg)
|
2016-09-10 01:27:17 +02:00
|
|
|
r_dir_file(logd, proc_meminfo)
|
2016-01-28 04:23:10 +01:00
|
|
|
|
2017-11-09 23:51:26 +01:00
|
|
|
allow logd self:global_capability_class_set { setuid setgid setpcap sys_nice audit_control };
|
|
|
|
allow logd self:global_capability2_class_set syslog;
|
2016-05-17 06:12:17 +02:00
|
|
|
allow logd self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_write };
|
2014-04-01 20:02:57 +02:00
|
|
|
allow logd kernel:system syslog_read;
|
2019-03-20 23:36:26 +01:00
|
|
|
allow logd kmsg_device:chr_file { getattr w_file_perms };
|
2016-09-10 01:27:17 +02:00
|
|
|
allow logd system_data_file:{ file lnk_file } r_file_perms;
|
Relabel /data/system/packages.list to new type.
Conservatively grant access to packages_list_file to everything that had
access to system_data_file:file even if the comment in the SELinux
policy suggests it was for another use.
Ran a diff on the resulting SEPolicy, the only difference of domains
being granted is those that had system_data_file:dir permissiosn which
is clearly not applicable for packages.list
diff -u0 <(sesearch --allow -t system_data_file ~/sepolicy | sed 's/system_data_file/packages_list_file/') <(sesearch --allow -t packages_list_file ~/sepolicy_new)
--- /proc/self/fd/16 2019-03-19 20:01:44.378409146 +0000
+++ /proc/self/fd/18 2019-03-19 20:01:44.378409146 +0000
@@ -3 +2,0 @@
-allow appdomain packages_list_file:dir getattr;
@@ -6 +4,0 @@
-allow coredomain packages_list_file:dir getattr;
@@ -8 +5,0 @@
-allow domain packages_list_file:dir search;
@@ -35 +31,0 @@
-allow system_server packages_list_file:dir { rename search setattr read lock create reparent getattr write relabelfrom ioctl rmdir remove_name open add_name };
@@ -40 +35,0 @@
-allow tee packages_list_file:dir { search read lock getattr ioctl open };
@@ -43,3 +37,0 @@
-allow traced_probes packages_list_file:dir { read getattr open search };
-allow vendor_init packages_list_file:dir { search setattr read create getattr write relabelfrom ioctl rmdir remove_name open add_name };
-allow vold packages_list_file:dir { search setattr read lock create getattr mounton write ioctl rmdir remove_name open add_name };
@@ -48 +39,0 @@
-allow vold_prepare_subdirs packages_list_file:dir { read write relabelfrom rmdir remove_name open add_name };
@@ -50 +40,0 @@
-allow zygote packages_list_file:dir { search read lock getattr ioctl open };
Bug: 123186697
Change-Id: Ieabf313653deb5314872b63cd47dadd535af7b07
2019-03-19 19:14:38 +01:00
|
|
|
allow logd packages_list_file:file r_file_perms;
|
2016-09-13 18:33:35 +02:00
|
|
|
allow logd pstorefs:dir search;
|
|
|
|
allow logd pstorefs:file r_file_perms;
|
|
|
|
userdebug_or_eng(`
|
|
|
|
# Access to /data/misc/logd/event-log-tags
|
|
|
|
allow logd misc_logd_file:dir r_dir_perms;
|
|
|
|
allow logd misc_logd_file:file rw_file_perms;
|
|
|
|
')
|
|
|
|
allow logd runtime_event_log_tags_file:file rw_file_perms;
|
2013-11-13 00:34:52 +01:00
|
|
|
|
2016-01-04 16:20:45 +01:00
|
|
|
# Access device logging gating property
|
|
|
|
get_prop(logd, device_logging_prop)
|
|
|
|
|
2013-11-13 00:34:52 +01:00
|
|
|
r_dir_file(logd, domain)
|
|
|
|
|
2014-10-16 00:49:37 +02:00
|
|
|
allow logd kernel:system syslog_mod;
|
|
|
|
|
2015-03-10 21:46:37 +01:00
|
|
|
control_logd(logd)
|
2016-11-08 00:11:39 +01:00
|
|
|
read_runtime_log_tags(logd)
|
|
|
|
|
|
|
|
allow runtime_event_log_tags_file tmpfs:filesystem associate;
|
|
|
|
# Typically harmlessly blindly trying to access via liblog
|
|
|
|
# event tag mapping while in the untrusted_app domain.
|
|
|
|
# Access for that domain is controlled and gated via the
|
|
|
|
# event log tag service (albeit at a performance penalty,
|
|
|
|
# expected to be locally cached).
|
2019-01-14 21:59:54 +01:00
|
|
|
dontaudit domain runtime_event_log_tags_file:file { map open read };
|
2015-03-10 21:46:37 +01:00
|
|
|
|
2013-11-13 00:34:52 +01:00
|
|
|
###
|
|
|
|
### Neverallow rules
|
|
|
|
###
|
|
|
|
### logd should NEVER do any of this
|
|
|
|
|
|
|
|
# Block device access.
|
|
|
|
neverallow logd dev_type:blk_file { read write };
|
|
|
|
|
|
|
|
# ptrace any other app
|
|
|
|
neverallow logd domain:process ptrace;
|
|
|
|
|
2016-12-05 23:01:28 +01:00
|
|
|
# ... and nobody may ptrace me (except on userdebug or eng builds)
|
2018-08-08 01:03:47 +02:00
|
|
|
neverallow { domain userdebug_or_eng(`-crash_dump -llkd') } logd:process ptrace;
|
2016-12-05 23:01:28 +01:00
|
|
|
|
2013-11-13 00:34:52 +01:00
|
|
|
# Write to /system.
|
|
|
|
neverallow logd system_file:dir_file_class_set write;
|
|
|
|
|
|
|
|
# Write to files in /data/data or system files on /data
|
Relabel /data/system/packages.list to new type.
Conservatively grant access to packages_list_file to everything that had
access to system_data_file:file even if the comment in the SELinux
policy suggests it was for another use.
Ran a diff on the resulting SEPolicy, the only difference of domains
being granted is those that had system_data_file:dir permissiosn which
is clearly not applicable for packages.list
diff -u0 <(sesearch --allow -t system_data_file ~/sepolicy | sed 's/system_data_file/packages_list_file/') <(sesearch --allow -t packages_list_file ~/sepolicy_new)
--- /proc/self/fd/16 2019-03-19 20:01:44.378409146 +0000
+++ /proc/self/fd/18 2019-03-19 20:01:44.378409146 +0000
@@ -3 +2,0 @@
-allow appdomain packages_list_file:dir getattr;
@@ -6 +4,0 @@
-allow coredomain packages_list_file:dir getattr;
@@ -8 +5,0 @@
-allow domain packages_list_file:dir search;
@@ -35 +31,0 @@
-allow system_server packages_list_file:dir { rename search setattr read lock create reparent getattr write relabelfrom ioctl rmdir remove_name open add_name };
@@ -40 +35,0 @@
-allow tee packages_list_file:dir { search read lock getattr ioctl open };
@@ -43,3 +37,0 @@
-allow traced_probes packages_list_file:dir { read getattr open search };
-allow vendor_init packages_list_file:dir { search setattr read create getattr write relabelfrom ioctl rmdir remove_name open add_name };
-allow vold packages_list_file:dir { search setattr read lock create getattr mounton write ioctl rmdir remove_name open add_name };
@@ -48 +39,0 @@
-allow vold_prepare_subdirs packages_list_file:dir { read write relabelfrom rmdir remove_name open add_name };
@@ -50 +40,0 @@
-allow zygote packages_list_file:dir { search read lock getattr ioctl open };
Bug: 123186697
Change-Id: Ieabf313653deb5314872b63cd47dadd535af7b07
2019-03-19 19:14:38 +01:00
|
|
|
neverallow logd { app_data_file privapp_data_file system_data_file packages_list_file }:dir_file_class_set write;
|
2016-12-06 17:57:23 +01:00
|
|
|
|
|
|
|
# Only init is allowed to enter the logd domain via exec()
|
|
|
|
neverallow { domain -init } logd:process transition;
|
|
|
|
neverallow * logd:process dyntransition;
|
2016-11-08 00:11:39 +01:00
|
|
|
|
|
|
|
# protect the event-log-tags file
|
2016-09-13 18:33:35 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-init
|
|
|
|
-logd
|
|
|
|
} runtime_event_log_tags_file:file no_w_file_perms;
|