Merge "Statsd selinux allow shell to interact with statsd"
diff --git a/private/seapp_contexts b/private/seapp_contexts
index 0333d99..8db46f0 100644
--- a/private/seapp_contexts
+++ b/private/seapp_contexts
@@ -91,6 +91,10 @@
 # uid's can be in shell domain
 neverallow user=shell domain=((?!shell).)*
 
+# only the package named com.android.shell can run in the shell domain
+neverallow domain=shell name=((?!com\.android\.shell).)*
+neverallow user=shell name=((?!com\.android\.shell).)*
+
 # Ephemeral Apps must run in the ephemeral_app domain
 neverallow isEphemeralApp=true domain=((?!ephemeral_app).)*
 
@@ -102,7 +106,7 @@
 user=secure_element seinfo=platform domain=secure_element levelFrom=all
 user=radio seinfo=platform domain=radio type=radio_data_file
 user=shared_relro domain=shared_relro
-user=shell seinfo=platform domain=shell type=shell_data_file
+user=shell seinfo=platform domain=shell name=com.android.shell type=shell_data_file
 user=_isolated domain=isolated_app levelFrom=user
 user=webview_zygote seinfo=webview_zygote domain=webview_zygote
 user=_app seinfo=media domain=mediaprovider name=android.process.media type=app_data_file levelFrom=user
diff --git a/private/traced_probes.te b/private/traced_probes.te
index 3bf1471..03ace75 100644
--- a/private/traced_probes.te
+++ b/private/traced_probes.te
@@ -29,6 +29,9 @@
 # Allow procfs access
 r_dir_file(traced_probes, domain)
 
+# Allow to log to kernel dmesg when starting / stopping ftrace.
+allow traced_probes kmsg_device:chr_file write;
+
 ###
 ### Neverallow rules
 ###
@@ -45,7 +48,7 @@
 neverallow traced_probes domain:process ptrace;
 
 # Disallows access to /data files.
-neverallow traced {
+neverallow traced_probes {
   data_file_type
   -system_data_file
   # TODO(b/72998741) Remove vendor_data_file exemption. Further restricted in a
@@ -53,10 +56,10 @@
   -vendor_data_file
   -zoneinfo_data_file
 }:dir *;
-neverallow traced system_data_file:dir ~{ getattr search };
-neverallow traced zoneinfo_data_file:dir ~r_dir_perms;
-neverallow traced { data_file_type -zoneinfo_data_file }:lnk_file *;
-neverallow traced { data_file_type -zoneinfo_data_file }:file *;
+neverallow traced_probes system_data_file:dir ~{ getattr search };
+neverallow traced_probes zoneinfo_data_file:dir ~r_dir_perms;
+neverallow traced_probes { data_file_type -zoneinfo_data_file }:lnk_file *;
+neverallow traced_probes { data_file_type -zoneinfo_data_file }:file *;
 
 # Only init is allowed to enter the traced_probes domain via exec()
 neverallow { domain -init } traced_probes:process transition;