1# lmkd low memory killer daemon
2type lmkd, domain, domain_deprecated, mlstrustedsubject;
3type lmkd_exec, exec_type, file_type;
4
5init_daemon_domain(lmkd)
6
7allow lmkd self:capability { dac_override sys_resource kill };
8
9# lmkd locks itself in memory, to prevent it from being
10# swapped out and unable to kill other memory hogs.
11# system/core commit b28ff9131363f7b4a698990da5748b2a88c3ed35
12# b/16236289
13allow lmkd self:capability ipc_lock;
14
15## Open and write to /proc/PID/oom_score_adj
16## TODO: maybe scope this down?
17r_dir_file(lmkd, appdomain)
18allow lmkd appdomain:file write;
19r_dir_file(lmkd, autoplay_app)
20allow lmkd autoplay_app:file write;
21r_dir_file(lmkd, system_server)
22allow lmkd system_server:file write;
23
24## Writes to /sys/module/lowmemorykiller/parameters/minfree
25r_dir_file(lmkd, sysfs_type)
26allow lmkd sysfs_lowmemorykiller:file w_file_perms;
27
28# Send kill signals
29allow lmkd appdomain:process sigkill;
30
31# Clean up old cgroups
32allow lmkd cgroup:dir { remove_name rmdir };
33
34# Set self to SCHED_FIFO
35allow lmkd self:capability sys_nice;
36
37### neverallow rules
38
39# never honor LD_PRELOAD
40neverallow * lmkd:process noatsecure;
41