blob: 44c9ea561eefd13db7efd763110ec1fcf4ec73dd [file] [log] [blame]
Paul Crowley5b962cf2017-10-13 14:54:32 -07001domain_auto_trans(vold, vold_prepare_subdirs_exec, vold_prepare_subdirs)
Jin Qianc0125332017-10-19 14:41:37 -07002
Inseob Kim75806ef2024-03-27 17:18:41 +09003typeattribute vold_prepare_subdirs coredomain;
Alan Stokesfc0cab82020-02-11 14:43:05 +00004typeattribute vold_prepare_subdirs mlstrustedsubject;
5
Paul Crowley5850a2a2017-10-25 13:03:24 -07006allow vold_prepare_subdirs system_file:file execute_no_trans;
7allow vold_prepare_subdirs shell_exec:file rx_file_perms;
8allow vold_prepare_subdirs toolbox_exec:file rx_file_perms;
9allow vold_prepare_subdirs devpts:chr_file rw_file_perms;
10allow vold_prepare_subdirs vold:fd use;
11allow vold_prepare_subdirs vold:fifo_file { read write };
12allow vold_prepare_subdirs file_contexts_file:file r_file_perms;
Ellen Arteca27b515e2024-04-30 20:26:55 +000013allow vold_prepare_subdirs seapp_contexts_file:file r_file_perms;
Benjamin Gordon342362a2018-09-06 16:19:40 -060014allow vold_prepare_subdirs self:global_capability_class_set { chown dac_override dac_read_search fowner };
Paul Crowley5850a2a2017-10-25 13:03:24 -070015allow vold_prepare_subdirs self:process setfscreate;
Jeff Vander Stoepd25ccab2018-02-07 16:29:06 -080016allow vold_prepare_subdirs {
Mohammad Samiul Islamef1698a2022-05-11 21:43:54 +010017 sdk_sandbox_system_data_file
Jeff Vander Stoepd25ccab2018-02-07 16:29:06 -080018 system_data_file
19 vendor_data_file
Joel Galenson254a8722018-04-16 14:50:38 -070020}:dir { open read write add_name remove_name rmdir relabelfrom };
Paul Crowley80966392018-04-26 13:41:13 -070021allow vold_prepare_subdirs {
Alan Stokesfa10a142021-07-12 14:21:48 +010022 apex_data_file_type
Oli Lan79b4e1a2019-11-19 18:10:16 +000023 apex_module_data_file
Oli Lan91ce5b92019-12-02 18:29:48 +000024 apex_rollback_data_file
Annie Meng4c3d11c2019-01-15 21:20:13 +000025 backup_data_file
Tianjieb729aa62021-10-05 22:13:20 -070026 checkin_data_file
Kevin Chyn91c25802018-11-15 15:28:07 -080027 face_vendor_data_file
Nick Kralevich83f25e22018-11-19 18:42:11 +000028 fingerprint_vendor_data_file
Kevin Chyn91c25802018-11-15 15:28:07 -080029 iris_vendor_data_file
Narayan Kamath2ad229c2019-01-14 15:02:12 +000030 rollback_data_file
Ellen Arteca27b515e2024-04-30 20:26:55 +000031 is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `storage_area_key_file')
Paul Crowley80966392018-04-26 13:41:13 -070032 storaged_data_file
Nikita Ioffee2da6332022-02-21 17:55:59 +000033 sdk_sandbox_data_file
Mohammad Samiul Islamef1698a2022-05-11 21:43:54 +010034 sdk_sandbox_system_data_file
Alan Stokesfc0cab82020-02-11 14:43:05 +000035 system_data_file
Paul Crowley80966392018-04-26 13:41:13 -070036 vold_data_file
37}:dir { create_dir_perms relabelto };
38allow vold_prepare_subdirs {
Alan Stokesfa10a142021-07-12 14:21:48 +010039 apex_data_file_type
Orion Hodson8f75f762020-10-16 15:29:55 +010040 apex_art_staging_data_file
Oli Lan79b4e1a2019-11-19 18:10:16 +000041 apex_module_data_file
Oli Lan91ce5b92019-12-02 18:29:48 +000042 apex_rollback_data_file
Annie Meng4c3d11c2019-01-15 21:20:13 +000043 backup_data_file
Tianjieb729aa62021-10-05 22:13:20 -070044 checkin_data_file
Kevin Chyn91c25802018-11-15 15:28:07 -080045 face_vendor_data_file
Nick Kralevich83f25e22018-11-19 18:42:11 +000046 fingerprint_vendor_data_file
Kevin Chyn91c25802018-11-15 15:28:07 -080047 iris_vendor_data_file
Narayan Kamath2ad229c2019-01-14 15:02:12 +000048 rollback_data_file
Paul Crowley80966392018-04-26 13:41:13 -070049 storaged_data_file
Nikita Ioffee2da6332022-02-21 17:55:59 +000050 sdk_sandbox_data_file
Paul Crowley80966392018-04-26 13:41:13 -070051 system_data_file
52 vold_data_file
53}:file { getattr unlink };
Oli Lan79b4e1a2019-11-19 18:10:16 +000054allow vold_prepare_subdirs apex_mnt_dir:dir { open read };
Alan Stokesfc0cab82020-02-11 14:43:05 +000055allow vold_prepare_subdirs mnt_expand_file:dir search;
Alan Stokes7aa40412020-12-04 14:07:52 +000056allow vold_prepare_subdirs user_profile_data_file:dir { search getattr relabelfrom };
57allow vold_prepare_subdirs user_profile_root_file:dir { search getattr relabelfrom relabelto };
Alan Stokes53c76a22022-02-08 15:44:06 +000058
Ellen Arteca27b515e2024-04-30 20:26:55 +000059# Allow vold_prepare_subdirs to create storage area directories on behalf of apps.
60is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `
61 allow vold_prepare_subdirs {
62 storage_area_dir
63 storage_area_app_dir
64 }:dir {
65 rw_dir_perms
66 create
67 setattr # for chown() and chmod()
68 rmdir
69 unlink
70 relabelfrom # setfilecon
71 relabelto # setfilecon
72 };
73
74 # The storage area directories should have type storage_area_dir
75 type_transition vold_prepare_subdirs storage_area_app_dir:dir storage_area_dir;
76
77 selinux_check_context(vold_prepare_subdirs)
Ellen Artecaaa898dc2024-05-20 17:59:16 +000078
79 allowxperm vold_prepare_subdirs storage_area_dir:dir ioctl FS_IOC_SET_ENCRYPTION_POLICY;
80')
81
82is_flag_enabled(RELEASE_UNLOCKED_STORAGE_API, `
83 neverallowxperm vold_prepare_subdirs {
84 data_file_type
85 -storage_area_dir
86 }:dir ioctl FS_IOC_SET_ENCRYPTION_POLICY;
Ellen Arteca27b515e2024-04-30 20:26:55 +000087')
88
Alan Stokes53c76a22022-02-08 15:44:06 +000089# Migrate legacy labels to apex_system_server_data_file (b/217581286)
90allow vold_prepare_subdirs {
91 apex_appsearch_data_file
92 apex_permission_data_file
93 apex_scheduling_data_file
Treehugger Robotbad95e02022-05-03 13:44:35 +000094 apex_tethering_data_file
Alan Stokes53c76a22022-02-08 15:44:06 +000095 apex_wifi_data_file
96}:dir relabelfrom;
97
Alan Stokesfc0cab82020-02-11 14:43:05 +000098# /data/misc is unlabeled during early boot.
99allow vold_prepare_subdirs unlabeled:dir search;
Joel Galenson5d5ac9a2019-05-09 10:43:59 -0700100
101dontaudit vold_prepare_subdirs { proc unlabeled }:file r_file_perms;