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