Introduce system_file_type

system_file_type is a new attribute used to identify files which exist
on the /system partition. It's useful for allow rules in init, which are
based off of a blacklist of writable files. Additionally, it's useful
for constructing neverallow rules to prevent regressions.

Additionally, add commented out tests which enforce that all files on
the /system partition have the system_file_type attribute. These tests
will be uncommented in a future change after all the device-specific
policies are cleaned up.

Test: Device boots and no obvious problems.
Change-Id: Id9bae6625f042594c8eba74ca712abb09702c1e5
This commit is contained in:
Nick Kralevich 2018-09-27 10:21:37 -07:00
parent ff1c765ff2
commit 5e37271df8
93 changed files with 132 additions and 119 deletions

View file

@ -2,7 +2,7 @@
# It is spawned either by traced_probes or by init for the boottrace service.
type atrace, domain, coredomain;
type atrace_exec, exec_type, file_type;
type atrace_exec, exec_type, file_type, system_file_type;
# boottrace services uses /data/misc/boottrace/categories
allow atrace boottrace_data_file:dir search;

View file

@ -2,7 +2,7 @@
typeattribute audioserver coredomain;
type audioserver_exec, exec_type, file_type;
type audioserver_exec, exec_type, file_type, system_file_type;
init_daemon_domain(audioserver)
r_dir_file(audioserver, sdcard_type)

View file

@ -1,5 +1,5 @@
type blank_screen, domain, coredomain;
type blank_screen_exec, exec_type, file_type;
type blank_screen_exec, exec_type, file_type, system_file_type;
init_daemon_domain(blank_screen)

View file

@ -2,7 +2,7 @@
typeattribute blkid coredomain;
type blkid_exec, exec_type, file_type;
type blkid_exec, system_file_type, exec_type, file_type;
# Allowed read-only access to encrypted devices to extract UUID/label
allow blkid block_device:dir search;

View file

@ -1,6 +1,6 @@
# bpf program loader
type bpfloader, domain;
type bpfloader_exec, exec_type, file_type;
type bpfloader_exec, system_file_type, exec_type, file_type;
typeattribute bpfloader coredomain;
# Process need CAP_NET_ADMIN to run bpf programs as cgroup filter

View file

@ -1,6 +1,6 @@
# dexoptanalyzer
type dexoptanalyzer, domain, coredomain, mlstrustedsubject;
type dexoptanalyzer_exec, exec_type, file_type;
type dexoptanalyzer_exec, system_file_type, exec_type, file_type;
# Reading an APK opens a ZipArchive, which unpack to tmpfs.
# Use tmpfs_domain() which will give tmpfs files created by dexoptanalyzer their

View file

@ -1,5 +1,5 @@
type hal_allocator_default, domain, coredomain;
hal_server_domain(hal_allocator_default, hal_allocator)
type hal_allocator_default_exec, exec_type, file_type;
type hal_allocator_default_exec, system_file_type, exec_type, file_type;
init_daemon_domain(hal_allocator_default)

View file

@ -1,5 +1,5 @@
type hal_system_suspend_default, domain, coredomain;
hal_server_domain(hal_system_suspend_default, hal_system_suspend)
type hal_system_suspend_default_exec, exec_type, file_type;
type hal_system_suspend_default_exec, system_file_type, exec_type, file_type;
init_daemon_domain(hal_system_suspend_default)

View file

@ -1,6 +1,6 @@
typeattribute incident coredomain;
type incident_exec, exec_type, file_type;
type incident_exec, system_file_type, exec_type, file_type;
# switch to incident domain for incident command
domain_auto_trans(shell, incident_exec, incident)

View file

@ -1,6 +1,6 @@
typeattribute incident_helper coredomain;
type incident_helper_exec, exec_type, file_type;
type incident_helper_exec, system_file_type, exec_type, file_type;
# switch to incident_helper domain for incident_helper command
domain_auto_trans(incidentd, incident_helper_exec, incident_helper)

View file

@ -2,7 +2,7 @@ typeattribute incidentd coredomain;
typeattribute incidentd mlstrustedsubject;
init_daemon_domain(incidentd)
type incidentd_exec, exec_type, file_type;
type incidentd_exec, system_file_type, exec_type, file_type;
binder_use(incidentd)
wakelock_use(incidentd)

View file

@ -3,7 +3,7 @@
typeattribute mdnsd coredomain;
typeattribute mdnsd mlstrustedsubject;
type mdnsd_exec, exec_type, file_type;
type mdnsd_exec, system_file_type, exec_type, file_type;
init_daemon_domain(mdnsd)
net_domain(mdnsd)

