blob: f03a138dacc7005d0c2c024570f5ae4eca6b2221 [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
dcashmancc39f632016-07-22 13:13:11 -07006domain_trans(init, rootfs, slideshow)
Tao Baoecc7e8c2018-09-07 15:05:33 -07007domain_auto_trans(init, charger_exec, charger)
Jin Qian4de505b2017-05-02 13:45:08 -07008domain_auto_trans(init, e2fs_exec, e2fs)
Joel Fernandes147cf642018-11-29 13:07:40 -08009domain_auto_trans(init, bpfloader_exec, bpfloader)
10
dcashmancc39f632016-07-22 13:13:11 -070011recovery_only(`
Tao Baoecc7e8c2018-09-07 15:05:33 -070012 # Files in recovery image are labeled as rootfs.
Bowgo Tsai5846c792017-07-31 18:38:28 +080013 domain_trans(init, rootfs, adbd)
Kelvin Zhang19a57852022-08-30 00:12:26 +000014 domain_trans(init, rootfs, hal_bootctl_server)
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)
Yifan Hong705db2b2021-11-15 18:56:22 -080017 domain_trans(init, rootfs, hal_health_server)
dcashmancc39f632016-07-22 13:13:11 -070018 domain_trans(init, rootfs, recovery)
Kiyoung Kim2c271aa2019-12-09 14:57:46 +090019 domain_trans(init, rootfs, linkerconfig)
Yifan Hongd6b29012021-11-13 00:22:01 -080020 domain_trans(init, rootfs, servicemanager)
David Andersond84b67e2021-02-04 12:30:09 -080021 domain_trans(init, rootfs, snapuserd)
dcashmancc39f632016-07-22 13:13:11 -070022')
23domain_trans(init, shell_exec, shell)
24domain_trans(init, init_exec, ueventd)
Tom Cherry621c24c2017-09-28 14:34:36 -070025domain_trans(init, init_exec, vendor_init)
Sandeep Patile41af202017-06-02 16:09:26 -070026domain_trans(init, { rootfs toolbox_exec }, modprobe)
dcashmancc39f632016-07-22 13:13:11 -070027userdebug_or_eng(`
Tom Cherry938ab052018-08-03 10:49:20 -070028 # case where logpersistd is actually logcat -f in logd context (nee: logcatd)
Mark Salyzynda62cb42016-08-10 11:10:02 -070029 domain_auto_trans(init, logcat_exec, logpersist)
Tom Cherry938ab052018-08-03 10:49:20 -070030
31 # allow init to execute services marked with seclabel u:r:su:s0 in userdebug/eng
32 allow init su:process transition;
33 dontaudit init su:process noatsecure;
34 allow init su:process { siginh rlimitinh };
dcashmancc39f632016-07-22 13:13:11 -070035')
Branden Archerd36b1d52018-11-27 15:47:12 -080036
Nikita Ioffe23ba9762019-12-09 21:21:55 +000037# Allow init to figure out name of dm-device from it's /dev/block/dm-XX path.
38# This is useful in case of remounting ext4 userdata into checkpointing mode,
39# since it potentially requires tearing down dm-devices (e.g. dm-bow, dm-crypto)
40# that userdata is mounted onto.
41allow init sysfs_dm:file read;
42
Bart Van Assche9059e212021-07-29 14:53:51 -070043# Allow init to modify the properties of loop devices.
44allow init sysfs_loop:dir r_dir_perms;
45allow init sysfs_loop:file rw_file_perms;
46
Bart Van Assche60b7d9a2021-10-13 16:21:54 +000047# Allow init to examine the properties of block devices.
Bart Van Assche398b0af2021-10-13 10:56:57 -070048allow init sysfs_type:file { getattr read };
49# Allow init get the attributes of block devices in /dev/block.
50allow init dev_type:dir r_dir_perms;
51allow init dev_type:blk_file getattr;
Bart Van Assche60b7d9a2021-10-13 16:21:54 +000052
Michael Rosenfeld3ccbebb2021-02-10 18:45:35 -080053# Allow init to write to the drop_caches file.
54allow init proc_drop_caches:file rw_file_perms;
55
Branden Archerd36b1d52018-11-27 15:47:12 -080056# Allow the BoringSSL self test to request a reboot upon failure
57set_prop(init, powerctl_prop)
Nikita Ioffe7065e462019-11-14 12:59:15 +000058
59# Only init is allowed to set userspace reboot related properties.
Nikita Ioffe7065e462019-11-14 12:59:15 +000060set_prop(init, userspace_reboot_exported_prop)
Nikita Ioffe7065e462019-11-14 12:59:15 +000061neverallow { domain -init } userspace_reboot_exported_prop:property_service set;
Ryan Savitski52b3d312020-01-14 18:20:06 +000062
63# Second-stage init performs a test for whether the kernel has SELinux hooks
64# for the perf_event_open() syscall. This is done by testing for the syscall
65# outcomes corresponding to this policy.
66# TODO(b/137092007): this can be removed once the platform stops supporting
67# kernels that precede the perf_event_open hooks (Android common kernels 4.4
68# and 4.9).
69allow init self:perf_event { open cpu };
Alistair Delva178f0ac2020-06-05 10:15:30 -070070allow init self:global_capability2_class_set perfmon;
Ryan Savitski52b3d312020-01-14 18:20:06 +000071neverallow init self:perf_event { kernel tracepoint read write };
72dontaudit init self:perf_event { kernel tracepoint read write };
73
David Anderson0c0c13a2020-10-30 00:12:22 -070074# Allow init to communicate with snapuserd to transition Virtual A/B devices
75# from the first-stage daemon to the second-stage.
76allow init snapuserd_socket:sock_file write;
77allow init snapuserd:unix_stream_socket connectto;
78# Allow for libsnapshot's use of flock() on /metadata/ota.
79allow init ota_metadata_file:dir lock;
80
Jooyung Hanb62be122021-04-12 21:44:43 +090081# Allow init to restore contexts of vd_device(/dev/block/vd[..]) when labeling
82# /dev/block.
83allow init vd_device:blk_file relabelto;
84
Ryan Savitski52b3d312020-01-14 18:20:06 +000085# Only init is allowed to set the sysprop indicating whether perf_event_open()
86# SELinux hooks were detected.
87set_prop(init, init_perf_lsm_hooks_prop)
88neverallow { domain -init } init_perf_lsm_hooks_prop:property_service set;
Inseob Kim212e2b62020-07-14 02:10:37 +090089
90# Only init can write vts.native_server.on
91set_prop(init, vts_status_prop)
Inseob Kim85acf6e2021-03-10 10:42:23 +090092neverallow { domain -init } vts_status_prop:property_service set;
Inseob Kim8c342472020-07-23 17:54:35 +090093
94# Only init can write normal ro.boot. properties
Inseob Kim85acf6e2021-03-10 10:42:23 +090095neverallow { domain -init } bootloader_prop:property_service set;
Inseob Kim40c67b22020-07-25 00:34:56 +090096
Enrico Granata645c3902021-10-01 13:11:36 -060097# Only init can write ro.boot.hypervisor properties
98neverallow { domain -init } hypervisor_prop:property_service set;
99
Inseob Kim40c67b22020-07-25 00:34:56 +0900100# Only init can write hal.instrumentation.enable
Inseob Kim85acf6e2021-03-10 10:42:23 +0900101neverallow { domain -init } hal_instrumentation_prop:property_service set;
Inseob Kim40c67b22020-07-25 00:34:56 +0900102
103# Only init can write ro.property_service.version
Inseob Kim85acf6e2021-03-10 10:42:23 +0900104neverallow { domain -init } property_service_version_prop:property_service set;
Paul Crowleyb0c55712021-02-23 08:40:05 -0800105
106# Only init can set keystore.boot_level
Inseob Kim85acf6e2021-03-10 10:42:23 +0900107neverallow { domain -init } keystore_listen_prop:property_service set;
Alexander Potapenko3d528172021-03-02 16:46:50 +0100108
109# Allow accessing /sys/kernel/tracing/instances/bootreceiver to set up tracing.
110allow init debugfs_bootreceiver_tracing:file w_file_perms;
Andrew Walbrana995e842021-03-29 17:19:12 +0000111
Pete Bentleye6da3b82022-09-16 15:31:39 +0100112# PRNG seeder daemon socket is created and listened on by init before forking.
113allow init prng_seeder:unix_stream_socket { create bind listen };
114
Kalesh Singhfab8e1c2021-11-04 20:47:29 -0700115# Devices with kernels where CONFIG_HIST_TRIGGERS isn't enabled will
116# attempt to write a non exisiting 'synthetic_events' file, when setting
117# up synthetic events. This is a no-op in tracefs.
118dontaudit init debugfs_tracing_debug:dir { write add_name };
119
Andrew Walbrana995e842021-03-29 17:19:12 +0000120# chown/chmod on devices.
121allow init {
122 dev_type
123 -hw_random_device
124 -keychord_device
125 -kvm_device
126 -port_device
127}:chr_file setattr;