blob: 62ac06b669a8d82090d063339a4a9f5a807f5bd5 [file] [log] [blame]
David Anderson6d53efc2019-01-14 14:38:17 -08001# gsid - Manager for GSI Installation
2
3type gsid, domain;
4type gsid_exec, exec_type, file_type, system_file_type;
5typeattribute gsid coredomain;
6
7init_daemon_domain(gsid)
8
9binder_use(gsid)
David Andersondb90b912019-01-22 19:05:29 -080010binder_service(gsid)
David Anderson6d53efc2019-01-14 14:38:17 -080011add_service(gsid, gsi_service)
David Anderson8fe3c742019-02-07 13:14:20 -080012set_prop(gsid, gsid_prop)
David Andersondb90b912019-01-22 19:05:29 -080013
14# Needed to create/delete device-mapper nodes, and read/write to them.
15allow gsid dm_device:chr_file rw_file_perms;
16allow gsid dm_device:blk_file rw_file_perms;
17allow gsid self:global_capability_class_set sys_admin;
18dontaudit gsid self:global_capability_class_set dac_override;
19
20# libfiemap_writer uses sysfs to derive the bottom of a device-mapper stacking.
21# This requires traversing /sys/block/dm-N/slaves/* and reading the list of
22# file names.
23allow gsid sysfs_dm:dir r_dir_perms;
24
25# Needed to stat /data/gsi/* and realpath on /dev/block/by-name/*
26allow gsid block_device:dir r_dir_perms;
27
28# liblp queries these block alignment properties.
29allowxperm gsid userdata_block_device:blk_file ioctl {
30 BLKIOMIN
31 BLKALIGNOFF
32};
33
34# gsi_tool passes the system image over the adb connection, via stdin.
35allow gsid adbd:fd use;
36
David Anderson8fe3c742019-02-07 13:14:20 -080037neverallow { domain -gsid -init } gsid_prop:property_service set;
38
David Andersondb90b912019-01-22 19:05:29 -080039# gsid needs to store images on /data, but cannot use file I/O. If it did, the
40# underlying blocks would be encrypted, and we couldn't mount the GSI image in
41# first-stage init. So instead of directly writing to /data, we:
42#
43# 1. fallocate a file large enough to hold the signed GSI
44# 2. extract its block layout with FIEMAP
45# 3. create a dm-linear device using the FIEMAP, targeting /dev/block/by-name/userdata
46# 4. write system_gsi into that dm device
47#
48# To make this process work, we need to unwrap the device-mapper stacking for
49# userdata to reach the underlying block device. To verify the result we use
50# stat(), which requires read access.
51allow gsid userdata_block_device:blk_file r_file_perms;
52
53# gsid uses /metadata/gsi to communicate GSI boot information to first-stage
54# init. It cannot use userdata since data cannot be decrypted during this
55# stage.
56#
57# gsid uses /metadata/gsi to store three files:
58# install_status - A short string indicating whether a GSI image is bootable.
59# lp_metadata - LpMetadata blob describing the block ranges on userdata
60# where system_gsi resides.
61# booted - An empty file that, if exists, indicates that a GSI is
62# currently running.
63#
64allow gsid metadata_file:dir search;
65allow gsid gsi_metadata_file:dir rw_dir_perms;
66allow gsid gsi_metadata_file:file create_file_perms;
67
68allow gsid gsi_data_file:dir rw_dir_perms;
69allow gsid gsi_data_file:file create_file_perms;
70allowxperm gsid gsi_data_file:file ioctl FS_IOC_FIEMAP;
71
72neverallow {
73 domain
74 -init
75 -gsid
76 -fastbootd
77 -vold
78} gsi_metadata_file:dir *;
79
80neverallow {
81 domain
82 -init
83 -gsid
84 -fastbootd
85 -vold
86} gsi_metadata_file:notdevfile_class_set ~{ relabelto getattr };
87
88neverallow {
89 domain
90 -init
91 -gsid
92 -fastbootd
93 -vold
94} { gsi_data_file gsi_metadata_file }:notdevfile_class_set *;
95
96neverallow {
97 domain
98 -gsid
99} gsi_data_file:dir ~{ open create read getattr setattr search relabelto ioctl };
100
101neverallow {
102 domain
103 -init
104 -gsid
105} gsi_data_file:dir *;
106
107neverallow {
108 domain
109 -gsid
110} gsi_data_file:notdevfile_class_set ~{ relabelto getattr };