blob: 348673bcddd45728f22c045b3fe4ed720d2f921e [file] [log] [blame]
Alex Klyubinf5446eb2017-03-23 14:27:32 -07001typeattribute init coredomain;
2
dcashmancc39f632016-07-22 13:13:11 -07003tmpfs_domain(init)
4
5# Transitions to seclabel processes in init.rc
Sandeep Patil137a13d2016-12-15 12:36:45 -08006domain_trans(init, rootfs, healthd)
dcashmancc39f632016-07-22 13:13:11 -07007domain_trans(init, rootfs, slideshow)
Tao Baoecc7e8c2018-09-07 15:05:33 -07008domain_auto_trans(init, charger_exec, charger)
Jin Qian4de505b2017-05-02 13:45:08 -07009domain_auto_trans(init, e2fs_exec, e2fs)
Joel Fernandes147cf642018-11-29 13:07:40 -080010domain_auto_trans(init, bpfloader_exec, bpfloader)
11
dcashmancc39f632016-07-22 13:13:11 -070012recovery_only(`
Tao Baoecc7e8c2018-09-07 15:05:33 -070013 # Files in recovery image are labeled as rootfs.
Bowgo Tsai5846c792017-07-31 18:38:28 +080014 domain_trans(init, rootfs, adbd)
Tao Baoecc7e8c2018-09-07 15:05:33 -070015 domain_trans(init, rootfs, charger)
Jerry Zhang1d85efa2018-05-29 10:54:16 -070016 domain_trans(init, rootfs, fastbootd)
dcashmancc39f632016-07-22 13:13:11 -070017 domain_trans(init, rootfs, recovery)
Kiyoung Kim2c271aa2019-12-09 14:57:46 +090018 domain_trans(init, rootfs, linkerconfig)
David Andersond84b67e2021-02-04 12:30:09 -080019 domain_trans(init, rootfs, snapuserd)
dcashmancc39f632016-07-22 13:13:11 -070020')
21domain_trans(init, shell_exec, shell)
22domain_trans(init, init_exec, ueventd)
Tom Cherry621c24c2017-09-28 14:34:36 -070023domain_trans(init, init_exec, vendor_init)
Sandeep Patile41af202017-06-02 16:09:26 -070024domain_trans(init, { rootfs toolbox_exec }, modprobe)
dcashmancc39f632016-07-22 13:13:11 -070025userdebug_or_eng(`
Tom Cherry938ab052018-08-03 10:49:20 -070026 # case where logpersistd is actually logcat -f in logd context (nee: logcatd)
Mark Salyzynda62cb42016-08-10 11:10:02 -070027 domain_auto_trans(init, logcat_exec, logpersist)
Tom Cherry938ab052018-08-03 10:49:20 -070028
29 # allow init to execute services marked with seclabel u:r:su:s0 in userdebug/eng
30 allow init su:process transition;
31 dontaudit init su:process noatsecure;
32 allow init su:process { siginh rlimitinh };
dcashmancc39f632016-07-22 13:13:11 -070033')
Branden Archerd36b1d52018-11-27 15:47:12 -080034
Nikita Ioffe23ba9762019-12-09 21:21:55 +000035# Allow init to figure out name of dm-device from it's /dev/block/dm-XX path.
36# This is useful in case of remounting ext4 userdata into checkpointing mode,
37# since it potentially requires tearing down dm-devices (e.g. dm-bow, dm-crypto)
38# that userdata is mounted onto.
39allow init sysfs_dm:file read;
40
Branden Archerd36b1d52018-11-27 15:47:12 -080041# Allow the BoringSSL self test to request a reboot upon failure
42set_prop(init, powerctl_prop)
Nikita Ioffe7065e462019-11-14 12:59:15 +000043
44# Only init is allowed to set userspace reboot related properties.
Nikita Ioffe7065e462019-11-14 12:59:15 +000045set_prop(init, userspace_reboot_exported_prop)
Nikita Ioffe7065e462019-11-14 12:59:15 +000046neverallow { domain -init } userspace_reboot_exported_prop:property_service set;
Ryan Savitski52b3d312020-01-14 18:20:06 +000047
48# Second-stage init performs a test for whether the kernel has SELinux hooks
49# for the perf_event_open() syscall. This is done by testing for the syscall
50# outcomes corresponding to this policy.
51# TODO(b/137092007): this can be removed once the platform stops supporting
52# kernels that precede the perf_event_open hooks (Android common kernels 4.4
53# and 4.9).
54allow init self:perf_event { open cpu };
Alistair Delva178f0ac2020-06-05 10:15:30 -070055allow init self:global_capability2_class_set perfmon;
Ryan Savitski52b3d312020-01-14 18:20:06 +000056neverallow init self:perf_event { kernel tracepoint read write };
57dontaudit init self:perf_event { kernel tracepoint read write };
58
David Anderson0c0c13a2020-10-30 00:12:22 -070059# Allow init to communicate with snapuserd to transition Virtual A/B devices
60# from the first-stage daemon to the second-stage.
61allow init snapuserd_socket:sock_file write;
62allow init snapuserd:unix_stream_socket connectto;
63# Allow for libsnapshot's use of flock() on /metadata/ota.
64allow init ota_metadata_file:dir lock;
65
Ryan Savitski52b3d312020-01-14 18:20:06 +000066# Only init is allowed to set the sysprop indicating whether perf_event_open()
67# SELinux hooks were detected.
68set_prop(init, init_perf_lsm_hooks_prop)
69neverallow { domain -init } init_perf_lsm_hooks_prop:property_service set;
Inseob Kim212e2b62020-07-14 02:10:37 +090070
71# Only init can write vts.native_server.on
72set_prop(init, vts_status_prop)
73neverallow { -init } vts_status_prop:property_service set;
Inseob Kim8c342472020-07-23 17:54:35 +090074
75# Only init can write normal ro.boot. properties
76neverallow { -init } bootloader_prop:property_service set;
Inseob Kim40c67b22020-07-25 00:34:56 +090077
78# Only init can write hal.instrumentation.enable
79neverallow { -init } hal_instrumentation_prop:property_service set;
80
81# Only init can write ro.property_service.version
82neverallow { -init } property_service_version_prop:property_service set;
Paul Crowleyb0c55712021-02-23 08:40:05 -080083
84# Only init can set keystore.boot_level
85neverallow { -init } keystore_listen_prop:property_service set;