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
This commit is contained in:
Florian Mayer 2019-03-19 18:14:38 +00:00
parent 6557d87b0f
commit 4ab64c940f
9 changed files with 18 additions and 2 deletions

View file

@ -1581,7 +1581,8 @@
(typeattributeset system_boot_reason_prop_28_0 (system_boot_reason_prop))
(typeattributeset system_data_file_28_0
( dropbox_data_file
system_data_file))
system_data_file
packages_list_file))
(typeattributeset system_file_28_0
( system_file
system_asan_options_file

View file

@ -421,6 +421,7 @@
# propagate to the "Expanded data files" section.
#
/data(/.*)? u:object_r:system_data_file:s0
/data/system/packages\.list u:object_r:packages_list_file:s0
/data/.layout_version u:object_r:install_data_file:s0
/data/unencrypted(/.*)? u:object_r:unencrypted_data_file:s0
/data/backup(/.*)? u:object_r:backup_data_file:s0

View file

@ -12,6 +12,7 @@ allow storaged proc_uid_io_stats:file r_file_perms;
# Read /data/system/packages.list
allow storaged system_data_file:file r_file_perms;
allow storaged packages_list_file:file r_file_perms;
# Store storaged proto file
allow storaged storaged_data_file:dir rw_dir_perms;

View file

@ -357,6 +357,7 @@ allow system_server ota_package_file:file create_file_perms;
# Manage system data files.
allow system_server system_data_file:dir create_dir_perms;
allow system_server system_data_file:notdevfile_class_set create_file_perms;
allow system_server packages_list_file:file create_file_perms;
allow system_server keychain_data_file:dir create_dir_perms;
allow system_server keychain_data_file:file create_file_perms;
allow system_server keychain_data_file:lnk_file create_file_perms;
@ -525,6 +526,10 @@ allow system_server media_rw_data_file:dir { search getattr open read };
# Also used for measuring disk usage.
allow system_server media_rw_data_file:file { getattr read write append };
# System server needs to setfscreate to packages_list_file when writing
# /data/system/packages.list
allow system_server system_server:process setfscreate;
# Relabel apk files.
allow system_server { apk_tmp_file apk_private_tmp_file }:{ dir file } { relabelfrom relabelto };
allow system_server { apk_data_file apk_private_data_file }:{ dir file } { relabelfrom relabelto };

View file

@ -221,6 +221,10 @@ type cgroup_rc_file, file_type;
type coredump_file, file_type;
# Default type for anything under /data.
type system_data_file, file_type, data_file_type, core_data_file_type;
# Type for /data/system/packages.list.
# TODO(b/129332765): Narrow down permissions to this.
# Find out users of system_data_file that should be granted only this.
type packages_list_file, file_type, data_file_type, core_data_file_type;
# Default type for anything under /data/vendor{_ce,_de}.
type vendor_data_file, file_type, data_file_type;
# Unencrypted data

View file

@ -13,6 +13,7 @@ allow logd self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_write
allow logd kernel:system syslog_read;
allow logd kmsg_device:chr_file { getattr w_file_perms };
allow logd system_data_file:{ file lnk_file } r_file_perms;
allow logd packages_list_file:file r_file_perms;
allow logd pstorefs:dir search;
allow logd pstorefs:file r_file_perms;
userdebug_or_eng(`
@ -58,7 +59,7 @@ neverallow { domain userdebug_or_eng(`-crash_dump -llkd') } logd:process ptrace;
neverallow logd system_file:dir_file_class_set write;
# Write to files in /data/data or system files on /data
neverallow logd { app_data_file privapp_data_file system_data_file }:dir_file_class_set write;
neverallow logd { app_data_file privapp_data_file system_data_file packages_list_file }:dir_file_class_set write;
# Only init is allowed to enter the logd domain via exec()
neverallow { domain -init } logd:process transition;

View file

@ -13,6 +13,7 @@ allow runas shell_data_file:file { read write };
# run-as reads package information.
allow runas system_data_file:file r_file_perms;
allow runas system_data_file:lnk_file getattr;
allow runas packages_list_file:file r_file_perms;
# The app's data dir may be accessed through a symlink.
allow runas system_data_file:lnk_file read;

View file

@ -20,6 +20,7 @@ allow sdcardd media_rw_data_file:file create_file_perms;
# Read /data/system/packages.list.
allow sdcardd system_data_file:file r_file_perms;
allow sdcardd packages_list_file:file r_file_perms;
# Read /data/.layout_version
allow sdcardd install_data_file:file r_file_perms;

View file

@ -9,6 +9,7 @@ allow simpleperf_app_runner devpts:chr_file { read write ioctl };
# simpleperf_app_runner reads package information.
allow simpleperf_app_runner system_data_file:file r_file_perms;
allow simpleperf_app_runner system_data_file:lnk_file getattr;
allow simpleperf_app_runner packages_list_file:file r_file_perms;
# The app's data dir may be accessed through a symlink.
allow simpleperf_app_runner system_data_file:lnk_file read;