fsck_untrusted.te 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Any fsck program run on untrusted block devices
  2. type fsck_untrusted, domain;
  3. # Inherit and use pty created by android_fork_execvp_ext().
  4. allow fsck_untrusted devpts:chr_file { read write ioctl getattr };
  5. # Allow stdin/out back to vold
  6. allow fsck_untrusted vold:fd use;
  7. allow fsck_untrusted vold:fifo_file { read write getattr };
  8. # Run fsck on vold block devices
  9. allow fsck_untrusted block_device:dir search;
  10. allow fsck_untrusted vold_device:blk_file rw_file_perms;
  11. allow fsck_untrusted proc_mounts:file r_file_perms;
  12. # To determine if it is safe to run fsck on a filesystem, e2fsck
  13. # must first determine if the filesystem is mounted. To do that,
  14. # e2fsck scans through /proc/mounts and collects all the mounted
  15. # block devices. With that information, it runs stat() on each block
  16. # device, comparing the major and minor numbers to the filesystem
  17. # passed in on the command line. If there is a match, then the filesystem
  18. # is currently mounted and running fsck is dangerous.
  19. # Allow stat access to all block devices so that fsck can compare
  20. # major/minor values.
  21. allow fsck_untrusted dev_type:blk_file getattr;
  22. ###
  23. ### neverallow rules
  24. ###
  25. # Untrusted fsck should never be run on block devices holding sensitive data
  26. neverallow fsck_untrusted {
  27. boot_block_device
  28. frp_block_device
  29. metadata_block_device
  30. recovery_block_device
  31. root_block_device
  32. swap_block_device
  33. system_block_device
  34. userdata_block_device
  35. cache_block_device
  36. dm_device
  37. }:blk_file no_rw_file_perms;
  38. # Only allow entry from vold via fsck binaries
  39. neverallow { domain -vold } fsck_untrusted:process transition;
  40. neverallow * fsck_untrusted:process dyntransition;
  41. neverallow fsck_untrusted { file_type fs_type -fsck_exec }:file entrypoint;