View file

@ -4,7 +4,7 @@
# daemon.
type perfetto, domain, coredomain;
type perfetto_exec, exec_type, file_type;
type perfetto_exec, system_file_type, exec_type, file_type;
tmpfs_domain(perfetto);

View file

@ -1,6 +1,6 @@
type stats, domain;
typeattribute stats coredomain;
type stats_exec, exec_type, file_type;
type stats_exec, system_file_type, exec_type, file_type;
# switch to stats domain for stats command
domain_auto_trans(shell, stats_exec, stats)

View file

@ -1,6 +1,6 @@
# storaged daemon
type storaged, domain, coredomain, mlstrustedsubject;
type storaged_exec, exec_type, file_type;
type storaged_exec, system_file_type, exec_type, file_type;
init_daemon_domain(storaged)

View file

@ -2,7 +2,7 @@
typeattribute surfaceflinger coredomain;
type surfaceflinger_exec, exec_type, file_type;
type surfaceflinger_exec, system_file_type, exec_type, file_type;
init_daemon_domain(surfaceflinger)
typeattribute surfaceflinger mlstrustedsubject;

View file

@ -1,6 +1,6 @@
# Perfetto user-space tracing daemon (unprivileged)
type traced, domain, coredomain, mlstrustedsubject;
type traced_exec, exec_type, file_type;
type traced_exec, system_file_type, exec_type, file_type;
# Allow init to exec the daemon.
init_daemon_domain(traced)

View file

@ -1,5 +1,5 @@
# Perfetto tracing probes, has tracefs access.
type traced_probes_exec, exec_type, file_type;
type traced_probes_exec, system_file_type, exec_type, file_type;
# Allow init to exec the daemon.
init_daemon_domain(traced_probes)

View file

@ -1,6 +1,6 @@
# wait_for_keymaster service
type wait_for_keymaster, domain, coredomain;
type wait_for_keymaster_exec, exec_type, file_type;
type wait_for_keymaster_exec, system_file_type, exec_type, file_type;
init_daemon_domain(wait_for_keymaster)

View file

@ -1,7 +1,7 @@
# adbd seclabel is specified in init.rc since
# it lives in the rootfs and has no unique file type.
type adbd, domain;
type adbd_exec, exec_type, file_type;
type adbd_exec, exec_type, file_type, system_file_type;
# Only init is allowed to enter the adbd domain via exec()
neverallow { domain -init } adbd:process transition;

View file

@ -33,6 +33,10 @@ expandattribute data_file_type false;
# All types in /data, not in /data/vendor
attribute core_data_file_type;
expandattribute core_data_file_type false;
# All types in /system
attribute system_file_type;
# All types in /vendor
attribute vendor_file_type;

View file

@ -1,6 +1,6 @@
# bootanimation oneshot service
type bootanim, domain;
type bootanim_exec, exec_type, file_type;
type bootanim_exec, system_file_type, exec_type, file_type;
hal_client_domain(bootanim, hal_configstore)
hal_client_domain(bootanim, hal_graphics_allocator)

View file

@ -1,6 +1,6 @@
# bootstat command
type bootstat, domain;
type bootstat_exec, exec_type, file_type;
type bootstat_exec, system_file_type, exec_type, file_type;
read_runtime_log_tags(bootstat)

View file

@ -1,6 +1,6 @@
# bufferhubd
type bufferhubd, domain, mlstrustedsubject;
type bufferhubd_exec, exec_type, file_type;
type bufferhubd_exec, system_file_type, exec_type, file_type;
hal_client_domain(bufferhubd, hal_graphics_allocator)

View file

@ -1,6 +1,6 @@
# cameraserver - camera daemon
type cameraserver, domain;
type cameraserver_exec, exec_type, file_type;
type cameraserver_exec, system_file_type, exec_type, file_type;
binder_use(cameraserver)
binder_call(cameraserver, binderservicedomain)

View file

@ -1,6 +1,6 @@
# 464xlat daemon
type clatd, domain;
type clatd_exec, exec_type, file_type;
type clatd_exec, system_file_type, exec_type, file_type;
net_domain(clatd)

View file

@ -5,7 +5,7 @@
# directories.
type cppreopts, domain, mlstrustedsubject;
type cppreopts_exec, exec_type, file_type;
type cppreopts_exec, system_file_type, exec_type, file_type;
# Allow cppreopts copy files into the dalvik-cache
allow cppreopts dalvikcache_data_file:dir { add_name remove_name search write };

