Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 1 | # odrefresh |
Jiakai Zhang | f7dcc53 | 2024-07-04 15:59:49 +0100 | [diff] [blame] | 2 | type odrefresh, domain, coredomain, artd_subprocess_type; |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 3 | type odrefresh_exec, system_file_type, exec_type, file_type; |
| 4 | |
| 5 | # Allow odrefresh to create files and directories for on device signing. |
| 6 | allow odrefresh apex_module_data_file:dir { getattr search }; |
| 7 | allow odrefresh apex_art_data_file:dir { create_dir_perms relabelfrom }; |
Jiakai Zhang | 8d24e01 | 2024-03-15 16:39:13 +0000 | [diff] [blame] | 8 | allow odrefresh apex_art_data_file:file { create_file_perms relabelto } ; |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 9 | |
Orion Hodson | 7c6b3eb | 2021-04-09 15:17:38 +0100 | [diff] [blame] | 10 | # Allow odrefresh to create data files (typically for metrics before statsd starts). |
| 11 | allow odrefresh odrefresh_data_file:dir create_dir_perms; |
| 12 | allow odrefresh odrefresh_data_file:file create_file_perms; |
| 13 | |
Lokesh Gidra | 06edcd8 | 2021-03-11 11:32:47 -0800 | [diff] [blame] | 14 | userfaultfd_use(odrefresh) |
| 15 | |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 16 | # Staging area labels (/data/misc/apexdata/com.android.art/staging). odrefresh |
| 17 | # sets up files here and passes file descriptors for dex2oat to write to. |
| 18 | allow odrefresh apex_art_staging_data_file:dir { create_dir_perms relabelto }; |
Jiakai Zhang | 8d24e01 | 2024-03-15 16:39:13 +0000 | [diff] [blame] | 19 | allow odrefresh apex_art_staging_data_file:file { create_file_perms relabelfrom }; |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 20 | |
| 21 | # Run dex2oat in its own sandbox. |
| 22 | domain_auto_trans(odrefresh, dex2oat_exec, dex2oat) |
| 23 | |
Orion Hodson | 522bcbe | 2021-08-17 19:02:42 +0100 | [diff] [blame] | 24 | # Allow odrefresh to kill dex2oat if compilation times out. |
| 25 | allow odrefresh dex2oat:process sigkill; |
| 26 | |
Martijn Coenen | 6afdb72 | 2020-11-27 12:23:54 +0100 | [diff] [blame] | 27 | # Use devpts and fd from odsign (which exec()'s odrefresh) |
| 28 | allow odrefresh odsign_devpts:chr_file { read write }; |
| 29 | allow odrefresh odsign:fd use; |
| 30 | |
Alan Stokes | d3438b0 | 2021-09-15 14:28:12 +0100 | [diff] [blame] | 31 | # Allow odrefresh to read /apex/apex-info-list.xml to determine |
| 32 | # whether current apex is in /system or /data. |
| 33 | allow odrefresh apex_info_file:file r_file_perms; |
| 34 | |
| 35 | # Allow updating boot animation status. |
| 36 | set_prop(odrefresh, bootanim_system_prop) |
| 37 | |
| 38 | # Allow query ART device config properties |
| 39 | get_prop(odrefresh, device_config_runtime_native_prop) |
| 40 | get_prop(odrefresh, device_config_runtime_native_boot_prop) |
| 41 | |
Orion Hodson | 8f75f76 | 2020-10-16 15:29:55 +0100 | [diff] [blame] | 42 | # Do not audit unused resources from parent processes (adb, shell, su). |
| 43 | # These appear to be unnecessary for odrefresh. |
| 44 | dontaudit odrefresh { adbd shell }:fd use; |
| 45 | dontaudit odrefresh devpts:chr_file rw_file_perms; |
| 46 | dontaudit odrefresh adbd:unix_stream_socket { getattr read write }; |
| 47 | |
Jiakai Zhang | 8d24e01 | 2024-03-15 16:39:13 +0000 | [diff] [blame] | 48 | # Read access to SELinux context files, for restorecon. |
| 49 | allow odrefresh file_contexts_file:file r_file_perms; |
| 50 | allow odrefresh seapp_contexts_file:file r_file_perms; |
| 51 | |
| 52 | # Check validity of SELinux context, for restorecon. |
| 53 | selinux_check_context(odrefresh) |
Jiakai Zhang | 4acd073 | 2024-03-20 11:24:54 +0000 | [diff] [blame] | 54 | |
| 55 | # odrefresh iterates over all properties to find the ones that it's interested |
| 56 | # in. It's okay to ignore denials on other properties. |
| 57 | dontaudit odrefresh property_type:file r_file_perms; |
| 58 | |
| 59 | # Allow to be called by artd in Pre-reboot Dexopt. |
| 60 | allow odrefresh artd:fd use; |
| 61 | |
| 62 | # Neverallow rules. |
| 63 | |
| 64 | # No other processes should be creating files in the staging area. |
| 65 | neverallow { domain -init -odrefresh -compos_fd_server } apex_art_staging_data_file:file open; |
| 66 | |
| 67 | # No processes other than init, odrefresh, system_server, and artd access |
| 68 | # odrefresh_data_files. |
| 69 | # Among those, artd only needs to bind-mount /data/misc/odrefresh, but doesn't |
| 70 | # need to access the files. |
| 71 | neverallow { domain -init -odrefresh -system_server -artd } odrefresh_data_file:dir *; |
| 72 | neverallow { domain -init -odrefresh -system_server } odrefresh_data_file:file *; |