blob: 4312444f87075c791400e9c5e7526079b81eca89 [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
Bart Van Assche9059e212021-07-29 14:53:51 -070041# Allow init to modify the properties of loop devices.
42allow init sysfs_loop:dir r_dir_perms;
43allow init sysfs_loop:file rw_file_perms;
44
Michael Rosenfeld3ccbebb2021-02-10 18:45:35 -080045# Allow init to write to the drop_caches file.
46allow init proc_drop_caches:file rw_file_perms;
47
Branden Archerd36b1d52018-11-27 15:47:12 -080048# Allow the BoringSSL self test to request a reboot upon failure
49set_prop(init, powerctl_prop)
Nikita Ioffe7065e462019-11-14 12:59:15 +000050
51# Only init is allowed to set userspace reboot related properties.
Nikita Ioffe7065e462019-11-14 12:59:15 +000052set_prop(init, userspace_reboot_exported_prop)
Nikita Ioffe7065e462019-11-14 12:59:15 +000053neverallow { domain -init } userspace_reboot_exported_prop:property_service set;
Ryan Savitski52b3d312020-01-14 18:20:06 +000054
55# Second-stage init performs a test for whether the kernel has SELinux hooks
56# for the perf_event_open() syscall. This is done by testing for the syscall
57# outcomes corresponding to this policy.
58# TODO(b/137092007): this can be removed once the platform stops supporting
59# kernels that precede the perf_event_open hooks (Android common kernels 4.4
60# and 4.9).
61allow init self:perf_event { open cpu };
Alistair Delva178f0ac2020-06-05 10:15:30 -070062allow init self:global_capability2_class_set perfmon;
Ryan Savitski52b3d312020-01-14 18:20:06 +000063neverallow init self:perf_event { kernel tracepoint read write };
64dontaudit init self:perf_event { kernel tracepoint read write };
65
David Anderson0c0c13a2020-10-30 00:12:22 -070066# Allow init to communicate with snapuserd to transition Virtual A/B devices
67# from the first-stage daemon to the second-stage.
68allow init snapuserd_socket:sock_file write;
69allow init snapuserd:unix_stream_socket connectto;
70# Allow for libsnapshot's use of flock() on /metadata/ota.
71allow init ota_metadata_file:dir lock;
72
Jooyung Hanb62be122021-04-12 21:44:43 +090073# Allow init to restore contexts of vd_device(/dev/block/vd[..]) when labeling
74# /dev/block.
75allow init vd_device:blk_file relabelto;
76
Ryan Savitski52b3d312020-01-14 18:20:06 +000077# Only init is allowed to set the sysprop indicating whether perf_event_open()
78# SELinux hooks were detected.
79set_prop(init, init_perf_lsm_hooks_prop)
80neverallow { domain -init } init_perf_lsm_hooks_prop:property_service set;
Inseob Kim212e2b62020-07-14 02:10:37 +090081
82# Only init can write vts.native_server.on
83set_prop(init, vts_status_prop)
Inseob Kim85acf6e2021-03-10 10:42:23 +090084neverallow { domain -init } vts_status_prop:property_service set;
Inseob Kim8c342472020-07-23 17:54:35 +090085
86# Only init can write normal ro.boot. properties
Inseob Kim85acf6e2021-03-10 10:42:23 +090087neverallow { domain -init } bootloader_prop:property_service set;
Inseob Kim40c67b22020-07-25 00:34:56 +090088
Enrico Granata645c3902021-10-01 13:11:36 -060089# Only init can write ro.boot.hypervisor properties
90neverallow { domain -init } hypervisor_prop:property_service set;
91
Inseob Kim40c67b22020-07-25 00:34:56 +090092# Only init can write hal.instrumentation.enable
Inseob Kim85acf6e2021-03-10 10:42:23 +090093neverallow { domain -init } hal_instrumentation_prop:property_service set;
Inseob Kim40c67b22020-07-25 00:34:56 +090094
95# Only init can write ro.property_service.version
Inseob Kim85acf6e2021-03-10 10:42:23 +090096neverallow { domain -init } property_service_version_prop:property_service set;
Paul Crowleyb0c55712021-02-23 08:40:05 -080097
98# Only init can set keystore.boot_level
Inseob Kim85acf6e2021-03-10 10:42:23 +090099neverallow { domain -init } keystore_listen_prop:property_service set;
Alexander Potapenko3d528172021-03-02 16:46:50 +0100100
101# Allow accessing /sys/kernel/tracing/instances/bootreceiver to set up tracing.
102allow init debugfs_bootreceiver_tracing:file w_file_perms;
Andrew Walbrana995e842021-03-29 17:19:12 +0000103
104# chown/chmod on devices.
105allow init {
106 dev_type
107 -hw_random_device
108 -keychord_device
109 -kvm_device
110 -port_device
111}:chr_file setattr;