lmkd.te 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # lmkd low memory killer daemon
  2. type lmkd, domain, mlstrustedsubject;
  3. type lmkd_exec, system_file_type, exec_type, file_type;
  4. allow lmkd self:global_capability_class_set { dac_override dac_read_search sys_resource kill };
  5. # lmkd locks itself in memory, to prevent it from being
  6. # swapped out and unable to kill other memory hogs.
  7. # system/core commit b28ff9131363f7b4a698990da5748b2a88c3ed35
  8. # b/16236289
  9. allow lmkd self:global_capability_class_set ipc_lock;
  10. ## Open and write to /proc/PID/oom_score_adj
  11. ## TODO: maybe scope this down?
  12. r_dir_file(lmkd, appdomain)
  13. allow lmkd appdomain:file write;
  14. r_dir_file(lmkd, system_server)
  15. allow lmkd system_server:file write;
  16. ## Writes to /sys/module/lowmemorykiller/parameters/minfree
  17. r_dir_file(lmkd, sysfs_lowmemorykiller)
  18. allow lmkd sysfs_lowmemorykiller:file w_file_perms;
  19. # setsched and send kill signals
  20. allow lmkd appdomain:process { setsched sigkill };
  21. allow lmkd kernel:process { setsched };
  22. # Clean up old cgroups
  23. allow lmkd cgroup:dir { remove_name rmdir };
  24. # Allow to read memcg stats
  25. allow lmkd cgroup:file r_file_perms;
  26. # Set self to SCHED_FIFO
  27. allow lmkd self:global_capability_class_set sys_nice;
  28. allow lmkd proc_zoneinfo:file r_file_perms;
  29. # Set sys.lmk.* properties.
  30. set_prop(lmkd, system_lmk_prop)
  31. # live lock watchdog process allowed to look through /proc/
  32. allow lmkd domain:dir { search open read };
  33. allow lmkd domain:file { open read };
  34. # live lock watchdog process allowed to dump process trace and
  35. # reboot because orderly shutdown may not be possible.
  36. allow lmkd proc_sysrq:file rw_file_perms;
  37. # Read /proc/meminfo
  38. allow lmkd proc_meminfo:file r_file_perms;
  39. # Read /proc/pressure/cpu and /proc/pressure/io
  40. allow lmkd proc_pressure_cpu:file r_file_perms;
  41. allow lmkd proc_pressure_io:file r_file_perms;
  42. # Read/Write /proc/pressure/memory
  43. allow lmkd proc_pressure_mem:file rw_file_perms;
  44. # Allow lmkd to write to statsd.
  45. unix_socket_send(lmkd, statsdw, statsd)
  46. ### neverallow rules
  47. # never honor LD_PRELOAD
  48. neverallow * lmkd:process noatsecure;