blob: 682831ff26f3a5495639c6c1d2720e3c3181d8f2 [file] [log] [blame]
Alex Klyubinf5446eb2017-03-23 14:27:32 -07001typeattribute fsck_untrusted coredomain;
Inseob Kim75806ef2024-03-27 17:18:41 +09002
3# Inherit and use pty created by android_fork_execvp_ext().
4allow fsck_untrusted devpts:chr_file { read write ioctl getattr };
5
6# Allow stdin/out back to vold
7allow fsck_untrusted vold:fd use;
8allow fsck_untrusted vold:fifo_file { read write getattr };
9
10# Run fsck on vold block devices
11allow fsck_untrusted block_device:dir search;
12allow fsck_untrusted vold_device:blk_file rw_file_perms;
13
14allow fsck_untrusted proc_mounts:file r_file_perms;
15
16# To determine if it is safe to run fsck on a filesystem, e2fsck
17# must first determine if the filesystem is mounted. To do that,
18# e2fsck scans through /proc/mounts and collects all the mounted
19# block devices. With that information, it runs stat() on each block
20# device, comparing the major and minor numbers to the filesystem
21# passed in on the command line. If there is a match, then the filesystem
22# is currently mounted and running fsck is dangerous.
23# Allow stat access to all block devices so that fsck can compare
24# major/minor values.
25allow fsck_untrusted dev_type:blk_file getattr;
26
27###
28### neverallow rules
29###
30
31# Untrusted fsck should never be run on block devices holding sensitive data
32neverallow fsck_untrusted {
33 boot_block_device
34 frp_block_device
35 metadata_block_device
36 recovery_block_device
37 root_block_device
38 swap_block_device
39 system_block_device
40 userdata_block_device
41 cache_block_device
42 dm_device
43}:blk_file no_rw_file_perms;
44
45# Only allow entry from vold via fsck binaries
46neverallow { domain -vold } fsck_untrusted:process transition;
47neverallow * fsck_untrusted:process dyntransition;
48neverallow fsck_untrusted { file_type fs_type -fsck_exec }:file entrypoint;
49
50# fsck_untrusted should never have sys_admin permissions. If it requires sys_admin
51# permissions, that is a code mistake that needs to be fixed, not a permission that
52# should be granted. Same with setgid and setuid.
53neverallow fsck_untrusted self:global_capability_class_set { setgid setuid sys_admin };
54
55###
56### dontaudit rules
57###
58
59# Ignores attempts to access sysfs. fsck binaries seem to like trying to go
60# here, but nothing bad happens if they can't, and they shouldn't be allowed.
61dontaudit fsck_untrusted sysfs:file rw_file_perms;
62dontaudit fsck_untrusted sysfs_dm:file rw_file_perms;
63dontaudit fsck_untrusted sysfs_dm:dir rw_dir_perms;
64
65# Ignore attempts to access tmpfs. fsck don't need to do this.
66dontaudit fsck_untrusted tmpfs:lnk_file read;