View file

@ -1,5 +1,5 @@
type crash_dump, domain;
type crash_dump_exec, exec_type, file_type;
type crash_dump_exec, system_file_type, exec_type, file_type;
# crash_dump might inherit CAP_SYS_PTRACE from a privileged process,
# which will result in an audit log even when it's allowed to trace.

View file

@ -1,6 +1,6 @@
# dex2oat
type dex2oat, domain;
type dex2oat_exec, exec_type, file_type;
type dex2oat_exec, system_file_type, exec_type, file_type;
r_dir_file(dex2oat, apk_data_file)
# Access to /vendor/app

View file

@ -1,5 +1,5 @@
type dhcp, domain;
type dhcp_exec, exec_type, file_type;
type dhcp_exec, system_file_type, exec_type, file_type;
net_domain(dhcp)

View file

@ -1,6 +1,6 @@
# DNS, DHCP services
type dnsmasq, domain;
type dnsmasq_exec, exec_type, file_type;
type dnsmasq_exec, system_file_type, exec_type, file_type;
net_domain(dnsmasq)
allowxperm dnsmasq self:udp_socket ioctl priv_sock_ioctls;

View file

@ -454,7 +454,7 @@ neverallow {
userdebug_or_eng(`-mediaextractor')
} {
file_type
-system_file
-system_file_type
-system_lib_file
-system_linker_exec
-vendor_file_type
@ -503,16 +503,16 @@ neverallow {
domain
with_asan(`-asan_extract')
} {
system_file
system_file_type
vendor_file_type
exec_type
}:dir_file_class_set { create write setattr relabelfrom append unlink link rename };
neverallow { domain -kernel with_asan(`-asan_extract') } { system_file vendor_file_type exec_type }:dir_file_class_set relabelto;
neverallow { domain -kernel with_asan(`-asan_extract') } { system_file_type vendor_file_type exec_type }:dir_file_class_set relabelto;
# Don't allow mounting on top of /system files or directories
neverallow * exec_type:dir_file_class_set mounton;
neverallow { domain -init } { system_file vendor_file_type }:dir_file_class_set mounton;
neverallow { domain -init } { system_file_type vendor_file_type }:dir_file_class_set mounton;
# Nothing should be writing to files in the rootfs.
neverallow * rootfs:file { create write setattr relabelto append unlink link rename };
@ -1109,7 +1109,7 @@ full_treble_only(`
# -appdomain
# -coredomain
# -vendor_executes_system_violators
# } system_file:file *;
# } system_file_type:file *;
#')
# Only authorized processes should be writing to files in /data/dalvik-cache

View file

@ -1,6 +1,6 @@
# drmserver - DRM service
type drmserver, domain;
type drmserver_exec, exec_type, file_type;
type drmserver_exec, system_file_type, exec_type, file_type;
typeattribute drmserver mlstrustedsubject;

View file

@ -1,6 +1,6 @@
# dumpstate
type dumpstate, domain, mlstrustedsubject;
type dumpstate_exec, exec_type, file_type;
type dumpstate_exec, system_file_type, exec_type, file_type;
net_domain(dumpstate)
binder_use(dumpstate)

View file

@ -1,5 +1,5 @@
type e2fs, domain, coredomain;
type e2fs_exec, exec_type, file_type;
type e2fs_exec, system_file_type, exec_type, file_type;
allow e2fs devpts:chr_file { read write getattr ioctl };

View file

@ -131,19 +131,19 @@ type app_fusefs, fs_type, contextmount_type;
type unlabeled, file_type;
# Default type for anything under /system.
type system_file, file_type;
type system_file, system_file_type, file_type;
# Default type for anything under /system/lib[64].
type system_lib_file, file_type;
type system_lib_file, system_file_type, file_type;
# Default type for linker executable /system/bin/linker[64].
type system_linker_exec, file_type;
type system_linker_exec, system_file_type, file_type;
# Default type for linker config /system/etc/ld.config.*.
type system_linker_config_file, file_type;
type system_linker_config_file, system_file_type, file_type;
# Default type for linker config /system/etc/seccomp_policy/*.
type system_seccomp_policy_file, file_type;
type system_seccomp_policy_file, system_file_type, file_type;
# Default type for cacerts in /system/etc/security/cacerts/*.
type system_security_cacerts_file, file_type;
type system_security_cacerts_file, system_file_type, file_type;
# Default type for zoneinfo files in /system/usr/share/zoneinfo/*.
type system_zoneinfo_file, file_type;
type system_zoneinfo_file, system_file_type, file_type;
# Default type for directories search for
# HAL implementations
@ -175,7 +175,7 @@ type vold_metadata_file, file_type;
# Speedup access for trusted applications to the runtime event tags
type runtime_event_log_tags_file, file_type;
# Type for /system/bin/logcat.
type logcat_exec, exec_type, file_type;
type logcat_exec, system_file_type, exec_type, file_type;
# /cores for coredumps on userdebug / eng builds
type coredump_file, file_type;
# Default type for anything under /data.
@ -385,28 +385,28 @@ pdx_service_socket_types(performance_client, pdx_performance_dir)
pdx_service_socket_types(bufferhub_client, pdx_bufferhub_dir)
# file_contexts files
type file_contexts_file, file_type;
type file_contexts_file, system_file_type, file_type;
# mac_permissions file
type mac_perms_file, file_type;
type mac_perms_file, system_file_type, file_type;
# property_contexts file
type property_contexts_file, file_type;
type property_contexts_file, system_file_type, file_type;
# seapp_contexts file
type seapp_contexts_file, file_type;
type seapp_contexts_file, system_file_type, file_type;
# sepolicy files binary and others
type sepolicy_file, file_type;
type sepolicy_file, system_file_type, file_type;
# service_contexts file
type service_contexts_file, file_type;
type service_contexts_file, system_file_type, file_type;
# nonplat service_contexts file (only accessible on non full-treble devices)
type nonplat_service_contexts_file, file_type;
# hwservice_contexts file
type hwservice_contexts_file, file_type;
type hwservice_contexts_file, system_file_type, file_type;
# vndservice_contexts file
type vndservice_contexts_file, file_type;

View file

@ -1,5 +1,5 @@
type fingerprintd, domain;
type fingerprintd_exec, exec_type, file_type;
type fingerprintd_exec, system_file_type, exec_type, file_type;
binder_use(fingerprintd)

View file

@ -1,6 +1,6 @@
# Any fsck program run by init
type fsck, domain;
type fsck_exec, exec_type, file_type;
type fsck_exec, system_file_type, exec_type, file_type;
# /dev/__null__ created by init prior to policy load,
# open fd inherited by fsck.

View file

@ -1,5 +1,5 @@
type gatekeeperd, domain;
type gatekeeperd_exec, exec_type, file_type;
type gatekeeperd_exec, system_file_type, exec_type, file_type;
# gatekeeperd
binder_service(gatekeeperd)

View file

@ -1,6 +1,6 @@
# healthd - battery/charger monitoring service daemon
type healthd, domain;
type healthd_exec, exec_type, file_type;
type healthd_exec, system_file_type, exec_type, file_type;
# Write to /dev/kmsg
allow healthd kmsg_device:chr_file rw_file_perms;

View file

@ -1,6 +1,6 @@
# hwservicemanager - the Binder context manager for HAL services
type hwservicemanager, domain, mlstrustedsubject;
type hwservicemanager_exec, exec_type, file_type;
type hwservicemanager_exec, system_file_type, exec_type, file_type;
# Note that we do not use the binder_* macros here.
# hwservicemanager provides name service (aka context manager)

View file

@ -1,6 +1,6 @@
# idmap, when executed by installd
type idmap, domain;
type idmap_exec, exec_type, file_type;
type idmap_exec, system_file_type, exec_type, file_type;
# Use open file to /data/resource-cache file inherited from installd.
allow idmap installd:fd use;

View file

@ -2,7 +2,7 @@
type init, domain, mlstrustedsubject;
# The init domain is entered by execing init.
type init_exec, exec_type, file_type;
type init_exec, system_file_type, exec_type, file_type;
# /dev/__null__ node created by init.
allow init tmpfs:chr_file { create setattr unlink rw_file_perms };
@ -147,7 +147,7 @@ allow init {
-nativetest_data_file
-privapp_data_file
-system_app_data_file
-system_file
-system_file_type
-vendor_file_type
}:dir { create search getattr open read setattr ioctl };
@ -161,7 +161,7 @@ allow init {
-privapp_data_file
-shell_data_file
-system_app_data_file
-system_file
-system_file_type
-vendor_file_type
-vold_data_file
}:dir { write add_name remove_name rmdir relabelfrom };
@ -177,7 +177,7 @@ allow init {
-runtime_event_log_tags_file
-shell_data_file
-system_app_data_file
-system_file
-system_file_type
-vendor_file_type
-vold_data_file
}:file { create getattr open read write setattr relabelfrom unlink map };
@ -192,7 +192,7 @@ allow init {
-privapp_data_file
-shell_data_file
-system_app_data_file
-system_file
-system_file_type
-vendor_file_type
-vold_data_file
}:{ sock_file fifo_file } { create getattr open read setattr relabelfrom unlink };
@ -207,14 +207,14 @@ allow init {
-privapp_data_file
-shell_data_file
-system_app_data_file
-system_file
-system_file_type
-vendor_file_type
-vold_data_file
}:lnk_file { create getattr setattr relabelfrom unlink };
allow init cache_file:lnk_file r_file_perms;
allow init { file_type -system_file -vendor_file_type -exec_type }:dir_file_class_set relabelto;
allow init { file_type -system_file_type -vendor_file_type -exec_type }:dir_file_class_set relabelto;
# does init really need to relabel app data?
userdebug_or_eng(`auditallow init { app_data_file privapp_data_file }:dir_file_class_set relabelto;')
allow init { sysfs debugfs debugfs_tracing debugfs_tracing_debug }:{ dir file lnk_file } { getattr relabelfrom };

View file

@ -1,6 +1,6 @@
# inputflinger
type inputflinger, domain;
type inputflinger_exec, exec_type, file_type;
type inputflinger_exec, system_file_type, exec_type, file_type;
binder_use(inputflinger)
binder_service(inputflinger)

View file

@ -1,6 +1,6 @@
# service flash_recovery in init.rc
type install_recovery, domain;
type install_recovery_exec, exec_type, file_type;
type install_recovery_exec, system_file_type, exec_type, file_type;
allow install_recovery self:global_capability_class_set { dac_override dac_read_search };

View file

@ -1,6 +1,6 @@
# installer daemon
type installd, domain;
type installd_exec, exec_type, file_type;
type installd_exec, system_file_type, exec_type, file_type;
typeattribute installd mlstrustedsubject;
allow installd self:global_capability_class_set { chown dac_override dac_read_search fowner fsetid setgid setuid sys_admin };

View file

@ -1,5 +1,5 @@
type keystore, domain;
type keystore_exec, exec_type, file_type;
type keystore_exec, system_file_type, exec_type, file_type;
# keystore daemon
typeattribute keystore mlstrustedsubject;

View file

@ -1,3 +1,3 @@
# llkd Live LocK Daemon
type llkd, domain, mlstrustedsubject;
type llkd_exec, exec_type, file_type;
type llkd_exec, system_file_type, exec_type, file_type;

View file

@ -1,6 +1,6 @@
# lmkd low memory killer daemon
type lmkd, domain, mlstrustedsubject;
type lmkd_exec, exec_type, file_type;
type lmkd_exec, system_file_type, exec_type, file_type;
allow lmkd self:global_capability_class_set { dac_override dac_read_search sys_resource kill };

View file

@ -1,6 +1,6 @@
# android user-space log manager
type logd, domain, mlstrustedsubject;
type logd_exec, exec_type, file_type;
type logd_exec, system_file_type, exec_type, file_type;
# Read access to pseudo filesystems.
r_dir_file(logd, cgroup)

View file

@ -1,6 +1,6 @@
# mediadrmserver - mediadrm daemon
type mediadrmserver, domain;
type mediadrmserver_exec, exec_type, file_type;
type mediadrmserver_exec, system_file_type, exec_type, file_type;
typeattribute mediadrmserver mlstrustedsubject;

View file

@ -1,6 +1,6 @@
# mediaextractor - multimedia daemon
type mediaextractor, domain;
type mediaextractor_exec, exec_type, file_type;
type mediaextractor_exec, system_file_type, exec_type, file_type;
typeattribute mediaextractor mlstrustedsubject;

View file

@ -1,6 +1,6 @@
# mediametrics - daemon for collecting media.metrics data
type mediametrics, domain;
type mediametrics_exec, exec_type, file_type;
type mediametrics_exec, system_file_type, exec_type, file_type;
binder_use(mediametrics)

View file

@ -1,6 +1,6 @@
# mediaserver - multimedia daemon
type mediaserver, domain;
type mediaserver_exec, exec_type, file_type;
type mediaserver_exec, system_file_type, exec_type, file_type;
typeattribute mediaserver mlstrustedsubject;

View file

@ -1,6 +1,6 @@
# vpn tunneling protocol manager
type mtp, domain;
type mtp_exec, exec_type, file_type;
type mtp_exec, system_file_type, exec_type, file_type;
net_domain(mtp)

View file

@ -1,6 +1,6 @@
# network manager
type netd, domain, mlstrustedsubject;
type netd_exec, exec_type, file_type;
type netd_exec, system_file_type, exec_type, file_type;
net_domain(netd)
# in addition to ioctls whitelisted for all domains, grant netd priv_sock_ioctls.

View file

@ -1,4 +1,4 @@
type netutils_wrapper, domain;
type netutils_wrapper_exec, exec_type, file_type;
type netutils_wrapper_exec, system_file_type, exec_type, file_type;
neverallow domain netutils_wrapper_exec:file execute_no_trans;

View file

@ -1,6 +1,6 @@
# otapreopt_chroot executable
type otapreopt_chroot, domain;
type otapreopt_chroot_exec, exec_type, file_type;
type otapreopt_chroot_exec, system_file_type, exec_type, file_type;
# Chroot preparation and execution.
# We need to create an unshared mount namespace, and then mount /data.

View file

@ -4,7 +4,7 @@
# from /data/ota to /data/dalvik-cache.
type otapreopt_slot, domain, mlstrustedsubject;
type otapreopt_slot_exec, exec_type, file_type;
type otapreopt_slot_exec, system_file_type, exec_type, file_type;
# The otapreopt_slot renames the OTA dalvik-cache to the regular dalvik-cache, and cleans up

View file

@ -1,6 +1,6 @@
# performanced
type performanced, domain, mlstrustedsubject;
type performanced_exec, exec_type, file_type;
type performanced_exec, system_file_type, exec_type, file_type;
# Needed to check for app permissions.
binder_use(performanced)

View file

@ -1,6 +1,6 @@
# perfprofd - perf profile collection daemon
type perfprofd, domain;
type perfprofd_exec, exec_type, file_type;
type perfprofd_exec, system_file_type, exec_type, file_type;
userdebug_or_eng(`

View file

@ -1,7 +1,7 @@
# Point to Point Protocol daemon
type ppp, domain;
type ppp_device, dev_type;
type ppp_exec, exec_type, file_type;
type ppp_exec, system_file_type, exec_type, file_type;
net_domain(ppp)

View file

@ -3,7 +3,7 @@
# This executable translates names from the preopted versions the build system
# creates to the names the runtime expects in the data directory.
type preopt2cachename, domain;
type preopt2cachename_exec, exec_type, file_type;
type preopt2cachename_exec, system_file_type, exec_type, file_type;
# Allow write to stdout.
allow preopt2cachename cppreopts:fd use;

View file

@ -1,6 +1,6 @@
# profman
type profman, domain;
type profman_exec, exec_type, file_type;
type profman_exec, system_file_type, exec_type, file_type;
allow profman user_profile_data_file:file { getattr read write lock map };

View file

@ -1,6 +1,6 @@
# IKE key management daemon
type racoon, domain;
type racoon_exec, exec_type, file_type;
type racoon_exec, system_file_type, exec_type, file_type;
typeattribute racoon mlstrustedsubject;

View file

@ -1,6 +1,6 @@
# android recovery persistent log manager
type recovery_persist, domain;
type recovery_persist_exec, exec_type, file_type;
type recovery_persist_exec, system_file_type, exec_type, file_type;
allow recovery_persist pstorefs:dir search;
allow recovery_persist pstorefs:file r_file_perms;

View file

@ -1,6 +1,6 @@
# android recovery refresh log manager
type recovery_refresh, domain;
type recovery_refresh_exec, exec_type, file_type;
type recovery_refresh_exec, system_file_type, exec_type, file_type;
allow recovery_refresh pstorefs:dir search;
allow recovery_refresh pstorefs:file r_file_perms;

View file

@ -1,5 +1,5 @@
type runas, domain, mlstrustedsubject;
type runas_exec, exec_type, file_type;
type runas_exec, system_file_type, exec_type, file_type;
allow runas adbd:fd use;
allow runas adbd:process sigchld;

View file

@ -1,5 +1,5 @@
type sdcardd, domain;
type sdcardd_exec, exec_type, file_type;
type sdcardd_exec, system_file_type, exec_type, file_type;
allow sdcardd cgroup:dir create_dir_perms;
allow sdcardd fuse_device:chr_file rw_file_perms;

View file

@ -1,6 +1,6 @@
# servicemanager - the Binder context manager
type servicemanager, domain, mlstrustedsubject;
type servicemanager_exec, exec_type, file_type;
type servicemanager_exec, system_file_type, exec_type, file_type;
# Note that we do not use the binder_* macros here.
# servicemanager is unique in that it only provides

View file

@ -1,6 +1,6 @@
# sgdisk called from vold
type sgdisk, domain;
type sgdisk_exec, exec_type, file_type;
type sgdisk_exec, system_file_type, exec_type, file_type;
# Allowed to read/write low-level partition tables
allow sgdisk block_device:dir search;

View file

@ -1,6 +1,6 @@
# Domain for shell processes spawned by ADB or console service.
type shell, domain, mlstrustedsubject;
type shell_exec, exec_type, file_type;
type shell_exec, system_file_type, exec_type, file_type;
# Create and use network sockets.
net_domain(shell)

View file

@ -1,6 +1,6 @@
type statsd, domain, mlstrustedsubject;
type statsd_exec, exec_type, file_type;
type statsd_exec, system_file_type, exec_type, file_type;
binder_use(statsd)
# Allow statsd to scan through /proc/pid for all processes.

View file

@ -3,7 +3,7 @@
type su, domain;
# File types must be defined for file_contexts.
type su_exec, exec_type, file_type;
type su_exec, system_file_type, exec_type, file_type;
userdebug_or_eng(`
# Domain used for su processes, as well as for adbd and adb shell

View file

@ -1,6 +1,6 @@
# thermalserviced -- thermal management services for system and vendor
type thermalserviced, domain;
type thermalserviced_exec, exec_type, file_type;
type thermalserviced_exec, system_file_type, exec_type, file_type;
binder_use(thermalserviced)
binder_service(thermalserviced)

View file

@ -1,6 +1,6 @@
# debugger interface
type tombstoned, domain, mlstrustedsubject;
type tombstoned_exec, exec_type, file_type;
type tombstoned_exec, system_file_type, exec_type, file_type;
# Write to arbitrary pipes given to us.
allow tombstoned domain:fd use;

View file

@ -2,7 +2,7 @@
# At present, the only known usage is for running mkswap via fs_mgr.
# Do NOT use this domain for toolbox when run by any other domain.
type toolbox, domain;
type toolbox_exec, exec_type, file_type;
type toolbox_exec, system_file_type, exec_type, file_type;
# /dev/__null__ created by init prior to policy load,
# open fd inherited by fsck.

View file

@ -1,6 +1,6 @@
# The tzdatacheck command run by init.
type tzdatacheck, domain;
type tzdatacheck_exec, exec_type, file_type;
type tzdatacheck_exec, system_file_type, exec_type, file_type;
allow tzdatacheck zoneinfo_data_file:dir create_dir_perms;
allow tzdatacheck zoneinfo_data_file:file unlink;

View file

@ -1,6 +1,6 @@
# uncrypt
type uncrypt, domain, mlstrustedsubject;
type uncrypt_exec, exec_type, file_type;
type uncrypt_exec, system_file_type, exec_type, file_type;
allow uncrypt self:global_capability_class_set { dac_override dac_read_search };

View file

@ -1,6 +1,6 @@
# Domain for update_engine daemon.
type update_engine, domain, update_engine_common;
type update_engine_exec, exec_type, file_type;
type update_engine_exec, system_file_type, exec_type, file_type;
net_domain(update_engine);

View file

@ -1,6 +1,6 @@
# update_verifier
type update_verifier, domain;
type update_verifier_exec, exec_type, file_type;
type update_verifier_exec, system_file_type, exec_type, file_type;
# Allow update_verifier to reach block devices in /dev/block.
allow update_verifier block_device:dir search;

View file

@ -1,5 +1,5 @@
type usbd, domain;
type usbd_exec, exec_type, file_type;
type usbd_exec, system_file_type, exec_type, file_type;
# Start/stop adbd via ctl.start adbd
set_prop(usbd, ctl_adbd_prop)

View file

@ -6,7 +6,7 @@
# collecting bug reports.
type vdc, domain;
type vdc_exec, exec_type, file_type;
type vdc_exec, system_file_type, exec_type, file_type;
# vdc can be invoked with logwrapper, so let it write to pty
allow vdc devpts:chr_file rw_file_perms;

View file

@ -41,7 +41,7 @@ allow vendor_init {
file_type
-core_data_file_type
-exec_type
-system_file
-system_file_type
-mnt_product_file
-unlabeled
-vendor_file_type
@ -53,7 +53,7 @@ allow vendor_init {
-core_data_file_type
-exec_type
-runtime_event_log_tags_file
-system_file
-system_file_type
-unlabeled
-vendor_file_type
-vold_metadata_file
@ -63,7 +63,7 @@ allow vendor_init {
file_type
-core_data_file_type
-exec_type
-system_file
-system_file_type
-unlabeled
-vendor_file_type
-vold_metadata_file
@ -73,7 +73,7 @@ allow vendor_init {
file_type
-core_data_file_type
-exec_type
-system_file
-system_file_type
-unlabeled
-vendor_file_type
-vold_metadata_file
@ -84,7 +84,7 @@ allow vendor_init {
-core_data_file_type
-exec_type
-mnt_product_file
-system_file
-system_file_type
-vendor_file_type
-vold_metadata_file
}:dir_file_class_set relabelto;
@ -175,6 +175,9 @@ not_compatible_property(`
})
')
# Get file context
allow vendor_init file_contexts_file:file r_file_perms;
set_prop(vendor_init, bluetooth_a2dp_offload_prop)
set_prop(vendor_init, debug_prop)
set_prop(vendor_init, exported_audio_prop)

View file

@ -1,5 +1,5 @@
type virtual_touchpad, domain;
type virtual_touchpad_exec, exec_type, file_type;
type virtual_touchpad_exec, system_file_type, exec_type, file_type;
binder_use(virtual_touchpad)
binder_service(virtual_touchpad)

View file

@ -1,6 +1,6 @@
# volume manager
type vold, domain;
type vold_exec, exec_type, file_type;
type vold_exec, exec_type, file_type, system_file_type;
# Read already opened /cache files.
allow vold cache_file:dir r_dir_perms;

View file

@ -1,6 +1,6 @@
# SELinux directory creation and labelling for vold-managed directories
type vold_prepare_subdirs, domain;
type vold_prepare_subdirs_exec, exec_type, file_type;
type vold_prepare_subdirs_exec, system_file_type, exec_type, file_type;
typeattribute vold_prepare_subdirs coredomain;

View file

@ -1,5 +1,5 @@
type vr_hwc, domain;
type vr_hwc_exec, exec_type, file_type;
type vr_hwc_exec, system_file_type, exec_type, file_type;
# Get buffer metadata.
hal_client_domain(vr_hwc, hal_graphics_allocator)

View file

@ -1,6 +1,6 @@
# watchdogd seclabel is specified in init.<board>.rc
type watchdogd, domain;
type watchdogd_exec, exec_type, file_type;
type watchdogd_exec, system_file_type, exec_type, file_type;
allow watchdogd watchdog_device:chr_file rw_file_perms;
allow watchdogd kmsg_device:chr_file rw_file_perms;

View file

@ -1,6 +1,6 @@
# wificond
type wificond, domain;
type wificond_exec, exec_type, file_type;
type wificond_exec, system_file_type, exec_type, file_type;
binder_use(wificond)
binder_call(wificond, system_server)

View file

@ -1,5 +1,5 @@
type wpantund, domain;
type wpantund_exec, exec_type, file_type;
type wpantund_exec, system_file_type, exec_type, file_type;
hal_client_domain(wpantund, hal_lowpan)
net_domain(wpantund)

View file

@ -1,3 +1,3 @@
# zygote
type zygote, domain;
type zygote_exec, exec_type, file_type;
type zygote_exec, system_file_type, exec_type, file_type;

View file

@ -11,6 +11,9 @@ import sys
def TestDataTypeViolations(pol):
return pol.AssertPathTypesHaveAttr(["/data/"], [], "data_file_type")
# def TestSystemTypeViolations(pol):
# return pol.AssertPathTypesHaveAttr(["/system/"], [], "system_file_type")
def TestProcTypeViolations(pol):
return pol.AssertGenfsFilesystemTypesHaveAttr("proc", "proc_type")
@ -55,6 +58,7 @@ Tests = [
"TestDataTypeViolators",
"TestProcTypeViolations",
"TestSysfsTypeViolations",
# "TestSystemTypeViolators",
"TestDebugfsTypeViolations",
"TestVendorTypeViolations",
"TestCoreDataTypeViolations",
@ -103,6 +107,8 @@ if __name__ == '__main__':
results += TestProcTypeViolations(pol)
if options.test is None or "TestSysfsTypeViolations" in options.test:
results += TestSysfsTypeViolations(pol)
# if options.test is None or "TestSystemTypeViolations" in options.test:
# results += TestSystemTypeViolations(pol)
if options.test is None or "TestDebugfsTypeViolations" in options.test:
results += TestDebugfsTypeViolations(pol)
if options.test is None or "TestVendorTypeViolations" in options.test: