Minimize public policy
Ideally, public should only contain APIs (types / attributes) for vendor. The other statements like allow/neverallow/typeattributes are regarded as implementation detail for platform and should be in private. Bug: 232023812 Test: m selinux_policy Test: diff <(git diff --staged | grep "^-" | cut -b2- | sort) \ <(git diff --staged | grep "^+" | cut -b2- | sort) Test: remove comments on plat_sepolicy.cil, replace base_typeattr_* to base_typeattr and then compare old and new plat_sepolicy.cil Change-Id: I5e7d2da4465ab0216de6bacdf03077d37f6ffe12
This commit is contained in:
parent
e98c6d2b38
commit
75806ef3c5
258 changed files with 7018 additions and 7000 deletions
|
@ -230,6 +230,11 @@ allow adbd apex_info_file:file r_file_perms;
|
|||
allow adbd tombstone_data_file:dir r_dir_perms;
|
||||
allow adbd tombstone_data_file:file r_file_perms;
|
||||
|
||||
# Access /data/local/tests.
|
||||
allow adbd shell_test_data_file:dir create_dir_perms;
|
||||
allow adbd shell_test_data_file:file create_file_perms;
|
||||
allow adbd shell_test_data_file:lnk_file create_file_perms;
|
||||
|
||||
###
|
||||
### Neverallow rules
|
||||
###
|
||||
|
@ -239,3 +244,7 @@ allow adbd tombstone_data_file:file r_file_perms;
|
|||
# never want to see a transition from adbd to su (aka "adb root")
|
||||
neverallow adbd { domain -crash_dump -shell }:process transition;
|
||||
neverallow adbd { domain userdebug_or_eng(`-su') recovery_only(`-shell') }:process dyntransition;
|
||||
|
||||
# Only init is allowed to enter the adbd domain via exec()
|
||||
neverallow { domain -init } adbd:process transition;
|
||||
neverallow * adbd:process dyntransition;
|
||||
|
|
|
@ -2,4 +2,9 @@ userdebug_or_eng(`
|
|||
typeattribute aidl_lazy_test_server coredomain;
|
||||
|
||||
init_daemon_domain(aidl_lazy_test_server)
|
||||
|
||||
binder_use(aidl_lazy_test_server)
|
||||
binder_call(aidl_lazy_test_server, binderservicedomain)
|
||||
|
||||
add_service(aidl_lazy_test_server, aidl_lazy_test_service)
|
||||
')
|
||||
|
|
|
@ -2,6 +2,9 @@ typeattribute apexd coredomain;
|
|||
|
||||
init_daemon_domain(apexd)
|
||||
|
||||
binder_use(apexd)
|
||||
add_service(apexd, apex_service)
|
||||
|
||||
# Allow creating, reading and writing of APEX files/dirs in the APEX data dir
|
||||
allow apexd apex_data_file:dir create_dir_perms;
|
||||
allow apexd apex_data_file:file create_file_perms;
|
||||
|
@ -166,33 +169,7 @@ get_prop(apexd, apexd_select_prop)
|
|||
# Allow apexd to read apexd_payload_metadata_prop
|
||||
get_prop(apexd, apexd_payload_metadata_prop)
|
||||
|
||||
neverallow { domain -apexd -init } apex_data_file:dir no_w_dir_perms;
|
||||
neverallow { domain -apexd -init } apex_metadata_file:dir no_w_dir_perms;
|
||||
neverallow { domain -apexd -init -kernel } apex_data_file:file no_w_file_perms;
|
||||
neverallow { domain -apexd -init -kernel } apex_metadata_file:file no_w_file_perms;
|
||||
neverallow { domain -apexd } apex_mnt_dir:lnk_file no_w_file_perms;
|
||||
|
||||
neverallow { domain -apexd -init -vold_prepare_subdirs } apex_module_data_file:dir no_w_dir_perms;
|
||||
neverallow { domain -apexd -init -vold_prepare_subdirs } apex_module_data_file:file no_w_file_perms;
|
||||
|
||||
neverallow { domain -apexd -init -vold_prepare_subdirs } apex_rollback_data_file:dir no_w_dir_perms;
|
||||
neverallow { domain -apexd -init -vold_prepare_subdirs } apex_rollback_data_file:file no_w_file_perms;
|
||||
|
||||
# only apexd can set apexd sysprop
|
||||
set_prop(apexd, apexd_prop)
|
||||
neverallow { domain -apexd -init } apexd_prop:property_service set;
|
||||
|
||||
# only apexd can write apex-info-list.xml
|
||||
neverallow { domain -apexd } apex_info_file:file no_w_file_perms;
|
||||
|
||||
# Only apexd and init should be allowed to manage /apex mounts
|
||||
# A note on otapreopt_chroot. It used to mount APEXes during postainstall stage of A/B OTAs,
|
||||
# but starting from S it just calls into apexd to prepare /apex for otapreoprt. Once the sepolicies
|
||||
# around otapreopt_chroot are cleaned up we should be able to remove it from the lists below.
|
||||
# dexopt_chroot_setup calls apexd to prepare /apex for Pre-reboot Dexopt, but it
|
||||
# needs to mount a tmpfs on /apex for apexd to work on.
|
||||
neverallow { domain -apexd -init -otapreopt_chroot } apex_mnt_dir:filesystem { mount unmount };
|
||||
neverallow { domain -apexd -dexopt_chroot_setup -init -otapreopt_chroot } apex_mnt_dir:dir mounton;
|
||||
|
||||
# Allow for use in postinstall
|
||||
allow apexd otapreopt_chroot:fd use;
|
||||
|
@ -212,3 +189,39 @@ set_prop(apexd, apex_ready_prop)
|
|||
|
||||
# Allow apexd to write to statsd.
|
||||
unix_socket_send(apexd, statsdw, statsd)
|
||||
|
||||
###
|
||||
### Neverallow rules
|
||||
###
|
||||
|
||||
neverallow { domain -apexd -init } apex_data_file:dir no_w_dir_perms;
|
||||
neverallow { domain -apexd -init } apex_metadata_file:dir no_w_dir_perms;
|
||||
neverallow { domain -apexd -init -kernel } apex_data_file:file no_w_file_perms;
|
||||
neverallow { domain -apexd -init -kernel } apex_metadata_file:file no_w_file_perms;
|
||||
neverallow { domain -apexd } apex_mnt_dir:lnk_file no_w_file_perms;
|
||||
|
||||
neverallow { domain -apexd -init -vold_prepare_subdirs } apex_module_data_file:dir no_w_dir_perms;
|
||||
neverallow { domain -apexd -init -vold_prepare_subdirs } apex_module_data_file:file no_w_file_perms;
|
||||
|
||||
neverallow { domain -apexd -init -vold_prepare_subdirs } apex_rollback_data_file:dir no_w_dir_perms;
|
||||
neverallow { domain -apexd -init -vold_prepare_subdirs } apex_rollback_data_file:file no_w_file_perms;
|
||||
|
||||
# only apexd can set apexd sysprop
|
||||
neverallow { domain -apexd -init } apexd_prop:property_service set;
|
||||
|
||||
# only apexd can write apex-info-list.xml
|
||||
neverallow { domain -apexd } apex_info_file:file no_w_file_perms;
|
||||
|
||||
# Only apexd and init should be allowed to manage /apex mounts
|
||||
# A note on otapreopt_chroot. It used to mount APEXes during postainstall stage of A/B OTAs,
|
||||
# but starting from S it just calls into apexd to prepare /apex for otapreoprt. Once the sepolicies
|
||||
# around otapreopt_chroot are cleaned up we should be able to remove it from the lists below.
|
||||
# dexopt_chroot_setup calls apexd to prepare /apex for Pre-reboot Dexopt, but it
|
||||
# needs to mount a tmpfs on /apex for apexd to work on.
|
||||
neverallow { domain -apexd -init -otapreopt_chroot } apex_mnt_dir:filesystem { mount unmount };
|
||||
neverallow { domain -apexd -dexopt_chroot_setup -init -otapreopt_chroot } apex_mnt_dir:dir mounton;
|
||||
|
||||
neverallow { domain -init -apexd -system_server -update_engine } apex_service:service_manager find;
|
||||
neverallow { domain -init -apexd -system_server -servicemanager -update_engine } apexd:binder call;
|
||||
|
||||
neverallow { domain userdebug_or_eng(`-crash_dump') } apexd:process ptrace;
|
||||
|
|
264
private/app.te
264
private/app.te
|
@ -84,28 +84,6 @@ allow { appdomain -sdk_sandbox_all } mnt_media_rw_file:dir search;
|
|||
allow appdomain system_server:udp_socket {
|
||||
connect getattr read recvfrom sendto write getopt setopt };
|
||||
|
||||
neverallow appdomain system_server:udp_socket {
|
||||
accept append bind create ioctl listen lock name_bind
|
||||
relabelfrom relabelto setattr shutdown };
|
||||
|
||||
# Transition to a non-app domain.
|
||||
# Exception for the shell and su domains, can transition to runas, etc.
|
||||
# Exception for crash_dump to allow for app crash reporting.
|
||||
# Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc)
|
||||
# to allow renderscript to create privileged executable files.
|
||||
# Exception for virtualizationmanager to allow running VMs as child processes.
|
||||
neverallow { appdomain -shell userdebug_or_eng(`-su') }
|
||||
{ domain -appdomain -crash_dump -rs -virtualizationmanager }:process { transition };
|
||||
neverallow { appdomain -shell userdebug_or_eng(`-su') }
|
||||
{ domain -appdomain }:process { dyntransition };
|
||||
|
||||
# Don't allow regular apps access to storage configuration properties.
|
||||
neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms;
|
||||
|
||||
# Don't allow apps reading /system/etc/font_fallback.xml
|
||||
dontaudit appdomain system_font_fallback_file:file no_rw_file_perms;
|
||||
neverallow appdomain system_font_fallback_file:file no_rw_file_perms;
|
||||
|
||||
# Allow to read sendbug.preferred.domain
|
||||
get_prop(appdomain, sendbug_config_prop)
|
||||
|
||||
|
@ -134,7 +112,6 @@ allow appdomain apex_art_data_file:file rx_file_perms;
|
|||
# Allow access to tombstones if an fd to one is given to you.
|
||||
# An app cannot open the tombstone itself because it lacks `open`.
|
||||
allow appdomain tombstone_data_file:file { getattr read };
|
||||
neverallow { appdomain -shell } tombstone_data_file:file ~{ getattr read };
|
||||
|
||||
# Execute the shell or other system executables.
|
||||
allow { appdomain -ephemeral_app -sdk_sandbox_all } shell_exec:file rx_file_perms;
|
||||
|
@ -505,6 +482,223 @@ allow appdomain audioserver_tmpfs:file { getattr map read write };
|
|||
allow appdomain system_server_tmpfs:file { getattr map read write };
|
||||
allow appdomain zygote_tmpfs:file { map read };
|
||||
|
||||
###
|
||||
### Neverallow rules
|
||||
###
|
||||
### These are things that Android apps should NEVER be able to do
|
||||
###
|
||||
|
||||
# Superuser capabilities.
|
||||
# bluetooth requires net_admin and wake_alarm. network stack app requires net_admin.
|
||||
neverallow { appdomain -bluetooth -network_stack } self:capability_class_set *;
|
||||
|
||||
# Block device access.
|
||||
neverallow appdomain dev_type:blk_file { read write };
|
||||
|
||||
# Note: Try expanding list of app domains in the future.
|
||||
neverallow { untrusted_app isolated_app shell } graphics_device:chr_file { read write };
|
||||
|
||||
neverallow { appdomain -nfc } nfc_device:chr_file
|
||||
{ read write };
|
||||
neverallow { appdomain -bluetooth } hci_attach_dev:chr_file
|
||||
{ read write };
|
||||
neverallow appdomain tee_device:chr_file { read write };
|
||||
|
||||
# Privileged netlink socket interfaces.
|
||||
neverallow { appdomain -network_stack }
|
||||
domain:{
|
||||
netlink_tcpdiag_socket
|
||||
netlink_nflog_socket
|
||||
netlink_xfrm_socket
|
||||
netlink_audit_socket
|
||||
netlink_dnrt_socket
|
||||
} *;
|
||||
|
||||
# These messages are broadcast messages from the kernel to userspace.
|
||||
# Do not allow the writing of netlink messages, which has been a source
|
||||
# of rooting vulns in the past.
|
||||
neverallow { appdomain -network_stack }
|
||||
domain:netlink_kobject_uevent_socket { write append };
|
||||
|
||||
# Sockets under /dev/socket that are not specifically typed.
|
||||
neverallow appdomain socket_device:sock_file write;
|
||||
|
||||
# Unix domain sockets.
|
||||
neverallow appdomain adbd_socket:sock_file write;
|
||||
neverallow { appdomain -radio } rild_socket:sock_file write;
|
||||
|
||||
# ptrace access to non-app domains.
|
||||
neverallow appdomain { domain -appdomain }:process ptrace;
|
||||
|
||||
# The Android security model guarantees the confidentiality and integrity
|
||||
# of application data and execution state. Ptrace bypasses those
|
||||
# confidentiality guarantees. Disallow ptrace access from system components
|
||||
# to apps. Crash_dump is excluded, as it needs ptrace access to
|
||||
# produce stack traces. llkd is excluded, as it needs ptrace access to
|
||||
# inspect stack traces for live lock conditions.
|
||||
|
||||
neverallow {
|
||||
domain
|
||||
-appdomain
|
||||
-crash_dump
|
||||
userdebug_or_eng(`-llkd')
|
||||
} appdomain:process ptrace;
|
||||
|
||||
# Read or write access to /proc/pid entries for any non-app domain.
|
||||
# A different form of hidepid=2 like protections
|
||||
neverallow appdomain { domain -appdomain }:file no_w_file_perms;
|
||||
neverallow { appdomain -shell } { domain -appdomain }:file no_rw_file_perms;
|
||||
|
||||
# signal access to non-app domains.
|
||||
# sigchld allowed for parent death notification.
|
||||
# signull allowed for kill(pid, 0) existence test.
|
||||
# All others prohibited.
|
||||
# -perfetto is to allow shell (which is an appdomain) to kill perfetto
|
||||
# (see private/shell.te).
|
||||
neverallow appdomain { domain -appdomain -perfetto }:process
|
||||
{ sigkill sigstop signal };
|
||||
|
||||
# Write to rootfs.
|
||||
neverallow appdomain rootfs:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
|
||||
# Write to /system.
|
||||
neverallow appdomain system_file_type:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
|
||||
# Write to entrypoint executables.
|
||||
neverallow appdomain exec_type:file
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
|
||||
# Write to system-owned parts of /data.
|
||||
# This is the default type for anything under /data not otherwise
|
||||
# specified in file_contexts. Define a different type for portions
|
||||
# that should be writable by apps.
|
||||
neverallow appdomain system_data_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
|
||||
# Write to various other parts of /data.
|
||||
neverallow appdomain drm_data_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
neverallow { appdomain -platform_app }
|
||||
apk_data_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
neverallow { appdomain -platform_app }
|
||||
apk_private_data_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
neverallow { appdomain -platform_app }
|
||||
apk_private_tmp_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
neverallow { appdomain -shell }
|
||||
shell_data_file:dir_file_class_set
|
||||
{ create setattr relabelfrom relabelto append unlink link rename };
|
||||
neverallow { appdomain -bluetooth }
|
||||
bluetooth_data_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
neverallow { domain -credstore -init } credstore_data_file:dir_file_class_set *;
|
||||
neverallow appdomain
|
||||
keystore_data_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
neverallow appdomain
|
||||
systemkeys_data_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
neverallow appdomain
|
||||
wifi_data_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
neverallow appdomain
|
||||
dhcp_data_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
|
||||
# access tmp apk files
|
||||
neverallow { appdomain -platform_app }
|
||||
apk_tmp_file:dir_file_class_set
|
||||
{ create write setattr relabelfrom relabelto append unlink link rename };
|
||||
|
||||
neverallow { appdomain -untrusted_app_all -platform_app -priv_app -isolated_app_all }
|
||||
{ apk_tmp_file apk_private_tmp_file }:dir_file_class_set *;
|
||||
|
||||
neverallow { untrusted_app_all isolated_app_all } { apk_tmp_file apk_private_tmp_file }:{ devfile_class_set dir fifo_file lnk_file sock_file } *;
|
||||
neverallow { untrusted_app_all isolated_app_all } { apk_tmp_file apk_private_tmp_file }:file ~{ getattr read };
|
||||
|
||||
# Access to factory files.
|
||||
neverallow appdomain efs_file:dir_file_class_set write;
|
||||
neverallow { appdomain -shell } efs_file:dir_file_class_set read;
|
||||
|
||||
# Write to various pseudo file systems.
|
||||
neverallow { appdomain -bluetooth -nfc }
|
||||
sysfs:dir_file_class_set write;
|
||||
neverallow appdomain
|
||||
proc:dir_file_class_set write;
|
||||
|
||||
# Access to syslog(2) or /proc/kmsg.
|
||||
neverallow appdomain kernel:system { syslog_read syslog_mod syslog_console };
|
||||
|
||||
# SELinux is not an API for apps to use
|
||||
neverallow { appdomain -shell } *:security { compute_av check_context };
|
||||
neverallow { appdomain -shell } *:netlink_selinux_socket *;
|
||||
|
||||
# Ability to perform any filesystem operation other than statfs(2).
|
||||
# i.e. no mount(2), unmount(2), etc.
|
||||
neverallow appdomain fs_type:filesystem ~getattr;
|
||||
|
||||
# prevent creation/manipulation of globally readable symlinks
|
||||
neverallow appdomain {
|
||||
apk_data_file
|
||||
cache_file
|
||||
cache_recovery_file
|
||||
dev_type
|
||||
rootfs
|
||||
system_file
|
||||
tmpfs
|
||||
}:lnk_file no_w_file_perms;
|
||||
|
||||
# Applications should use the activity model for receiving events
|
||||
neverallow {
|
||||
appdomain
|
||||
-shell # bugreport
|
||||
} input_device:chr_file ~getattr;
|
||||
|
||||
# Do not allow access to Bluetooth-related system properties except for a few allowed domains.
|
||||
# neverallow rules for access to Bluetooth-related data files are above.
|
||||
neverallow {
|
||||
appdomain
|
||||
-bluetooth
|
||||
-system_app
|
||||
} { bluetooth_audio_hal_prop bluetooth_a2dp_offload_prop bluetooth_prop exported_bluetooth_prop }:file create_file_perms;
|
||||
|
||||
# allow system_app to access Nfc-related system properties.
|
||||
set_prop(system_app, nfc_prop)
|
||||
|
||||
# allow system_app to access radio_config system properties.
|
||||
set_prop(system_app, radio_control_prop)
|
||||
|
||||
# Apps cannot access proc_uid_time_in_state
|
||||
neverallow appdomain proc_uid_time_in_state:file *;
|
||||
|
||||
# Apps cannot access proc_uid_concurrent_active_time
|
||||
neverallow appdomain proc_uid_concurrent_active_time:file *;
|
||||
|
||||
# Apps cannot access proc_uid_concurrent_policy_time
|
||||
neverallow appdomain proc_uid_concurrent_policy_time:file *;
|
||||
|
||||
# Apps cannot access proc_uid_cpupower
|
||||
neverallow appdomain proc_uid_cpupower:file *;
|
||||
|
||||
# Apps may not read /proc/net/{tcp,tcp6,udp,udp6}. These files leak information across the
|
||||
# application boundary. VPN apps may use the ConnectivityManager.getConnectionOwnerUid() API to
|
||||
# perform UID lookups.
|
||||
neverallow { appdomain -shell } proc_net_tcp_udp:file *;
|
||||
|
||||
# Apps cannot access bootstrap files. The bootstrap files are only for
|
||||
# extremely early processes (like init, etc.) which are started before
|
||||
# the runtime APEX is activated and Bionic libs are provided from there.
|
||||
# If app process accesses (or even load/execute) the bootstrap files,
|
||||
# it might cause problems such as ODR violation, etc.
|
||||
neverallow appdomain system_bootstrap_lib_file:file
|
||||
{ open read write append execute execute_no_trans map };
|
||||
neverallow appdomain system_bootstrap_lib_file:dir
|
||||
{ open read getattr search };
|
||||
|
||||
# Sensitive app domains are not allowed to execute from /data
|
||||
# to prevent persistence attacks and ensure all code is executed
|
||||
# from read-only locations.
|
||||
|
@ -559,3 +753,27 @@ neverallow {
|
|||
-untrusted_app_30
|
||||
-untrusted_app_32
|
||||
} apk_data_file:file { watch watch_reads };
|
||||
|
||||
neverallow appdomain system_server:udp_socket {
|
||||
accept append bind create ioctl listen lock name_bind
|
||||
relabelfrom relabelto setattr shutdown };
|
||||
|
||||
# Transition to a non-app domain.
|
||||
# Exception for the shell and su domains, can transition to runas, etc.
|
||||
# Exception for crash_dump to allow for app crash reporting.
|
||||
# Exception for renderscript binaries (/system/bin/bcc, /system/bin/ld.mc)
|
||||
# to allow renderscript to create privileged executable files.
|
||||
# Exception for virtualizationmanager to allow running VMs as child processes.
|
||||
neverallow { appdomain -shell userdebug_or_eng(`-su') }
|
||||
{ domain -appdomain -crash_dump -rs -virtualizationmanager }:process { transition };
|
||||
neverallow { appdomain -shell userdebug_or_eng(`-su') }
|
||||
{ domain -appdomain }:process { dyntransition };
|
||||
|
||||
# Don't allow regular apps access to storage configuration properties.
|
||||
neverallow { appdomain -mediaprovider_app } storage_config_prop:file no_rw_file_perms;
|
||||
|
||||
# Don't allow apps reading /system/etc/font_fallback.xml
|
||||
dontaudit appdomain system_font_fallback_file:file no_rw_file_perms;
|
||||
neverallow appdomain system_font_fallback_file:file no_rw_file_perms;
|
||||
|
||||
neverallow { appdomain -shell } tombstone_data_file:file ~{ getattr read };
|
||||
|
|
|
@ -8,4 +8,28 @@ with_asan(`
|
|||
|
||||
# We need to signal a reboot when done.
|
||||
set_prop(asan_extract, powerctl_prop)
|
||||
|
||||
# Allow asan_extract to execute itself using #!/system/bin/sh
|
||||
allow asan_extract shell_exec:file rx_file_perms;
|
||||
|
||||
# We execute log, rm, gzip and tar.
|
||||
allow asan_extract toolbox_exec:file rx_file_perms;
|
||||
allow asan_extract system_file:file execute_no_trans;
|
||||
|
||||
# asan_extract deletes old /data/lib.
|
||||
allow asan_extract system_file:dir { open read remove_name rmdir write };
|
||||
allow asan_extract system_file:file unlink;
|
||||
|
||||
# asan_extract untars ASAN libraries into /data.
|
||||
allow asan_extract system_data_file:dir create_dir_perms ;
|
||||
allow asan_extract system_data_file:{ file lnk_file } create_file_perms ;
|
||||
|
||||
# Relabel the libraries with restorecon.
|
||||
allow asan_extract file_contexts_file:file r_file_perms;
|
||||
allow asan_extract system_data_file:{ dir file } relabelfrom;
|
||||
allow asan_extract system_file:dir { relabelto setattr };
|
||||
allow asan_extract system_file:file relabelto;
|
||||
|
||||
# Restorecon will actually already try to run with sanitized libraries (libpackagelistparser).
|
||||
allow asan_extract system_data_file:file execute;
|
||||
')
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
# audioserver - audio services daemon
|
||||
|
||||
type audioserver_exec, exec_type, file_type, system_file_type;
|
||||
typeattribute audioserver coredomain;
|
||||
|
||||
type audioserver_exec, exec_type, file_type, system_file_type;
|
||||
init_daemon_domain(audioserver)
|
||||
tmpfs_domain(audioserver)
|
||||
|
||||
|
@ -79,6 +78,20 @@ userdebug_or_eng(`
|
|||
# Allow write access to log tag property
|
||||
set_prop(audioserver, log_tag_prop);
|
||||
|
||||
# Allow audioserver to signal audio HAL processes and dump their stacks.
|
||||
allow audioserver hal_audio_server:process signal;
|
||||
|
||||
# Allow audioserver to access sensorservice.
|
||||
allow audioserver sensorservice_service:service_manager find;
|
||||
allow audioserver system_server:unix_stream_socket { read write };
|
||||
|
||||
# Allow using wake locks
|
||||
wakelock_use(audioserver)
|
||||
|
||||
# Allow reading audio config props, e.g. af.fast_track_multiplier
|
||||
get_prop(audioserver, audio_config_prop)
|
||||
get_prop(audioserver, system_audio_config_prop)
|
||||
|
||||
###
|
||||
### neverallow rules
|
||||
###
|
||||
|
@ -99,10 +112,3 @@ neverallow audioserver { file_type fs_type }:file execute_no_trans;
|
|||
# https://android-developers.googleblog.com/2016/05/hardening-media-stack.html
|
||||
neverallow audioserver domain:{ udp_socket rawip_socket } *;
|
||||
neverallow audioserver { domain userdebug_or_eng(`-su') }:tcp_socket *;
|
||||
|
||||
# Allow using wake locks
|
||||
wakelock_use(audioserver)
|
||||
|
||||
# Allow reading audio config props, e.g. af.fast_track_multiplier
|
||||
get_prop(audioserver, audio_config_prop)
|
||||
get_prop(audioserver, system_audio_config_prop)
|
||||
|
|
|
@ -21,3 +21,46 @@ r_dir_file(bootanim, bootanim_data_file)
|
|||
|
||||
# Allow accessing vendor apex for EGL/GLES
|
||||
allow bootanim vendor_apex_metadata_file:dir r_dir_perms;
|
||||
|
||||
hal_client_domain(bootanim, hal_configstore)
|
||||
hal_client_domain(bootanim, hal_graphics_allocator)
|
||||
hal_client_domain(bootanim, hal_graphics_composer)
|
||||
|
||||
binder_use(bootanim)
|
||||
binder_call(bootanim, surfaceflinger)
|
||||
binder_call(bootanim, audioserver)
|
||||
|
||||
hwbinder_use(bootanim)
|
||||
|
||||
allow bootanim gpu_device:chr_file rw_file_perms;
|
||||
allow bootanim gpu_device:dir r_dir_perms;
|
||||
allow bootanim sysfs_gpu:file r_file_perms;
|
||||
|
||||
# /oem access
|
||||
allow bootanim oemfs:dir r_dir_perms;
|
||||
# boot animations on oem are stored with specific label
|
||||
allow bootanim bootanim_oem_file:file r_file_perms;
|
||||
|
||||
allow bootanim audio_device:dir r_dir_perms;
|
||||
allow bootanim audio_device:chr_file rw_file_perms;
|
||||
|
||||
allow bootanim audioserver_service:service_manager find;
|
||||
allow bootanim surfaceflinger_service:service_manager find;
|
||||
allow bootanim surfaceflinger:unix_stream_socket { read write };
|
||||
|
||||
# Allow access to ion memory allocation device
|
||||
allow bootanim ion_device:chr_file rw_file_perms;
|
||||
|
||||
# Allow access to DMA-BUF system heap
|
||||
allow bootanim dmabuf_system_heap_device:chr_file r_file_perms;
|
||||
|
||||
allow bootanim hal_graphics_allocator:fd use;
|
||||
|
||||
# Fences
|
||||
allow bootanim hal_graphics_composer:fd use;
|
||||
|
||||
# Read access to pseudo filesystems.
|
||||
allow bootanim proc_meminfo:file r_file_perms;
|
||||
|
||||
# System file accesses.
|
||||
allow bootanim system_file:dir r_dir_perms;
|
||||
|
|
|
@ -10,6 +10,39 @@ set_prop(bootstat, bootloader_boot_reason_prop)
|
|||
set_prop(bootstat, system_boot_reason_prop)
|
||||
set_prop(bootstat, last_boot_reason_prop)
|
||||
|
||||
read_runtime_log_tags(bootstat)
|
||||
|
||||
# Allow persistent storage in /data/misc/bootstat.
|
||||
allow bootstat bootstat_data_file:dir rw_dir_perms;
|
||||
allow bootstat bootstat_data_file:file create_file_perms;
|
||||
|
||||
allow bootstat metadata_file:dir search;
|
||||
allow bootstat metadata_bootstat_file:dir rw_dir_perms;
|
||||
allow bootstat metadata_bootstat_file:file create_file_perms;
|
||||
|
||||
# ToDo: TBI move access for the following to a system health HAL
|
||||
|
||||
# Allow access to /sys/fs/pstore/ and syslog
|
||||
allow bootstat pstorefs:dir search;
|
||||
allow bootstat pstorefs:file r_file_perms;
|
||||
allow bootstat kernel:system syslog_read;
|
||||
|
||||
# Allow access to reading the logs to read aspects of system health
|
||||
read_logd(bootstat)
|
||||
|
||||
# Allow bootstat write to statsd.
|
||||
unix_socket_send(bootstat, statsdw, statsd)
|
||||
|
||||
###
|
||||
### Neverallow rules
|
||||
###
|
||||
|
||||
neverallow {
|
||||
domain
|
||||
-bootstat
|
||||
-init
|
||||
} system_boot_reason_prop:property_service set;
|
||||
|
||||
neverallow {
|
||||
domain
|
||||
-bootanim
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
typeattribute bufferhubd coredomain;
|
||||
|
||||
init_daemon_domain(bufferhubd)
|
||||
|
||||
hal_client_domain(bufferhubd, hal_graphics_allocator)
|
||||
|
||||
# TODO(b/112338294): remove these after migrate to Binder
|
||||
pdx_server(bufferhubd, bufferhub_client)
|
||||
pdx_client(bufferhubd, performance_client)
|
||||
|
||||
# Access the GPU.
|
||||
allow bufferhubd gpu_device:chr_file rw_file_perms;
|
||||
|
||||
# Access /dev/ion
|
||||
allow bufferhubd ion_device:chr_file r_file_perms;
|
||||
|
||||
# Receive sync fence FDs from hal_omx_server. Note that hal_omx_server never directly
|
||||
# connects to bufferhubd via PDX. Instead, a VR app acts as a bridge between
|
||||
# those two: it talks to hal_omx_server via Binder and talks to bufferhubd via PDX.
|
||||
# Thus, there is no need to use pdx_client macro.
|
||||
allow bufferhubd hal_omx_server:fd use;
|
||||
|
||||
# Codec2 is similar to OMX
|
||||
allow bufferhubd hal_codec2_server:fd use;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
typeattribute cameraserver coredomain;
|
||||
|
||||
typeattribute cameraserver camera_service_server;
|
||||
typeattribute cameraserver coredomain;
|
||||
|
||||
init_daemon_domain(cameraserver)
|
||||
tmpfs_domain(cameraserver)
|
||||
|
@ -8,3 +7,86 @@ tmpfs_domain(cameraserver)
|
|||
allow cameraserver gpu_device:chr_file rw_file_perms;
|
||||
allow cameraserver gpu_device:dir r_dir_perms;
|
||||
allow cameraserver virtual_camera:binder call;
|
||||
|
||||
binder_use(cameraserver)
|
||||
binder_call(cameraserver, binderservicedomain)
|
||||
binder_call(cameraserver, appdomain)
|
||||
binder_service(cameraserver)
|
||||
|
||||
hal_client_domain(cameraserver, hal_camera)
|
||||
|
||||
hal_client_domain(cameraserver, hal_graphics_allocator)
|
||||
|
||||
allow cameraserver ion_device:chr_file rw_file_perms;
|
||||
allow cameraserver dmabuf_system_heap_device:chr_file r_file_perms;
|
||||
|
||||
# Talk with graphics composer fences
|
||||
allow cameraserver hal_graphics_composer:fd use;
|
||||
|
||||
add_service(cameraserver, cameraserver_service)
|
||||
add_service(cameraserver, fwk_camera_service)
|
||||
add_hwservice(cameraserver, fwk_camera_hwservice)
|
||||
|
||||
allow cameraserver activity_service:service_manager find;
|
||||
allow cameraserver appops_service:service_manager find;
|
||||
allow cameraserver audioserver_service:service_manager find;
|
||||
allow cameraserver batterystats_service:service_manager find;
|
||||
allow cameraserver cameraproxy_service:service_manager find;
|
||||
allow cameraserver mediaserver_service:service_manager find;
|
||||
allow cameraserver package_native_service:service_manager find;
|
||||
allow cameraserver permission_checker_service:service_manager find;
|
||||
allow cameraserver processinfo_service:service_manager find;
|
||||
allow cameraserver scheduling_policy_service:service_manager find;
|
||||
allow cameraserver sensor_privacy_service:service_manager find;
|
||||
allow cameraserver surfaceflinger_service:service_manager find;
|
||||
|
||||
allow cameraserver hidl_token_hwservice:hwservice_manager find;
|
||||
allow cameraserver hal_camera_service:service_manager find;
|
||||
allow cameraserver virtual_camera_service:service_manager find;
|
||||
|
||||
# Allow to talk with surfaceflinger through unix stream socket
|
||||
allow cameraserver surfaceflinger:unix_stream_socket { read write };
|
||||
|
||||
# Allow shell commands from ADB for CTS testing/dumping
|
||||
allow cameraserver adbd:fd use;
|
||||
allow cameraserver adbd:unix_stream_socket { read write };
|
||||
allow cameraserver shell:fd use;
|
||||
allow cameraserver shell:unix_stream_socket { read write };
|
||||
allow cameraserver shell:fifo_file { read write };
|
||||
|
||||
# allow self to set SCHED_FIFO
|
||||
allow cameraserver self:global_capability_class_set sys_nice;
|
||||
|
||||
# Allow to talk with media codec
|
||||
allow cameraserver mediametrics_service:service_manager find;
|
||||
hal_client_domain(cameraserver, hal_codec2)
|
||||
hal_client_domain(cameraserver, hal_omx)
|
||||
hal_client_domain(cameraserver, hal_allocator)
|
||||
|
||||
# Allow shell commands from ADB for CTS testing/dumping
|
||||
userdebug_or_eng(`
|
||||
allow cameraserver su:fd use;
|
||||
allow cameraserver su:fifo_file { read write };
|
||||
allow cameraserver su:unix_stream_socket { read write };
|
||||
')
|
||||
|
||||
###
|
||||
### neverallow rules
|
||||
###
|
||||
|
||||
# cameraserver should never execute any executable without a
|
||||
# domain transition
|
||||
neverallow cameraserver { file_type fs_type }:file execute_no_trans;
|
||||
|
||||
# The goal of the mediaserver split is to place media processing code into
|
||||
# restrictive sandboxes with limited responsibilities and thus limited
|
||||
# permissions. Example: Audioserver is only responsible for controlling audio
|
||||
# hardware and processing audio content. Cameraserver does the same for camera
|
||||
# hardware/content. Etc.
|
||||
#
|
||||
# Media processing code is inherently risky and thus should have limited
|
||||
# permissions and be isolated from the rest of the system and network.
|
||||
# Lengthier explanation here:
|
||||
# https://android-developers.googleblog.com/2016/05/hardening-media-stack.html
|
||||
neverallow cameraserver domain:{ udp_socket rawip_socket } *;
|
||||
neverallow cameraserver { domain userdebug_or_eng(`-su') }:tcp_socket *;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
typeattribute charger coredomain;
|
||||
|
||||
# The system charger is a client of HIDL health HAL.
|
||||
hal_client_domain(charger, hal_health)
|
||||
|
||||
# charger needs to tell init to continue the boot
|
||||
# process when running in charger mode.
|
||||
# The system charger needs to be allowed to set these properties on legacy devices.
|
||||
|
|
|
@ -6,6 +6,44 @@ get_prop(charger_type, charger_config_prop)
|
|||
# get minui properties
|
||||
get_prop(charger_type, recovery_config_prop)
|
||||
|
||||
# Write to /dev/kmsg
|
||||
allow charger_type kmsg_device:chr_file rw_file_perms;
|
||||
|
||||
# Read access to pseudo filesystems.
|
||||
r_dir_file(charger_type, rootfs)
|
||||
r_dir_file(charger_type, cgroup)
|
||||
r_dir_file(charger_type, cgroup_v2)
|
||||
|
||||
# Allow to read /sys/class/power_supply directory
|
||||
allow charger_type sysfs_type:dir r_dir_perms;
|
||||
|
||||
allow charger_type self:global_capability_class_set {
|
||||
sys_boot
|
||||
sys_tty_config
|
||||
};
|
||||
|
||||
wakelock_use(charger_type)
|
||||
|
||||
allow charger_type self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
|
||||
|
||||
# Read/write to /sys/power/state
|
||||
allow charger_type sysfs_power:file rw_file_perms;
|
||||
|
||||
r_dir_file(charger_type, sysfs_batteryinfo)
|
||||
|
||||
# Read /sys/fs/pstore/console-ramoops
|
||||
# Don't worry about overly broad permissions for now, as there's
|
||||
# only one file in /sys/fs/pstore
|
||||
allow charger_type pstorefs:dir r_dir_perms;
|
||||
allow charger_type pstorefs:file r_file_perms;
|
||||
|
||||
allow charger_type graphics_device:dir r_dir_perms;
|
||||
allow charger_type graphics_device:chr_file rw_file_perms;
|
||||
allow charger_type input_device:dir r_dir_perms;
|
||||
allow charger_type input_device:chr_file r_file_perms;
|
||||
allow charger_type tty_device:chr_file rw_file_perms;
|
||||
allow charger_type proc_sysrq:file rw_file_perms;
|
||||
|
||||
### Neverallow rules for charger properties
|
||||
|
||||
# charger_config_prop: Only init and vendor_init is allowed to set it
|
||||
|
|
3
private/charger_vendor.te
Normal file
3
private/charger_vendor.te
Normal file
|
@ -0,0 +1,3 @@
|
|||
hal_server_domain(charger_vendor, hal_health)
|
||||
|
||||
typeattribute charger_vendor bpfdomain;
|
|
@ -39,10 +39,84 @@ allow crash_dump system_bootstrap_lib_file:file r_file_perms;
|
|||
# Read Vendor APEX directories
|
||||
allow crash_dump vendor_apex_metadata_file:dir { getattr search };
|
||||
|
||||
# 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.
|
||||
dontaudit crash_dump self:global_capability_class_set { sys_ptrace };
|
||||
|
||||
userdebug_or_eng(`
|
||||
allow crash_dump logd:process { ptrace signal sigchld sigstop sigkill };
|
||||
|
||||
# Let crash_dump write to /dev/kmsg_debug crashes that happen before logd comes up.
|
||||
allow crash_dump kmsg_debug_device:chr_file { open append };
|
||||
')
|
||||
|
||||
# Use inherited file descriptors
|
||||
allow crash_dump domain:fd use;
|
||||
|
||||
# Read/write IPC pipes inherited from crashing processes.
|
||||
allow crash_dump domain:fifo_file { read write };
|
||||
|
||||
# Append to pipes given to us by processes requesting dumps (e.g. dumpstate)
|
||||
allow crash_dump domain:fifo_file { append };
|
||||
|
||||
# Read information from /proc/$PID.
|
||||
allow crash_dump domain:process getattr;
|
||||
|
||||
r_dir_file(crash_dump, domain)
|
||||
allow crash_dump exec_type:file r_file_perms;
|
||||
|
||||
# Read /data/dalvik-cache.
|
||||
allow crash_dump dalvikcache_data_file:dir { search getattr };
|
||||
allow crash_dump dalvikcache_data_file:file r_file_perms;
|
||||
|
||||
# Read APEX data directories.
|
||||
allow crash_dump apex_module_data_file:dir { getattr search };
|
||||
|
||||
# Read uptime
|
||||
allow crash_dump proc_uptime:file r_file_perms;
|
||||
|
||||
# Read APK files.
|
||||
r_dir_file(crash_dump, apk_data_file);
|
||||
|
||||
# Read all /vendor
|
||||
r_dir_file(crash_dump, { vendor_file same_process_hal_file })
|
||||
|
||||
# Read all /data/local/tests
|
||||
r_dir_file(crash_dump, shell_test_data_file)
|
||||
|
||||
# Talk to tombstoned
|
||||
unix_socket_connect(crash_dump, tombstoned_crash, tombstoned)
|
||||
|
||||
# Talk to ActivityManager.
|
||||
unix_socket_connect(crash_dump, system_ndebug, system_server)
|
||||
|
||||
# Append to ANR files.
|
||||
allow crash_dump anr_data_file:file { append getattr };
|
||||
|
||||
# Append to tombstone files.
|
||||
allow crash_dump tombstone_data_file:file { append getattr };
|
||||
|
||||
# crash_dump writes out logcat logs at the bottom of tombstones,
|
||||
# which is super useful in some cases.
|
||||
unix_socket_connect(crash_dump, logdr, logd)
|
||||
|
||||
# Crash dump is not intended to access the following files. Since these
|
||||
# are WAI, suppress the denials to clean up the logs.
|
||||
dontaudit crash_dump {
|
||||
core_data_file_type
|
||||
vendor_file_type
|
||||
}:dir search;
|
||||
dontaudit crash_dump system_data_file:{ lnk_file file } read;
|
||||
dontaudit crash_dump property_type:file read;
|
||||
|
||||
###
|
||||
### neverallow assertions
|
||||
###
|
||||
|
||||
# A domain transition must occur for crash_dump to get the privileges needed to trace the process.
|
||||
# Do not allow the execution of crash_dump without a domain transition.
|
||||
neverallow domain crash_dump_exec:file execute_no_trans;
|
||||
|
||||
# sigchld not explicitly forbidden since it's part of the
|
||||
# domain-transition-on-exec macros, and is by itself not sensitive
|
||||
neverallow crash_dump {
|
||||
|
|
|
@ -11,3 +11,19 @@ hal_client_domain(credstore, hal_keymint)
|
|||
# credstore needs to get keys from the RKPD
|
||||
get_prop(credstore, remote_prov_prop)
|
||||
allow credstore remote_provisioning_service:service_manager find;
|
||||
|
||||
binder_use(credstore)
|
||||
binder_service(credstore)
|
||||
binder_call(credstore, system_server)
|
||||
|
||||
allow credstore credstore_data_file:dir create_dir_perms;
|
||||
allow credstore credstore_data_file:file create_file_perms;
|
||||
|
||||
add_service(credstore, credstore_service)
|
||||
allow credstore sec_key_att_app_id_provider_service:service_manager find;
|
||||
allow credstore dropbox_service:service_manager find;
|
||||
allow credstore authorization_service:service_manager find;
|
||||
allow credstore keystore:keystore2 get_auth_token;
|
||||
|
||||
r_dir_file(credstore, cgroup)
|
||||
r_dir_file(credstore, cgroup_v2)
|
||||
|
|
|
@ -5,3 +5,29 @@ type_transition dhcp system_data_file:{ dir file } dhcp_data_file;
|
|||
|
||||
set_prop(dhcp, dhcp_prop)
|
||||
set_prop(dhcp, pan_result_prop)
|
||||
|
||||
net_domain(dhcp)
|
||||
|
||||
allow dhcp cgroup:dir { create write add_name };
|
||||
allow dhcp cgroup_v2:dir { create write add_name };
|
||||
allow dhcp self:global_capability_class_set { setgid setuid net_admin net_raw net_bind_service };
|
||||
allow dhcp self:packet_socket create_socket_perms_no_ioctl;
|
||||
allow dhcp self:netlink_route_socket nlmsg_write;
|
||||
allow dhcp shell_exec:file rx_file_perms;
|
||||
allow dhcp system_file:file rx_file_perms;
|
||||
not_full_treble(`allow dhcp vendor_file:file rx_file_perms;')
|
||||
|
||||
# dhcpcd runs dhcpcd-hooks/*, which runs getprop / setprop (toolbox_exec)
|
||||
allow dhcp toolbox_exec:file rx_file_perms;
|
||||
|
||||
# For /proc/sys/net/ipv4/conf/*/promote_secondaries
|
||||
allow dhcp proc_net_type:file write;
|
||||
|
||||
allow dhcp dhcp_data_file:dir create_dir_perms;
|
||||
allow dhcp dhcp_data_file:file create_file_perms;
|
||||
|
||||
# PAN connections
|
||||
allow dhcp netd:fd use;
|
||||
allow dhcp netd:fifo_file rw_file_perms;
|
||||
allow dhcp netd:{ dgram_socket_class_set unix_stream_socket } { read write };
|
||||
allow dhcp netd:{ netlink_kobject_uevent_socket netlink_route_socket netlink_nflog_socket } { read write };
|
||||
|
|
|
@ -1 +1,23 @@
|
|||
typeattribute dnsmasq coredomain;
|
||||
|
||||
net_domain(dnsmasq)
|
||||
allowxperm dnsmasq self:udp_socket ioctl priv_sock_ioctls;
|
||||
|
||||
# TODO: Run with dhcp group to avoid need for dac_override.
|
||||
allow dnsmasq self:global_capability_class_set { dac_override dac_read_search };
|
||||
|
||||
allow dnsmasq self:global_capability_class_set { net_admin net_raw net_bind_service setgid setuid };
|
||||
|
||||
allow dnsmasq dhcp_data_file:dir w_dir_perms;
|
||||
allow dnsmasq dhcp_data_file:file create_file_perms;
|
||||
|
||||
# Inherit and use open files from netd.
|
||||
allow dnsmasq netd:fd use;
|
||||
allow dnsmasq netd:fifo_file { getattr read write };
|
||||
# TODO: Investigate whether these inherited sockets should be closed on exec.
|
||||
allow dnsmasq netd:netlink_kobject_uevent_socket { read write };
|
||||
allow dnsmasq netd:netlink_nflog_socket { read write };
|
||||
allow dnsmasq netd:netlink_route_socket { read write };
|
||||
allow dnsmasq netd:unix_stream_socket { getattr read write };
|
||||
allow dnsmasq netd:unix_dgram_socket { read write };
|
||||
allow dnsmasq netd:udp_socket { read write };
|
||||
|
|
1300
private/domain.te
1300
private/domain.te
File diff suppressed because it is too large
Load diff
|
@ -7,3 +7,63 @@ type_transition drmserver apk_data_file:sock_file drmserver_socket;
|
|||
typeattribute drmserver_socket coredomain_socket;
|
||||
|
||||
get_prop(drmserver, drm_service_config_prop)
|
||||
|
||||
typeattribute drmserver mlstrustedsubject;
|
||||
|
||||
net_domain(drmserver)
|
||||
|
||||
# Perform Binder IPC to system server.
|
||||
binder_use(drmserver)
|
||||
binder_call(drmserver, system_server)
|
||||
binder_call(drmserver, appdomain)
|
||||
binder_call(drmserver, mediametrics)
|
||||
binder_service(drmserver)
|
||||
# Inherit or receive open files from system_server.
|
||||
allow drmserver system_server:fd use;
|
||||
|
||||
# Perform Binder IPC to mediaserver
|
||||
binder_call(drmserver, mediaserver)
|
||||
|
||||
allow drmserver { sdcard_type fuse }:dir search;
|
||||
allow drmserver drm_data_file:dir create_dir_perms;
|
||||
allow drmserver drm_data_file:file create_file_perms;
|
||||
allow drmserver { app_data_file privapp_data_file }:file { read write getattr map };
|
||||
allow drmserver { sdcard_type fuse }:file { read write getattr map };
|
||||
r_dir_file(drmserver, efs_file)
|
||||
|
||||
# /data/app/tlcd_sock socket file.
|
||||
# Clearly, /data/app is the most logical place to create a socket. Not.
|
||||
allow drmserver apk_data_file:dir rw_dir_perms;
|
||||
auditallow drmserver apk_data_file:dir { add_name write };
|
||||
allow drmserver drmserver_socket:sock_file create_file_perms;
|
||||
auditallow drmserver drmserver_socket:sock_file create;
|
||||
# Delete old socket file if present.
|
||||
allow drmserver apk_data_file:sock_file unlink;
|
||||
|
||||
# After taking a video, drmserver looks at the video file.
|
||||
r_dir_file(drmserver, media_rw_data_file)
|
||||
|
||||
# Read resources from open apk files passed over Binder.
|
||||
allow drmserver apk_data_file:file { read getattr map };
|
||||
allow drmserver asec_apk_file:file { read getattr map };
|
||||
allow drmserver ringtone_file:file { read getattr map };
|
||||
|
||||
# Read /data/data/com.android.providers.telephony files passed over Binder.
|
||||
allow drmserver radio_data_file:file { read getattr map };
|
||||
|
||||
# /oem access
|
||||
allow drmserver oemfs:dir search;
|
||||
allow drmserver oemfs:file r_file_perms;
|
||||
|
||||
# overlay package access
|
||||
allow drmserver vendor_overlay_file:file { read map };
|
||||
|
||||
add_service(drmserver, drmserver_service)
|
||||
allow drmserver permission_service:service_manager find;
|
||||
allow drmserver mediametrics_service:service_manager find;
|
||||
|
||||
selinux_check_access(drmserver)
|
||||
|
||||
r_dir_file(drmserver, cgroup)
|
||||
r_dir_file(drmserver, cgroup_v2)
|
||||
r_dir_file(drmserver, system_file)
|
||||
|
|
|
@ -151,3 +151,407 @@ allow dumpstate system_dlkm_file:dir getattr;
|
|||
|
||||
# Allow dumpstate to execute derive_sdk in its own domain
|
||||
domain_auto_trans(dumpstate, derive_sdk_exec, derive_sdk)
|
||||
|
||||
net_domain(dumpstate)
|
||||
binder_use(dumpstate)
|
||||
wakelock_use(dumpstate)
|
||||
|
||||
# Allow setting process priority, protect from OOM killer, and dropping
|
||||
# privileges by switching UID / GID
|
||||
allow dumpstate self:global_capability_class_set { setuid setgid sys_resource };
|
||||
|
||||
# Allow dumpstate to scan through /proc/pid for all processes
|
||||
r_dir_file(dumpstate, domain)
|
||||
|
||||
allow dumpstate self:global_capability_class_set {
|
||||
# Send signals to processes
|
||||
kill
|
||||
# Run iptables
|
||||
net_raw
|
||||
net_admin
|
||||
};
|
||||
|
||||
# Allow executing files on system, such as:
|
||||
# /system/bin/toolbox
|
||||
# /system/bin/logcat
|
||||
# /system/bin/dumpsys
|
||||
allow dumpstate system_file:file execute_no_trans;
|
||||
not_full_treble(`allow dumpstate vendor_file:file execute_no_trans;')
|
||||
allow dumpstate toolbox_exec:file rx_file_perms;
|
||||
|
||||
# hidl searches for files in /system/lib(64)/hw/
|
||||
allow dumpstate system_file:dir r_dir_perms;
|
||||
|
||||
# Create and write into /data/anr/
|
||||
allow dumpstate self:global_capability_class_set { dac_override dac_read_search chown fowner fsetid };
|
||||
allow dumpstate anr_data_file:dir rw_dir_perms;
|
||||
allow dumpstate anr_data_file:file create_file_perms;
|
||||
|
||||
# Allow reading /data/system/uiderrors.txt
|
||||
# TODO: scope this down.
|
||||
allow dumpstate system_data_file:file r_file_perms;
|
||||
|
||||
# Allow dumpstate to append into apps' private files.
|
||||
allow dumpstate { privapp_data_file app_data_file }:file append;
|
||||
|
||||
# Read dmesg
|
||||
allow dumpstate self:global_capability2_class_set syslog;
|
||||
allow dumpstate kernel:system syslog_read;
|
||||
|
||||
# Read /sys/fs/pstore/console-ramoops
|
||||
allow dumpstate pstorefs:dir r_dir_perms;
|
||||
allow dumpstate pstorefs:file r_file_perms;
|
||||
|
||||
# Get process attributes
|
||||
allow dumpstate domain:process getattr;
|
||||
|
||||
# Signal java processes to dump their stack
|
||||
allow dumpstate { appdomain system_server zygote app_zygote }:process signal;
|
||||
|
||||
# Signal native processes to dump their stack.
|
||||
allow dumpstate {
|
||||
# This list comes from native_processes_to_dump in dumputils/dump_utils.c
|
||||
audioserver
|
||||
cameraserver
|
||||
drmserver
|
||||
inputflinger
|
||||
mediadrmserver
|
||||
mediaextractor
|
||||
mediametrics
|
||||
mediaserver
|
||||
mediaswcodec
|
||||
sdcardd
|
||||
surfaceflinger
|
||||
vold
|
||||
|
||||
# This list comes from hal_interfaces_to_dump in dumputils/dump_utils.c
|
||||
evsmanagerd
|
||||
hal_audio_server
|
||||
hal_audiocontrol_server
|
||||
hal_bluetooth_server
|
||||
hal_broadcastradio_server
|
||||
hal_camera_server
|
||||
hal_codec2_server
|
||||
hal_drm_server
|
||||
hal_evs_server
|
||||
hal_face_server
|
||||
hal_fingerprint_server
|
||||
hal_graphics_allocator_server
|
||||
hal_graphics_composer_server
|
||||
hal_health_server
|
||||
hal_input_processor_server
|
||||
hal_neuralnetworks_server
|
||||
hal_omx_server
|
||||
hal_power_server
|
||||
hal_power_stats_server
|
||||
hal_sensors_server
|
||||
hal_thermal_server
|
||||
hal_vehicle_server
|
||||
hal_vr_server
|
||||
system_suspend_server
|
||||
}:process signal;
|
||||
|
||||
# Connect to tombstoned to intercept dumps.
|
||||
unix_socket_connect(dumpstate, tombstoned_intercept, tombstoned)
|
||||
|
||||
# Access to /sys
|
||||
allow dumpstate sysfs_type:dir r_dir_perms;
|
||||
|
||||
allow dumpstate {
|
||||
sysfs_devices_block
|
||||
sysfs_dm
|
||||
sysfs_loop
|
||||
sysfs_usb
|
||||
sysfs_zram
|
||||
}:file r_file_perms;
|
||||
|
||||
# Ignore other file access under /sys.
|
||||
dontaudit dumpstate sysfs:file r_file_perms;
|
||||
|
||||
# Other random bits of data we want to collect
|
||||
no_debugfs_restriction(`
|
||||
allow dumpstate debugfs:file r_file_perms;
|
||||
auditallow dumpstate debugfs:file r_file_perms;
|
||||
|
||||
allow dumpstate debugfs_mmc:file r_file_perms;
|
||||
')
|
||||
|
||||
# df for
|
||||
allow dumpstate {
|
||||
block_device
|
||||
cache_file
|
||||
metadata_file
|
||||
rootfs
|
||||
selinuxfs
|
||||
storage_file
|
||||
tmpfs
|
||||
}:dir { search getattr };
|
||||
allow dumpstate fuse_device:chr_file getattr;
|
||||
allow dumpstate { dm_device cache_block_device }:blk_file getattr;
|
||||
allow dumpstate { cache_file rootfs }:lnk_file { getattr read };
|
||||
|
||||
# Read /dev/cpuctl and /dev/cpuset
|
||||
r_dir_file(dumpstate, cgroup)
|
||||
r_dir_file(dumpstate, cgroup_v2)
|
||||
|
||||
# Allow dumpstate to make binder calls to any binder service
|
||||
binder_call(dumpstate, binderservicedomain)
|
||||
binder_call(dumpstate, { appdomain artd netd wificond })
|
||||
|
||||
# Allow dumpstate to call dump() on specific hals.
|
||||
dump_hal(hal_audio)
|
||||
dump_hal(hal_audiocontrol)
|
||||
dump_hal(hal_authgraph)
|
||||
dump_hal(hal_authsecret)
|
||||
dump_hal(hal_bluetooth)
|
||||
dump_hal(hal_broadcastradio)
|
||||
dump_hal(hal_camera)
|
||||
dump_hal(hal_codec2)
|
||||
dump_hal(hal_contexthub)
|
||||
dump_hal(hal_drm)
|
||||
dump_hal(hal_dumpstate)
|
||||
dump_hal(hal_evs)
|
||||
dump_hal(hal_face)
|
||||
dump_hal(hal_fingerprint)
|
||||
dump_hal(hal_gnss)
|
||||
dump_hal(hal_graphics_allocator)
|
||||
dump_hal(hal_graphics_composer)
|
||||
dump_hal(hal_health)
|
||||
dump_hal(hal_identity)
|
||||
dump_hal(hal_input_processor)
|
||||
dump_hal(hal_keymint)
|
||||
dump_hal(hal_light)
|
||||
dump_hal(hal_memtrack)
|
||||
dump_hal(hal_neuralnetworks)
|
||||
dump_hal(hal_nfc)
|
||||
dump_hal(hal_oemlock)
|
||||
dump_hal(hal_power)
|
||||
dump_hal(hal_power_stats)
|
||||
dump_hal(hal_rebootescrow)
|
||||
dump_hal(hal_secretkeeper)
|
||||
dump_hal(hal_sensors)
|
||||
dump_hal(hal_thermal)
|
||||
dump_hal(hal_vehicle)
|
||||
dump_hal(hal_weaver)
|
||||
dump_hal(hal_wifi)
|
||||
|
||||
# Vibrate the device after we are done collecting the bugreport
|
||||
hal_client_domain(dumpstate, hal_vibrator)
|
||||
|
||||
# Reading /proc/PID/maps of other processes
|
||||
allow dumpstate self:global_capability_class_set sys_ptrace;
|
||||
|
||||
# Allow the bugreport service to create a file in
|
||||
# /data/data/com.android.shell/files/bugreports/bugreport
|
||||
allow dumpstate shell_data_file:dir create_dir_perms;
|
||||
allow dumpstate shell_data_file:file create_file_perms;
|
||||
|
||||
# Run a shell.
|
||||
allow dumpstate shell_exec:file rx_file_perms;
|
||||
|
||||
# For running am and similar framework commands.
|
||||
# Run /system/bin/app_process.
|
||||
allow dumpstate zygote_exec:file rx_file_perms;
|
||||
|
||||
# For Bluetooth
|
||||
allow dumpstate bluetooth_data_file:dir search;
|
||||
allow dumpstate bluetooth_logs_data_file:dir r_dir_perms;
|
||||
allow dumpstate bluetooth_logs_data_file:file r_file_perms;
|
||||
|
||||
# For Nfc
|
||||
allow dumpstate nfc_logs_data_file:dir r_dir_perms;
|
||||
allow dumpstate nfc_logs_data_file:file r_file_perms;
|
||||
|
||||
# Dumpstate calls screencap, which grabs a screenshot. Needs gpu access
|
||||
allow dumpstate gpu_device:chr_file rw_file_perms;
|
||||
allow dumpstate gpu_device:dir r_dir_perms;
|
||||
|
||||
# logd access
|
||||
read_logd(dumpstate)
|
||||
control_logd(dumpstate)
|
||||
read_runtime_log_tags(dumpstate)
|
||||
|
||||
# Read files in /proc
|
||||
allow dumpstate {
|
||||
proc_bootconfig
|
||||
proc_buddyinfo
|
||||
proc_cmdline
|
||||
proc_meminfo
|
||||
proc_modules
|
||||
proc_net_type
|
||||
proc_pipe_conf
|
||||
proc_pagetypeinfo
|
||||
proc_qtaguid_ctrl
|
||||
proc_qtaguid_stat
|
||||
proc_slabinfo
|
||||
proc_version
|
||||
proc_vmallocinfo
|
||||
proc_vmstat
|
||||
}:file r_file_perms;
|
||||
|
||||
# Read network state info files.
|
||||
allow dumpstate net_data_file:dir search;
|
||||
allow dumpstate net_data_file:file r_file_perms;
|
||||
|
||||
# List sockets via ss.
|
||||
allow dumpstate self:netlink_tcpdiag_socket { create_socket_perms_no_ioctl nlmsg_read };
|
||||
|
||||
# Access /data/tombstones.
|
||||
allow dumpstate tombstone_data_file:dir r_dir_perms;
|
||||
allow dumpstate tombstone_data_file:file r_file_perms;
|
||||
|
||||
# Access /cache/recovery
|
||||
allow dumpstate cache_recovery_file:dir r_dir_perms;
|
||||
allow dumpstate cache_recovery_file:file r_file_perms;
|
||||
|
||||
# Access /data/misc/recovery
|
||||
allow dumpstate recovery_data_file:dir r_dir_perms;
|
||||
allow dumpstate recovery_data_file:file r_file_perms;
|
||||
|
||||
# Access /data/misc/update_engine & /data/misc/update_engine_log
|
||||
allow dumpstate { update_engine_data_file update_engine_log_data_file }:dir r_dir_perms;
|
||||
allow dumpstate { update_engine_data_file update_engine_log_data_file }:file r_file_perms;
|
||||
# Access /data/misc/snapuserd_log
|
||||
allow dumpstate snapuserd_log_data_file:dir r_dir_perms;
|
||||
allow dumpstate snapuserd_log_data_file:file r_file_perms;
|
||||
|
||||
# Access /data/misc/profiles/{cur,ref}/
|
||||
userdebug_or_eng(`
|
||||
allow dumpstate { user_profile_root_file user_profile_data_file}:dir r_dir_perms;
|
||||
allow dumpstate user_profile_data_file:file r_file_perms;
|
||||
')
|
||||
|
||||
# Access /data/misc/logd
|
||||
allow dumpstate misc_logd_file:dir r_dir_perms;
|
||||
allow dumpstate misc_logd_file:file r_file_perms;
|
||||
|
||||
# Access /data/misc/prereboot
|
||||
allow dumpstate prereboot_data_file:dir r_dir_perms;
|
||||
allow dumpstate prereboot_data_file:file r_file_perms;
|
||||
|
||||
allow dumpstate app_fuse_file:dir r_dir_perms;
|
||||
allow dumpstate overlayfs_file:dir r_dir_perms;
|
||||
|
||||
allow dumpstate {
|
||||
service_manager_type
|
||||
-apex_service
|
||||
-dumpstate_service
|
||||
-gatekeeper_service
|
||||
-hal_service_type
|
||||
-virtual_touchpad_service
|
||||
-vold_service
|
||||
-default_android_service
|
||||
}:service_manager find;
|
||||
# suppress denials for services dumpstate should not be accessing.
|
||||
dontaudit dumpstate {
|
||||
apex_service
|
||||
dumpstate_service
|
||||
gatekeeper_service
|
||||
hal_service_type
|
||||
virtual_touchpad_service
|
||||
vold_service
|
||||
}:service_manager find;
|
||||
|
||||
# Most of these are neverallowed.
|
||||
dontaudit dumpstate hwservice_manager_type:hwservice_manager find;
|
||||
|
||||
allow dumpstate servicemanager:service_manager list;
|
||||
allow dumpstate hwservicemanager:hwservice_manager list;
|
||||
|
||||
allow dumpstate devpts:chr_file rw_file_perms;
|
||||
|
||||
# Read any system properties
|
||||
get_prop(dumpstate, property_type)
|
||||
|
||||
# Access to /data/media.
|
||||
# This should be removed if sdcardfs is modified to alter the secontext for its
|
||||
# accesses to the underlying FS.
|
||||
allow dumpstate media_rw_data_file:dir getattr;
|
||||
allow dumpstate proc_interrupts:file r_file_perms;
|
||||
allow dumpstate proc_zoneinfo:file r_file_perms;
|
||||
|
||||
# Create a service for talking back to system_server
|
||||
add_service(dumpstate, dumpstate_service)
|
||||
|
||||
# use /dev/ion for screen capture
|
||||
allow dumpstate ion_device:chr_file r_file_perms;
|
||||
|
||||
# Allow dumpstate to run top
|
||||
allow dumpstate proc_stat:file r_file_perms;
|
||||
|
||||
allow dumpstate proc_pressure_cpu:file r_file_perms;
|
||||
allow dumpstate proc_pressure_mem:file r_file_perms;
|
||||
allow dumpstate proc_pressure_io:file r_file_perms;
|
||||
|
||||
# Allow dumpstate to run ps
|
||||
allow dumpstate proc_pid_max:file r_file_perms;
|
||||
|
||||
# Allow dumpstate to talk to installd over binder
|
||||
binder_call(dumpstate, installd);
|
||||
|
||||
# Allow dumpstate to run ip xfrm policy
|
||||
allow dumpstate self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_read };
|
||||
|
||||
# Allow dumpstate to run iotop
|
||||
allow dumpstate self:netlink_socket create_socket_perms_no_ioctl;
|
||||
# newer kernels (e.g. 4.4) have a new class for sockets
|
||||
allow dumpstate self:netlink_generic_socket create_socket_perms_no_ioctl;
|
||||
|
||||
# Allow dumpstate to run ss
|
||||
allow dumpstate { domain pdx_channel_socket_type pdx_endpoint_socket_type }:socket_class_set getattr;
|
||||
|
||||
# Allow dumpstate to read linkerconfig directory
|
||||
allow dumpstate linkerconfig_file:dir { read open };
|
||||
|
||||
# For when dumpstate runs df
|
||||
dontaudit dumpstate {
|
||||
mnt_vendor_file
|
||||
mirror_data_file
|
||||
mnt_user_file
|
||||
mnt_product_file
|
||||
}:dir search;
|
||||
dontaudit dumpstate {
|
||||
apex_mnt_dir
|
||||
linkerconfig_file
|
||||
mirror_data_file
|
||||
mnt_user_file
|
||||
}:dir getattr;
|
||||
|
||||
# Allow dumpstate to talk to bufferhubd over binder
|
||||
binder_call(dumpstate, bufferhubd);
|
||||
|
||||
# Allow dumpstate to talk to mediaswcodec over binder
|
||||
binder_call(dumpstate, mediaswcodec);
|
||||
|
||||
#Access /data/misc/snapshotctl_log
|
||||
allow dumpstate snapshotctl_log_data_file:dir r_dir_perms;
|
||||
allow dumpstate snapshotctl_log_data_file:file r_file_perms;
|
||||
|
||||
#Allow access to /dev/binderfs/binder_logs
|
||||
allow dumpstate binderfs_logs:dir r_dir_perms;
|
||||
allow dumpstate binderfs_logs:file r_file_perms;
|
||||
allow dumpstate binderfs_logs_proc:file r_file_perms;
|
||||
allow dumpstate binderfs_logs_stats:file r_file_perms;
|
||||
|
||||
use_apex_info(dumpstate)
|
||||
|
||||
# Allow reading files under /data/system/shutdown-checkpoints/
|
||||
allow dumpstate shutdown_checkpoints_system_data_file:dir r_dir_perms;
|
||||
allow dumpstate shutdown_checkpoints_system_data_file:file r_file_perms;
|
||||
|
||||
###
|
||||
### neverallow rules
|
||||
###
|
||||
|
||||
# dumpstate has capability sys_ptrace, but should only use that capability for
|
||||
# accessing sensitive /proc/PID files, never for using ptrace attach.
|
||||
neverallow dumpstate *:process ptrace;
|
||||
|
||||
# only system_server, dumpstate, traceur_app and shell can find the dumpstate service
|
||||
neverallow {
|
||||
domain
|
||||
-system_server
|
||||
-shell
|
||||
-traceur_app
|
||||
-dumpstate
|
||||
} dumpstate_service:service_manager find;
|
||||
|
|
30
private/e2fs.te
Normal file
30
private/e2fs.te
Normal file
|
@ -0,0 +1,30 @@
|
|||
allow e2fs devpts:chr_file { read write getattr ioctl };
|
||||
|
||||
allow e2fs dev_type:blk_file getattr;
|
||||
allow e2fs block_device:dir search;
|
||||
allow e2fs userdata_block_device:blk_file rw_file_perms;
|
||||
allow e2fs metadata_block_device:blk_file rw_file_perms;
|
||||
allow e2fs dm_device:blk_file rw_file_perms;
|
||||
allow e2fs zoned_block_device:blk_file rw_file_perms;
|
||||
# Vold needs to capture mkfs.ext4's output
|
||||
allow e2fs vold:fd use;
|
||||
# Need to be able to format a partition
|
||||
allow e2fs sysfs_dm:dir r_dir_perms;
|
||||
allow e2fs sysfs_dm:file r_file_perms;
|
||||
|
||||
allowxperm e2fs { userdata_block_device metadata_block_device dm_device zoned_block_device }:blk_file ioctl {
|
||||
BLKSECDISCARD BLKDISCARD BLKPBSZGET BLKDISCARDZEROES BLKROGET BLKREPORTZONE BLKRESETZONE
|
||||
};
|
||||
|
||||
allow e2fs {
|
||||
proc_filesystems
|
||||
proc_mounts
|
||||
proc_swaps
|
||||
}:file r_file_perms;
|
||||
|
||||
# access /sys/fs/ext4/features
|
||||
allow e2fs sysfs_fs_ext4_features:dir search;
|
||||
allow e2fs sysfs_fs_ext4_features:file r_file_perms;
|
||||
|
||||
# access SELinux context files
|
||||
allow e2fs file_contexts_file:file r_file_perms;
|
|
@ -4,3 +4,13 @@ init_daemon_domain(extra_free_kbytes)
|
|||
|
||||
# Only extra_free_kbytes script is allowed to store these properties
|
||||
set_prop(extra_free_kbytes, init_storage_prop)
|
||||
|
||||
# required permissions to run the script from init
|
||||
allow extra_free_kbytes shell_exec:file rx_file_perms;
|
||||
allow extra_free_kbytes system_file:file x_file_perms;
|
||||
allow extra_free_kbytes toolbox_exec:file rx_file_perms;
|
||||
|
||||
# files used by the script
|
||||
allow extra_free_kbytes proc_extra_free_kbytes:file rw_file_perms;
|
||||
allow extra_free_kbytes proc_watermark_scale_factor:file rw_file_perms;
|
||||
allow extra_free_kbytes proc_zoneinfo:file r_file_perms;
|
||||
|
|
|
@ -49,9 +49,129 @@ recovery_only(`
|
|||
# Let this domain use the hal fastboot service
|
||||
binder_use(fastbootd)
|
||||
hal_client_domain(fastbootd, hal_fastboot)
|
||||
|
||||
# fastbootd can only use HALs in passthrough mode
|
||||
passthrough_hal_client_domain(fastbootd, hal_bootctl)
|
||||
|
||||
# fastbootd can use AIDL HALs in binder mode
|
||||
binder_use(fastbootd)
|
||||
hal_client_domain(fastbootd, hal_health)
|
||||
hal_client_domain(fastbootd, hal_fastboot)
|
||||
|
||||
# Access /dev/usb-ffs/fastbootd/ep0
|
||||
allow fastbootd functionfs:dir search;
|
||||
allow fastbootd functionfs:file rw_file_perms;
|
||||
|
||||
allowxperm fastbootd functionfs:file ioctl { FUNCTIONFS_ENDPOINT_DESC };
|
||||
# Log to serial
|
||||
allow fastbootd kmsg_device:chr_file { open getattr write };
|
||||
|
||||
# battery info
|
||||
allow fastbootd sysfs_batteryinfo:file r_file_perms;
|
||||
|
||||
allow fastbootd device:dir r_dir_perms;
|
||||
|
||||
# For dev/block/by-name dir
|
||||
allow fastbootd block_device:dir r_dir_perms;
|
||||
|
||||
# Needed for DM_DEV_CREATE ioctl call
|
||||
allow fastbootd self:capability sys_admin;
|
||||
|
||||
unix_socket_connect(fastbootd, recovery, recovery)
|
||||
|
||||
# Required for flashing
|
||||
allow fastbootd dm_device:chr_file rw_file_perms;
|
||||
allow fastbootd dm_device:blk_file rw_file_perms;
|
||||
|
||||
allow fastbootd cache_block_device:blk_file rw_file_perms;
|
||||
allow fastbootd super_block_device_type:blk_file rw_file_perms;
|
||||
allow fastbootd {
|
||||
boot_block_device
|
||||
metadata_block_device
|
||||
system_block_device
|
||||
userdata_block_device
|
||||
}:blk_file { w_file_perms getattr ioctl };
|
||||
|
||||
# For disabling/wiping GSI, and for modifying/deleting files created via
|
||||
# libfiemap.
|
||||
allow fastbootd metadata_block_device:blk_file r_file_perms;
|
||||
allow fastbootd {rootfs tmpfs}:dir mounton;
|
||||
allow fastbootd metadata_file:dir { search getattr mounton };
|
||||
allow fastbootd gsi_metadata_file_type:dir rw_dir_perms;
|
||||
allow fastbootd gsi_metadata_file_type:file create_file_perms;
|
||||
|
||||
allowxperm fastbootd super_block_device_type:blk_file ioctl { BLKIOMIN BLKALIGNOFF };
|
||||
|
||||
allowxperm fastbootd {
|
||||
metadata_block_device
|
||||
userdata_block_device
|
||||
dm_device
|
||||
cache_block_device
|
||||
}:blk_file ioctl { BLKSECDISCARD BLKDISCARD };
|
||||
|
||||
allow fastbootd misc_block_device:blk_file rw_file_perms;
|
||||
|
||||
allow fastbootd proc_cmdline:file r_file_perms;
|
||||
allow fastbootd rootfs:dir r_dir_perms;
|
||||
|
||||
# Needed to read fstab node from device tree.
|
||||
allow fastbootd sysfs_dt_firmware_android:file r_file_perms;
|
||||
allow fastbootd sysfs_dt_firmware_android:dir r_dir_perms;
|
||||
|
||||
# Needed because libdm reads sysfs to validate when a dm path is ready.
|
||||
r_dir_file(fastbootd, sysfs_dm)
|
||||
|
||||
# Needed for realpath() call to resolve symlinks.
|
||||
allow fastbootd block_device:dir getattr;
|
||||
userdebug_or_eng(`
|
||||
# Refined manipulation of /mnt/scratch, without these perms resorts
|
||||
# to deleting scratch partition when partition(s) are flashed.
|
||||
allow fastbootd self:process setfscreate;
|
||||
allow fastbootd cache_file:dir search;
|
||||
allow fastbootd proc_filesystems:file { getattr open read };
|
||||
allow fastbootd self:capability sys_rawio;
|
||||
allowxperm fastbootd dev_type:blk_file ioctl BLKROSET;
|
||||
allow fastbootd overlayfs_file:dir { create_dir_perms mounton };
|
||||
allow fastbootd {
|
||||
system_file_type
|
||||
unlabeled
|
||||
vendor_file_type
|
||||
}:dir { remove_name rmdir search write };
|
||||
allow fastbootd {
|
||||
overlayfs_file
|
||||
system_file_type
|
||||
unlabeled
|
||||
vendor_file_type
|
||||
}:{ file lnk_file } unlink;
|
||||
allow fastbootd tmpfs:dir rw_dir_perms;
|
||||
# Fetch vendor_boot partition
|
||||
allow fastbootd boot_block_device:blk_file r_file_perms;
|
||||
|
||||
# popen(/system/bin/dmesg) and associated permissions. We only allow this
|
||||
# on unlocked devices running userdebug builds.
|
||||
allow fastbootd rootfs:file execute_no_trans;
|
||||
allow fastbootd system_file:file execute_no_trans;
|
||||
allow fastbootd kmsg_device:chr_file read;
|
||||
allow fastbootd kernel:system syslog_read;
|
||||
')
|
||||
|
||||
# Allow using libfiemap/gsid directly (no binder in recovery).
|
||||
allow fastbootd gsi_metadata_file_type:dir search;
|
||||
allow fastbootd ota_metadata_file:dir rw_dir_perms;
|
||||
allow fastbootd ota_metadata_file:file create_file_perms;
|
||||
')
|
||||
|
||||
# This capability allows fastbootd to circumvent memlock rlimits while using
|
||||
# io_uring. An Alternative would be to up the memlock rlimit for the fastbootd service.
|
||||
allow fastbootd self:capability ipc_lock;
|
||||
io_uring_use(fastbootd)
|
||||
|
||||
###
|
||||
### neverallow rules
|
||||
###
|
||||
|
||||
# Write permission is required to wipe userdata
|
||||
# until recovery supports vold.
|
||||
neverallow fastbootd {
|
||||
data_file_type
|
||||
}:file { no_x_file_perms };
|
||||
|
|
|
@ -165,3 +165,27 @@ type pre_reboot_dexopt_file, file_type;
|
|||
# Type for /mnt/artd_tmp in the Pre-reboot Dexopt chroot
|
||||
# This type is set on the directory through the `rootcontext=` mount option.
|
||||
type pre_reboot_dexopt_artd_file, file_type;
|
||||
|
||||
# Allow files to be created in their appropriate filesystems.
|
||||
allow fs_type self:filesystem associate;
|
||||
allow cgroup tmpfs:filesystem associate;
|
||||
allow cgroup_v2 tmpfs:filesystem associate;
|
||||
allow cgroup_rc_file tmpfs:filesystem associate;
|
||||
allow sysfs_type sysfs:filesystem associate;
|
||||
allow debugfs_type { debugfs debugfs_tracing debugfs_tracing_debug }:filesystem associate;
|
||||
allow file_type labeledfs:filesystem associate;
|
||||
allow file_type tmpfs:filesystem associate;
|
||||
allow file_type rootfs:filesystem associate;
|
||||
allow dev_type tmpfs:filesystem associate;
|
||||
allow app_fuse_file app_fusefs:filesystem associate;
|
||||
allow postinstall_file self:filesystem associate;
|
||||
allow proc_net proc:filesystem associate;
|
||||
|
||||
# It's a bug to assign the file_type attribute and fs_type attribute
|
||||
# to any type. Do not allow it.
|
||||
#
|
||||
# For example, the following is a bug:
|
||||
# type apk_data_file, file_type, data_file_type, fs_type;
|
||||
# Should be:
|
||||
# type apk_data_file, file_type, data_file_type;
|
||||
neverallow fs_type file_type:filesystem associate;
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
typeattribute fingerprintd coredomain;
|
||||
|
||||
init_daemon_domain(fingerprintd)
|
||||
|
||||
binder_use(fingerprintd)
|
||||
|
||||
# Scan through /system/lib64/hw looking for installed HALs
|
||||
allow fingerprintd system_file:dir r_dir_perms;
|
||||
|
||||
# need to find KeyStore and add self
|
||||
add_service(fingerprintd, fingerprintd_service)
|
||||
|
||||
# allow HAL module to read dir contents
|
||||
allow fingerprintd fingerprintd_data_file:file { create_file_perms };
|
||||
|
||||
# allow HAL module to read/write/unlink contents of this dir
|
||||
allow fingerprintd fingerprintd_data_file:dir rw_dir_perms;
|
||||
|
||||
# Need to add auth tokens to KeyStore
|
||||
use_keystore(fingerprintd)
|
||||
allow fingerprintd keystore:keystore2 { add_auth };
|
||||
|
||||
# For permissions checking
|
||||
binder_call(fingerprintd, system_server);
|
||||
allow fingerprintd permission_service:service_manager find;
|
||||
|
||||
allow fingerprintd ion_device:chr_file r_file_perms;
|
||||
|
|
|
@ -36,6 +36,18 @@ set_prop(flags_health_check, device_config_camera_native_prop)
|
|||
set_prop(flags_health_check, device_config_tethering_u_or_later_native_prop)
|
||||
set_prop(flags_health_check, next_boot_prop)
|
||||
|
||||
allow flags_health_check server_configurable_flags_data_file:dir rw_dir_perms;
|
||||
allow flags_health_check server_configurable_flags_data_file:file create_file_perms;
|
||||
|
||||
###
|
||||
### Neverallow rules
|
||||
###
|
||||
|
||||
# server_configurable_flags_data_file is used for storing whether server configurable flags which
|
||||
# have been reset during current booting. Mistakenly modified by unrelated components can
|
||||
# cause bad server configurable flags synced back to device.
|
||||
neverallow { domain -init -flags_health_check } server_configurable_flags_data_file:file no_w_file_perms;
|
||||
|
||||
# system property device_config_boot_count_prop is used for deciding when to perform server
|
||||
# configurable flags related disaster recovery. Mistakenly set up by unrelated components can, at a
|
||||
# wrong timing, trigger server configurable flag related disaster recovery, which will override
|
||||
|
|
|
@ -3,3 +3,77 @@ typeattribute fsck coredomain;
|
|||
init_daemon_domain(fsck)
|
||||
|
||||
allow fsck metadata_block_device:blk_file rw_file_perms;
|
||||
|
||||
# /dev/__null__ created by init prior to policy load,
|
||||
# open fd inherited by fsck.
|
||||
allow fsck tmpfs:chr_file { read write ioctl };
|
||||
|
||||
# Inherit and use pty created by android_fork_execvp_ext().
|
||||
allow fsck devpts:chr_file { read write ioctl getattr };
|
||||
|
||||
# Allow stdin/out back to vold
|
||||
allow fsck vold:fd use;
|
||||
allow fsck vold:fifo_file { read write getattr };
|
||||
|
||||
# Run fsck on certain block devices
|
||||
allow fsck userdata_block_device:blk_file rw_file_perms;
|
||||
allow fsck cache_block_device:blk_file rw_file_perms;
|
||||
allow fsck dm_device:blk_file rw_file_perms;
|
||||
allow fsck zoned_block_device:blk_file rw_file_perms;
|
||||
userdebug_or_eng(`
|
||||
allow fsck system_block_device:blk_file rw_file_perms;
|
||||
')
|
||||
|
||||
# e2fsck performs a comprehensive search of /proc/mounts to check whether the
|
||||
# checked filesystem is currently mounted.
|
||||
allow fsck metadata_file:dir getattr;
|
||||
allow fsck block_device:dir search;
|
||||
allow fsck mirror_data_file:dir search;
|
||||
|
||||
# For the block devices where we have ioctl access,
|
||||
# allow at a minimum the following common fsck ioctls.
|
||||
allowxperm fsck dev_type:blk_file ioctl {
|
||||
BLKDISCARDZEROES
|
||||
BLKROGET
|
||||
BLKREPORTZONE
|
||||
};
|
||||
|
||||
# To determine if it is safe to run fsck on a filesystem, e2fsck
|
||||
# must first determine if the filesystem is mounted. To do that,
|
||||
# e2fsck scans through /proc/mounts and collects all the mounted
|
||||
# block devices. With that information, it runs stat() on each block
|
||||
# device, comparing the major and minor numbers to the filesystem
|
||||
# passed in on the command line. If there is a match, then the filesystem
|
||||
# is currently mounted and running fsck is dangerous.
|
||||
# Allow stat access to all block devices so that fsck can compare
|
||||
# major/minor values.
|
||||
allow fsck dev_type:blk_file getattr;
|
||||
|
||||
allow fsck {
|
||||
proc_mounts
|
||||
proc_swaps
|
||||
sysfs_dm
|
||||
}:file r_file_perms;
|
||||
allow fsck rootfs:dir r_dir_perms;
|
||||
allow fsck sysfs_dm:dir r_dir_perms;
|
||||
|
||||
###
|
||||
### neverallow rules
|
||||
###
|
||||
|
||||
# fsck should never be run on these block devices
|
||||
neverallow fsck {
|
||||
boot_block_device
|
||||
frp_block_device
|
||||
recovery_block_device
|
||||
root_block_device
|
||||
swap_block_device
|
||||
system_block_device
|
||||
userdebug_or_eng(`-system_block_device')
|
||||
vold_device
|
||||
}:blk_file no_rw_file_perms;
|
||||
|
||||
# Only allow entry from init or vold via fsck binaries
|
||||
neverallow { domain -init -vold } fsck:process transition;
|
||||
neverallow * fsck:process dyntransition;
|
||||
neverallow fsck { file_type fs_type -fsck_exec }:file entrypoint;
|
||||
|
|
|
@ -1 +1,66 @@
|
|||
typeattribute fsck_untrusted coredomain;
|
||||
|
||||
# Inherit and use pty created by android_fork_execvp_ext().
|
||||
allow fsck_untrusted devpts:chr_file { read write ioctl getattr };
|
||||
|
||||
# Allow stdin/out back to vold
|
||||
allow fsck_untrusted vold:fd use;
|
||||
allow fsck_untrusted vold:fifo_file { read write getattr };
|
||||
|
||||
# Run fsck on vold block devices
|
||||
allow fsck_untrusted block_device:dir search;
|
||||
allow fsck_untrusted vold_device:blk_file rw_file_perms;
|
||||
|
||||
allow fsck_untrusted proc_mounts:file r_file_perms;
|
||||
|
||||
# To determine if it is safe to run fsck on a filesystem, e2fsck
|
||||
# must first determine if the filesystem is mounted. To do that,
|
||||
# e2fsck scans through /proc/mounts and collects all the mounted
|
||||
# block devices. With that information, it runs stat() on each block
|
||||
# device, comparing the major and minor numbers to the filesystem
|
||||
# passed in on the command line. If there is a match, then the filesystem
|
||||
# is currently mounted and running fsck is dangerous.
|
||||
# Allow stat access to all block devices so that fsck can compare
|
||||
# major/minor values.
|
||||
allow fsck_untrusted dev_type:blk_file getattr;
|
||||
|
||||
###
|
||||
### neverallow rules
|
||||
###
|
||||
|
||||
# Untrusted fsck should never be run on block devices holding sensitive data
|
||||
neverallow fsck_untrusted {
|
||||
boot_block_device
|
||||
frp_block_device
|
||||
metadata_block_device
|
||||
recovery_block_device
|
||||
root_block_device
|
||||
swap_block_device
|
||||
system_block_device
|
||||
userdata_block_device
|
||||
cache_block_device
|
||||
dm_device
|
||||
}:blk_file no_rw_file_perms;
|
||||
|
||||
# Only allow entry from vold via fsck binaries
|
||||
neverallow { domain -vold } fsck_untrusted:process transition;
|
||||
neverallow * fsck_untrusted:process dyntransition;
|
||||
neverallow fsck_untrusted { file_type fs_type -fsck_exec }:file entrypoint;
|
||||
|
||||
# fsck_untrusted should never have sys_admin permissions. If it requires sys_admin
|
||||
# permissions, that is a code mistake that needs to be fixed, not a permission that
|
||||
# should be granted. Same with setgid and setuid.
|
||||
neverallow fsck_untrusted self:global_capability_class_set { setgid setuid sys_admin };
|
||||
|
||||
###
|
||||
### dontaudit rules
|
||||
###
|
||||
|
||||
# Ignores attempts to access sysfs. fsck binaries seem to like trying to go
|
||||
# here, but nothing bad happens if they can't, and they shouldn't be allowed.
|
||||
dontaudit fsck_untrusted sysfs:file rw_file_perms;
|
||||
dontaudit fsck_untrusted sysfs_dm:file rw_file_perms;
|
||||
dontaudit fsck_untrusted sysfs_dm:dir rw_dir_perms;
|
||||
|
||||
# Ignore attempts to access tmpfs. fsck don't need to do this.
|
||||
dontaudit fsck_untrusted tmpfs:lnk_file read;
|
||||
|
|
|
@ -4,3 +4,42 @@ init_daemon_domain(gatekeeperd)
|
|||
|
||||
# For checking whether GSI is running
|
||||
get_prop(gatekeeperd, gsid_prop)
|
||||
|
||||
# gatekeeperd
|
||||
binder_service(gatekeeperd)
|
||||
binder_use(gatekeeperd)
|
||||
|
||||
### Rules needed when Gatekeeper HAL runs inside gatekeeperd process.
|
||||
### These rules should eventually be granted only when needed.
|
||||
allow gatekeeperd ion_device:chr_file r_file_perms;
|
||||
# Load HAL implementation
|
||||
allow gatekeeperd system_file:dir r_dir_perms;
|
||||
###
|
||||
|
||||
### Rules needed when Gatekeeper HAL runs outside of gatekeeperd process.
|
||||
### These rules should eventually be granted only when needed.
|
||||
hal_client_domain(gatekeeperd, hal_gatekeeper)
|
||||
###
|
||||
|
||||
# need to find KeyStore and add self
|
||||
add_service(gatekeeperd, gatekeeper_service)
|
||||
|
||||
# Need to add auth tokens to KeyStore
|
||||
use_keystore(gatekeeperd)
|
||||
allow gatekeeperd keystore:keystore2 { add_auth };
|
||||
allow gatekeeperd authorization_service:service_manager find;
|
||||
|
||||
|
||||
# For permissions checking
|
||||
allow gatekeeperd system_server:binder call;
|
||||
allow gatekeeperd permission_service:service_manager find;
|
||||
|
||||
# for SID file access
|
||||
allow gatekeeperd gatekeeper_data_file:dir rw_dir_perms;
|
||||
allow gatekeeperd gatekeeper_data_file:file create_file_perms;
|
||||
|
||||
# For hardware properties retrieval
|
||||
allow gatekeeperd hardware_properties_service:service_manager find;
|
||||
|
||||
r_dir_file(gatekeeperd, cgroup)
|
||||
r_dir_file(gatekeeperd, cgroup_v2)
|
||||
|
|
38
private/hal_graphics_composer.te
Normal file
38
private/hal_graphics_composer.te
Normal file
|
@ -0,0 +1,38 @@
|
|||
# HwBinder IPC from client to server, and callbacks
|
||||
binder_call(hal_graphics_composer_client, hal_graphics_composer_server)
|
||||
binder_call(hal_graphics_composer_server, hal_graphics_composer_client)
|
||||
allow hal_graphics_composer_client hal_graphics_composer_server_tmpfs:file { getattr map read write };
|
||||
allow hal_graphics_composer_server hal_graphics_composer_client_tmpfs:file { getattr map read write };
|
||||
|
||||
hal_attribute_hwservice(hal_graphics_composer, hal_graphics_composer_hwservice)
|
||||
|
||||
# Coordinate with hal_graphics_mapper
|
||||
allow hal_graphics_composer_server hal_graphics_mapper_hwservice:hwservice_manager find;
|
||||
|
||||
# GPU device access
|
||||
allow hal_graphics_composer gpu_device:chr_file rw_file_perms;
|
||||
allow hal_graphics_composer gpu_device:dir r_dir_perms;
|
||||
allow hal_graphics_composer ion_device:chr_file r_file_perms;
|
||||
allow hal_graphics_composer dmabuf_system_heap_device:chr_file r_file_perms;
|
||||
allow hal_graphics_composer hal_graphics_allocator:fd use;
|
||||
|
||||
# Access /dev/graphics/fb0.
|
||||
allow hal_graphics_composer graphics_device:dir search;
|
||||
allow hal_graphics_composer graphics_device:chr_file rw_file_perms;
|
||||
|
||||
# Fences
|
||||
allow hal_graphics_composer system_server:fd use;
|
||||
allow hal_graphics_composer bootanim:fd use;
|
||||
allow hal_graphics_composer appdomain:fd use;
|
||||
|
||||
# allow self to set SCHED_FIFO
|
||||
allow hal_graphics_composer self:global_capability_class_set sys_nice;
|
||||
|
||||
# allow surfaceflinger to use a pipe for dumpsys output
|
||||
allow hal_graphics_composer_server hal_graphics_composer_client:fifo_file write;
|
||||
|
||||
|
||||
binder_call(hal_graphics_composer_client, servicemanager)
|
||||
binder_call(hal_graphics_composer_server, servicemanager)
|
||||
|
||||
hal_attribute_service(hal_graphics_composer, hal_graphics_composer_service)
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue