Merge changes I5a3584b6,Ic7252a8e,I2d4ace75
* changes:
Various minor policy fixes based on CTS.
Split internal and external sdcards
Give sdcard sys_admin capability.
diff --git a/adbd.te b/adbd.te
index f924149..074f35b 100644
--- a/adbd.te
+++ b/adbd.te
@@ -15,6 +15,9 @@
allow adbd labeledfs:filesystem remount;
allow adbd shell_data_file:dir rw_dir_perms;
allow adbd shell_data_file:file create_file_perms;
+allow adbd sdcard_type:dir create_dir_perms;
+allow adbd sdcard_type:file create_file_perms;
+
allow adbd graphics_device:dir search;
allow adbd graphics_device:chr_file r_file_perms;
allow adbd log_device:chr_file r_file_perms;
diff --git a/app.te b/app.te
index de7b7d0..6a4c0b7 100644
--- a/app.te
+++ b/app.te
@@ -89,8 +89,8 @@
allow platformappdomain platform_app_data_file:dir create_dir_perms;
allow platformappdomain platform_app_data_file:notdevfile_class_set create_file_perms;
# App sdcard file accesses
-allow platformappdomain sdcard:dir create_dir_perms;
-allow platformappdomain sdcard:file create_file_perms;
+allow platformappdomain sdcard_type:dir create_dir_perms;
+allow platformappdomain sdcard_type:file create_file_perms;
# System data file accesses (e.g, shared objects from the lib directory)
allow platformappdomain system_data_file:file { execute open };
@@ -118,12 +118,19 @@
if (app_bluetooth or android_cts) {
# No specific SELinux class for bluetooth sockets presently.
allow untrusted_app self:socket *;
+allow untrusted_app bluetooth:unix_stream_socket { read write shutdown };
}
-# SDCard rw access.
-bool app_sdcard_rw true;
-if (app_sdcard_rw) {
-allow untrusted_app sdcard:dir create_dir_perms;
-allow untrusted_app sdcard:file create_file_perms;
+# Internal SDCard rw access.
+bool app_internal_sdcard_rw true;
+if (app_internal_sdcard_rw) {
+allow untrusted_app sdcard_internal:dir create_dir_perms;
+allow untrusted_app sdcard_internal:file create_file_perms;
+}
+# External SDCard rw access.
+bool app_external_sdcard_rw true;
+if (app_external_sdcard_rw) {
+allow untrusted_app sdcard_external:dir create_dir_perms;
+allow untrusted_app sdcard_external:file create_file_perms;
}
# Native app support.
bool app_ndk false;
@@ -155,7 +162,7 @@
# Communicate over a FIFO or socket created by the system_server.
allow appdomain system:fifo_file rw_file_perms;
-allow appdomain system:unix_stream_socket { read write };
+allow appdomain system:unix_stream_socket { read write setopt };
# Communicate over a socket created by surfaceflinger.
allow appdomain surfaceflinger:unix_stream_socket { read write setopt };
diff --git a/attributes b/attributes
index ef4a170..7d491e2 100644
--- a/attributes
+++ b/attributes
@@ -24,6 +24,9 @@
# All types use for sysfs files.
attribute sysfs_type;
+# Attribute used for all sdcards
+attribute sdcard_type;
+
# All types used for nodes/hosts.
attribute node_type;
diff --git a/dhcp.te b/dhcp.te
index 0c533eb..10ab788 100644
--- a/dhcp.te
+++ b/dhcp.te
@@ -4,16 +4,15 @@
type dhcp_system_file, file_type, data_file_type;
init_daemon_domain(dhcp)
+net_domain(dhcp)
-allow dhcp cgroup:dir { create add_name };
-allow dhcp self:capability { setgid setuid net_admin net_raw };
-allow dhcp self:packet_socket { create setopt bind write read };
-allow dhcp self:netlink_route_socket { write nlmsg_write read create bind };
-allow dhcp self:udp_socket { create ioctl };
-allow dhcp shell_exec:file { read open execute };
-allow dhcp system_file:file execute_no_trans;
+allow dhcp cgroup:dir { create write add_name };
+allow dhcp self:capability { setgid setuid net_admin net_raw net_bind_service };
+allow dhcp self:packet_socket create_socket_perms;
+allow dhcp self:netlink_route_socket { create_socket_perms nlmsg_write };
+allow dhcp shell_exec:file rx_file_perms;
+allow dhcp system_file:file rx_file_perms;
allow dhcp proc:file write;
-allow dhcp property_socket:sock_file write ;
allow dhcp system_prop:property_service set ;
allow dhcp dhcp_system_file:file rx_file_perms;
allow dhcp dhcp_system_file:dir r_dir_perms;
diff --git a/drmserver.te b/drmserver.te
index 63286d5..9ef3189 100644
--- a/drmserver.te
+++ b/drmserver.te
@@ -14,8 +14,12 @@
# Perform Binder IPC to mediaserver
binder_call(drmserver, mediaserver)
-allow drmserver sdcard:dir search;
+allow drmserver sdcard_type:dir search;
allow drmserver drm_data_file:dir create_dir_perms;
allow drmserver drm_data_file:file create_file_perms;
allow drmserver self:{ tcp_socket udp_socket } *;
+allow drmserver port:tcp_socket name_connect;
allow drmserver tee_device:chr_file rw_file_perms;
+allow drmserver platform_app_data_file:file { read write getattr };
+allow drmserver app_data_file:file { read write getattr };
+allow drmserver sdcard_type:file { read write getattr };
diff --git a/file.te b/file.te
index 484b8fe..65788df 100644
--- a/file.te
+++ b/file.te
@@ -16,7 +16,8 @@
type tmpfs, fs_type;
type shm, fs_type;
type mqueue, fs_type;
-type sdcard, fs_type, mlstrustedobject;
+type sdcard_internal, sdcard_type, fs_type, mlstrustedobject;
+type sdcard_external, sdcard_type, fs_type, mlstrustedobject;
type debugfs, fs_type, mlstrustedobject;
# File types
diff --git a/file_contexts b/file_contexts
index 0d2db38..d81d5a4 100644
--- a/file_contexts
+++ b/file_contexts
@@ -153,7 +153,7 @@
/data/app(/.*)? u:object_r:apk_data_file:s0
/data/app/vmdl.*\.tmp u:object_r:apk_tmp_file:s0
/data/tombstones(/.*)? u:object_r:tombstone_data_file:s0
-/data/local(/.*)? u:object_r:shell_data_file:s0
+/data/local/tmp(/.*)? u:object_r:shell_data_file:s0
# Misc data
/data/misc/bluetoothd(/.*)? u:object_r:bluetoothd_data_file:s0
/data/misc/bluetooth(/.*)? u:object_r:bluetooth_data_file:s0
diff --git a/genfs_contexts b/genfs_contexts
index ff633a7..2607b9d 100644
--- a/genfs_contexts
+++ b/genfs_contexts
@@ -9,6 +9,6 @@
# sysfs labels can be set by userspace.
genfscon sysfs / u:object_r:sysfs:s0
genfscon inotifyfs / u:object_r:inotify:s0
-genfscon vfat / u:object_r:sdcard:s0
+genfscon vfat / u:object_r:sdcard_external:s0
genfscon debugfs / u:object_r:debugfs:s0
-genfscon fuse / u:object_r:sdcard:s0
+genfscon fuse / u:object_r:sdcard_internal:s0
diff --git a/mediaserver.te b/mediaserver.te
index f941c6a..9a0ef1d 100644
--- a/mediaserver.te
+++ b/mediaserver.te
@@ -8,7 +8,7 @@
init_daemon_domain(mediaserver)
unix_socket_connect(mediaserver, property, init)
-r_dir_file(mediaserver, sdcard)
+r_dir_file(mediaserver, sdcard_type)
binder_use(mediaserver)
binder_call(mediaserver, binderservicedomain)
@@ -17,8 +17,9 @@
allow mediaserver kernel:system module_request;
allow mediaserver app_data_file:dir search;
-allow mediaserver app_data_file:file r_file_perms;
-allow mediaserver sdcard:file write;
+allow mediaserver app_data_file:file rw_file_perms;
+allow mediaserver platform_app_data_file:file { getattr read };
+allow mediaserver sdcard_type:file write;
allow mediaserver camera_device:chr_file rw_file_perms;
allow mediaserver graphics_device:chr_file rw_file_perms;
allow mediaserver video_device:chr_file rw_file_perms;
diff --git a/rild.te b/rild.te
index 9176348..c331bb3 100644
--- a/rild.te
+++ b/rild.te
@@ -23,7 +23,7 @@
allow rild radio_data_file:dir r_dir_perms;
allow rild radio_data_file:file rw_file_perms;
allow rild radio_device:lnk_file r_file_perms;
-allow rild sdcard:dir r_dir_perms;
+allow rild sdcard_type:dir r_dir_perms;
allow rild system_data_file:dir create_dir_perms;
allow rild system_data_file:file create_file_perms;
allow rild system_file:file x_file_perms;
diff --git a/sdcardd.te b/sdcardd.te
index 84471d7..4445183 100644
--- a/sdcardd.te
+++ b/sdcardd.te
@@ -6,8 +6,7 @@
allow sdcardd cgroup:dir create_dir_perms;
allow sdcardd fuse_device:chr_file rw_file_perms;
allow sdcardd rootfs:dir mounton;
-allow sdcardd sdcard:filesystem mount;
-allow sdcardd self:capability { setuid setgid dac_override };
+allow sdcardd sdcard_type:filesystem mount;
+allow sdcardd self:capability { setuid setgid dac_override sys_admin };
allow sdcardd system_data_file:dir create_dir_perms;
allow sdcardd system_data_file:file create_file_perms;
-
diff --git a/shell.te b/shell.te
index 5b4d843..2f1dd43 100644
--- a/shell.te
+++ b/shell.te
@@ -5,6 +5,7 @@
allow shell devpts:chr_file rw_file_perms;
allow shell tty_device:chr_file rw_file_perms;
allow shell console_device:chr_file rw_file_perms;
+allow shell input_device:chr_file rw_file_perms;
allow shell system_file:file x_file_perms;
allow shell shell_exec:file rx_file_perms;
allow shell zygote_exec:file rx_file_perms;
@@ -13,11 +14,11 @@
allow shell shell_data_file:file rx_file_perms;
# Access sdcard.
-allow shell sdcard:dir rw_dir_perms;
-allow shell sdcard:file create_file_perms;
+allow shell sdcard_type:dir rw_dir_perms;
+allow shell sdcard_type:file create_file_perms;
r_dir_file(shell, apk_data_file)
-allow shell dalvikcache_data_file:file write;
+allow shell dalvikcache_data_file:file { write setattr };
# Run logcat.
allow shell log_device:chr_file r_file_perms;
diff --git a/surfaceflinger.te b/surfaceflinger.te
index 30b1816..a383ec1 100644
--- a/surfaceflinger.te
+++ b/surfaceflinger.te
@@ -28,3 +28,7 @@
allow surfaceflinger system_prop:property_service set;
allow surfaceflinger ctl_default_prop:property_service set;
+# Use open files supplied by an app.
+allow surfaceflinger appdomain:fd use;
+allow surfaceflinger platform_app_data_file:file { read write };
+allow surfaceflinger app_data_file:file { read write };
diff --git a/system.te b/system.te
index a872516..a2a576c 100644
--- a/system.te
+++ b/system.te
@@ -28,7 +28,7 @@
selinux_getenforce(system_app)
# Settings app reads sdcard for storage stats
-allow system_app sdcard:dir r_dir_perms;
+allow system_app sdcard_type:dir r_dir_perms;
bool manage_selinux true;
if (manage_selinux) {
@@ -66,6 +66,9 @@
# XXX See if we can remove some of these.
allow system self:capability { kill net_bind_service net_broadcast net_admin net_raw sys_module sys_boot sys_nice sys_resource sys_time sys_tty_config };
+# Triggered by /proc/pid accesses, not allowed.
+dontaudit system self:capability sys_ptrace;
+
# Trigger module auto-load.
allow system kernel:system module_request;
diff --git a/vold.te b/vold.te
index 60d6a37..c1b9055 100644
--- a/vold.te
+++ b/vold.te
@@ -10,9 +10,9 @@
allow vold block_device:lnk_file read;
allow vold devpts:chr_file rw_file_perms;
allow vold rootfs:dir mounton;
-allow vold sdcard:dir mounton;
-allow vold sdcard:filesystem { mount remount unmount };
-allow vold sdcard:dir create_dir_perms;
+allow vold sdcard_type:dir mounton;
+allow vold sdcard_type:filesystem { mount remount unmount };
+allow vold sdcard_type:dir create_dir_perms;
allow vold tmpfs:filesystem { mount unmount };
allow vold tmpfs:dir create_dir_perms;
allow vold tmpfs:dir mounton;
diff --git a/zygote.te b/zygote.te
index 743af36..24e4189 100644
--- a/zygote.te
+++ b/zygote.te
@@ -33,7 +33,7 @@
# Setting up /storage/emulated.
allow zygote rootfs:dir mounton;
-allow zygote sdcard:dir { write search setattr create add_name mounton };
+allow zygote sdcard_type:dir { write search setattr create add_name mounton };
dontaudit zygote self:capability fsetid;
allow zygote tmpfs:dir { write create add_name setattr mounton };
allow zygote tmpfs:filesystem mount;