xref: /aosp_15_r20/system/sepolicy/prebuilts/api/31.0/public/toolbox.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker# Any toolbox command run by init.
2*e4a36f41SAndroid Build Coastguard Worker# At present, the only known usage is for running mkswap via fs_mgr.
3*e4a36f41SAndroid Build Coastguard Worker# Do NOT use this domain for toolbox when run by any other domain.
4*e4a36f41SAndroid Build Coastguard Workertype toolbox, domain;
5*e4a36f41SAndroid Build Coastguard Workertype toolbox_exec, system_file_type, exec_type, file_type;
6*e4a36f41SAndroid Build Coastguard Worker
7*e4a36f41SAndroid Build Coastguard Worker# /dev/__null__ created by init prior to policy load,
8*e4a36f41SAndroid Build Coastguard Worker# open fd inherited by fsck.
9*e4a36f41SAndroid Build Coastguard Workerallow toolbox tmpfs:chr_file { read write ioctl };
10*e4a36f41SAndroid Build Coastguard Worker
11*e4a36f41SAndroid Build Coastguard Worker# Inherit and use pty created by android_fork_execvp_ext().
12*e4a36f41SAndroid Build Coastguard Workerallow toolbox devpts:chr_file { read write getattr ioctl };
13*e4a36f41SAndroid Build Coastguard Worker
14*e4a36f41SAndroid Build Coastguard Worker# mkswap-specific.
15*e4a36f41SAndroid Build Coastguard Worker# Read/write block devices used for swap partitions.
16*e4a36f41SAndroid Build Coastguard Worker# Assign swap_block_device type any such partition in your
17*e4a36f41SAndroid Build Coastguard Worker# device/<vendor>/<product>/sepolicy/file_contexts file.
18*e4a36f41SAndroid Build Coastguard Workerallow toolbox block_device:dir search;
19*e4a36f41SAndroid Build Coastguard Workerallow toolbox swap_block_device:blk_file rw_file_perms;
20*e4a36f41SAndroid Build Coastguard Worker
21*e4a36f41SAndroid Build Coastguard Worker# Only allow entry from init via the toolbox binary.
22*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } toolbox:process transition;
23*e4a36f41SAndroid Build Coastguard Workerneverallow * toolbox:process dyntransition;
24*e4a36f41SAndroid Build Coastguard Workerneverallow toolbox { file_type fs_type -toolbox_exec}:file entrypoint;
25*e4a36f41SAndroid Build Coastguard Worker
26*e4a36f41SAndroid Build Coastguard Worker# rm -rf directories in /data
27*e4a36f41SAndroid Build Coastguard Workerallow toolbox system_data_root_file:dir { remove_name write };
28*e4a36f41SAndroid Build Coastguard Workerallow toolbox system_data_file:dir { rmdir rw_dir_perms };
29*e4a36f41SAndroid Build Coastguard Workerallow toolbox system_data_file:file { getattr unlink };
30*e4a36f41SAndroid Build Coastguard Worker
31*e4a36f41SAndroid Build Coastguard Worker# chattr +F and chattr +P /data/media in init
32*e4a36f41SAndroid Build Coastguard Workerallow toolbox media_rw_data_file:dir { r_dir_perms setattr };
33*e4a36f41SAndroid Build Coastguard Workerallowxperm toolbox media_rw_data_file:dir ioctl {
34*e4a36f41SAndroid Build Coastguard Worker  FS_IOC_FSGETXATTR
35*e4a36f41SAndroid Build Coastguard Worker  FS_IOC_FSSETXATTR
36*e4a36f41SAndroid Build Coastguard Worker  FS_IOC_GETFLAGS
37*e4a36f41SAndroid Build Coastguard Worker  FS_IOC_SETFLAGS
38*e4a36f41SAndroid Build Coastguard Worker};
39