Commit graph

308 commits

Author SHA1 Message Date
Alice Wang
334640c993 Merge "[cleanup] Remove permissions about binderfs inside microdroid" 2022-11-23 11:34:29 +00:00
Alice Wang
4a608c1960 [cleanup] Remove microdroid_service_context and its usages
As service_manager has been removed in microdroid.

Bug: 257260848
Test: atest MicrodroidTests MicrodroidHostTests

Change-Id: I05b3366a14ecd8d6aabfff5eca9b6fbf804dc97a
2022-11-23 10:03:53 +00:00
Alice Wang
79629bdd60 [cleanup] Remove permissions about binderfs inside microdroid
The binderfs in microdroid has been removed in aosp/2310572.

Bug: 222479468
Test: atest MicrodroidTests MicrodroidHostTests
Change-Id: I757ae39ebc841e8bb23300c4f65a3646ad8031fb
2022-11-22 21:22:38 +00:00
Alice Wang
0065888fe7 [cleanup] Remove unneeded apex_service permissions in microdroid
As microdroid doesn't use apex_service.

Bug: 222479468
Test: atest MicrodroidTests MicrodroidHostTests
Change-Id: Ie79473322905bda56c57d91f3c524ad715c99aff
2022-11-22 21:21:30 +00:00
Alice Wang
160ad719fb Merge "[cleanup] Remove permissions about servicemanager_prop inside microdroid" 2022-11-22 21:06:51 +00:00
Treehugger Robot
4c240dcaab Merge "Encryptedstore/Selinux: Format the crypt device" 2022-11-22 19:33:09 +00:00
Shikha Panwar
c6ff74a210 Encryptedstore/Selinux: Format the crypt device
Add selinux policies required for formatting the crypt device.
1. Allow encryptedstore to execute mk2fs.
2. The execution will happen without domain transition - so add
   permissions related to formatting the device.
3. Allow encryptedstore to write on /dev/vd device - required to zero
   starting bits initially

Test: Run vm with --storage & --storage-size option
Bug: 241541860
Change-Id: I9766e3c67e47a58707beee8b3a156944e3b0a9ce
2022-11-22 17:42:01 +00:00
Alice Wang
7358947455 Merge "[cleanup] Remove permissions about servicemanager inside microdroid" 2022-11-22 15:57:36 +00:00
Alice Wang
165148e62c [cleanup] Remove permissions about servicemanager_prop inside microdroid
As servicemanager is removed from microdroid.

Bug: 222479468
Test: atest MicrodroidTests MicrodroidHostTests
Change-Id: Ie39e4b214f297258f3dceecc11fa3d8289af3be4
2022-11-22 14:55:47 +00:00
Alice Wang
574be921af [cleanup] Remove permissions about servicemanager inside microdroid
Bug: 222479468
Test: atest MicrodroidTests MicrodroidHostTests
Change-Id: I562d0d018f0dbd7d4b93c39b2bde4d2a8b50de13
2022-11-22 14:36:09 +00:00
Treehugger Robot
ea83f4f046 Merge "Revert "Add listen/accept permission to MM's vsock"" 2022-11-22 13:52:20 +00:00
Alice Wang
05bd25482d Merge "[microdroid] Remove microdroid.servicemanager related permissions" 2022-11-22 12:34:04 +00:00
David Brazdil
909e3b9cf9 Revert "Add listen/accept permission to MM's vsock"
Unused since Ib7d1491e264539ffcc40442fdf419ce50d8cecf5.
This reverts commit 5df428bea8.

Bug: 253221932
Test: TH
Change-Id: Icc2aa0bbd05591a53458b1f5fbd2c442dfce7208
2022-11-22 11:52:29 +00:00
Shikha Panwar
f447a0bf07 Merge "encryptedstore - Create Selinux context & grant permissions" 2022-11-22 11:07:50 +00:00
Alice Wang
4925b34400 [microdroid] Remove microdroid.servicemanager related permissions
Since the microdroid.servicemanager has been removed.

Bug: 222479468
Test: atest MicrodroidTests MicrodroidHostTests
Change-Id: I90228ca2d1bc3c66a6967412942e1c3372ed09ca
2022-11-22 08:30:25 +00:00
Treehugger Robot
5a28628dbe Merge "Allow apkdmverity/zipfuse to write to kmsg_debug" 2022-11-22 03:00:37 +00:00
Inseob Kim
e987dcff74 Allow apkdmverity/zipfuse to write to kmsg_debug
..which is inherited from microdroid_manager.

Bug: 258760809
Test: atest MicrodroidHostTestCases MicrodroidTestApp
Change-Id: I839a0e6b4702e811db58b0cc44dd3b599c10a0b8
2022-11-22 10:13:48 +09:00
Alice Wang
3a7809a818 Merge "Cleanup authfs_service / servicemanager communication permissions" 2022-11-21 12:13:27 +00:00
Alice Wang
33fba3f1eb [rpc_binder] Remove permissions about virual_machine_payload_service
This cl removes the SELinux permissions about
virual_machine_payload_service / servicemanager communication.

Bug: 257260848
Test: atest MicrodroidTests
Change-Id: I2aeac92bdba7db1256ca48cdfca2265441882abf
2022-11-21 09:42:06 +00:00
Alice Wang
1a0c3f88e0 Cleanup authfs_service / servicemanager communication permissions
This cl removes SELinux policies related to
authfs_service / servicemanager communication as authfs_service
now uses rpc binder instead of servicemanager.

Bug: 257260848
Test: atest ComposHostTestCases
Change-Id: I3e3de94a837c95e8f486438cc6a76fea39ffc6f3
2022-11-21 09:29:41 +00:00
Inseob Kim
29fb4ae40b Merge changes from topic "microdroid_selinux_denial_fix"
* changes:
  Add listen/accept permission to MM's vsock
  Grant kmsg_debug permission to kexec
2022-11-18 12:04:34 +00:00
Alice Wang
b1c2e19a71 [rpc_binder] Enable connection for authfs_service socket
Bug: 222479468
Test: atest ComposHostTestCases
Change-Id: I2e60010beebf05391c7df6d38ef7be976ad8d06f
2022-11-18 09:22:20 +00:00
Inseob Kim
5df428bea8 Add listen/accept permission to MM's vsock
Bug: 259241719
Test: atest MicrodroidHostTestCases MicrodroidTestApp
Change-Id: I7403b2ae777fd72bb056b5cb260e693ef0793cff
2022-11-17 14:57:41 +00:00
Inseob Kim
cb2c533d83 Grant kmsg_debug permission to kexec
microdroid_manager has stdio_to_kmsg, so it's good to have the same
permission to microdroid_manager's children for better debuggability.

Bug: 259241719
Test: atest MicrodroidHostTestCases MicrodroidTestApp
Change-Id: Ibaaed365e970e6b9f2d458ccae4d128fd3b84f38
2022-11-17 14:57:17 +00:00
Shikha Panwar
81bf90de4d encryptedstore - Create Selinux context & grant permissions
encryptedstore is Microdroid's dm-crypt based encryption solution. It
requires access to block device, mapper devices etc.

Test: Run a VM & look for sepolicy denials.
Bug: 241541860
Change-Id: I556f56a184fc7a1ea71d67c3e591cc567dab2431
2022-11-16 18:18:34 +00:00
Treehugger Robot
069b9502b1 Merge "Allow microdroid_manager to do stdio_to_kmsg" 2022-11-14 13:48:17 +00:00
Inseob Kim
22c1bff56b Allow microdroid_manager to do stdio_to_kmsg
To track any possible bugs on microdroid_manager.

Bug: 258760809
Test: intentionally crash microdroid_manager and see console
Change-Id: I6cd24f3129d153159d76115c833a80353aeee42a
2022-11-14 17:59:08 +09:00
David Brazdil
9d8002113a microdroid: Allow microdroid_manager to get local CID
This is needed to determine the host VirtualMachineService port number.

Bug: 245727626
Test: atest -p packages/modules/Virtualization:avf-presubmit
Change-Id: Iec58ce8adcac27f9ac5e6b07d53e6ef093c1193e
2022-11-11 15:13:12 +00:00
Alice Wang
a818fa2ee2 [rpc_binder] Enable connection with vm_payload_service
Bug: 222479468
Test: atest MicrodroidTests
Change-Id: I85d4d2e2272143b0a1b044c307792feffde4cdf6
2022-11-10 08:00:36 +00:00
Victor Hsieh
069a98c6ad Remove proc_fs_verity as it's not used in microdroid
Bug: 249158715
Test: TH
Change-Id: I30c0feaf73c8825fc1c0041029b78353d767e0f8
2022-11-03 15:44:40 -07:00
Alan Stokes
960e186823 Don't allow payload to connect to host
The payload can listen for inbound connections from the host (routed
via Virtualization Service), but should not be connecting out to the
host - by doing so a VM could connect to an unrelated host process.

(authfs still connects outbound, but has its own domain.)

Bug: 243647186
Test: atest MicrodroidTests ComposHostTestCases
Change-Id: I16d225975d6bcbe647c5fbff21b10465eacd9cb6
2022-10-26 11:23:07 +01:00
Nikita Ioffe
d0fb527326 Switch to tombstoned.microdroid
Bug: 239367015
Test: microdroid presubmits
Change-Id: I01b4cc90425d79c5b33b8e17bf9fe942c3d6233b
2022-10-24 15:36:19 +01:00
Rob Seymour
9833c60b35 Merge "Allow service managers access to apex data." 2022-10-14 18:04:46 +00:00
Keir Fraser
5cbe30c386 Allow microdroid_manager to create a ZRAM swap device
Bug: 238284600
Test: Start a VM, confirm swap is available
Change-Id: I5b6050fabd652d9c15584afa0bfdc10b33401dd1
2022-10-13 14:22:15 +00:00
Treehugger Robot
c3b7489ee5 Merge "Fix too-broad allows granted to domain" 2022-10-13 05:37:13 +00:00
Inseob Kim
4e141f6241 Fix too-broad allows granted to domain
These are wrongly added to microdroid policy while bring up. The
permissions should be restricted to select domains.

Bug: 248478536
Test: atest MicrodroidTests MicrodroidHostTestCases
Change-Id: I9cd94728e84dfd4d69e1bc8e979d204d9d9afbd1
2022-10-13 13:14:29 +09:00
Seungjae Yoo
3ad46dcaa4 Allow reading some files in /proc by microdroid_manager
Bug: 236253808
Test: N/A
Change-Id: I5e5062335ace5c511aab2216c3745a2c8aa1204e
2022-10-11 10:30:03 +09:00
Treehugger Robot
24b66bcf11 Merge "Fix zipfuse race condition" 2022-10-10 15:51:12 +00:00
Andrew Scull
6892b3f212 Move DICE logic into microdroid_manager
The DICE service is deleted and microdroid_maanger takes over the DICE
logic.

Bug: 243133253
Test: atest MicrodroidTests
Test: atest ComposHostTestCases
Change-Id: Idc4cb53f46aa0bc1f197c6267b05f6c5678a34ae
2022-10-07 17:53:50 +00:00
Alan Stokes
fb9911a9bb Fix zipfuse race condition
Allow zipfuse to signal to microdroid_manager via property when it is
ready.

Bug: 243513572
Test: atest MicrodroidTests (locally & via acloud)
Change-Id: Ifcf3d0924faa61ce87124a5ac55bd6a2b193cd99
2022-10-07 16:37:37 +01:00
Alice Wang
34c9f94938 Allow the microdroid app to use vm payload service
Bug: 243512047
Test: atest MicrodroidTestApp
Change-Id: I651781a7cf87b3fa31828a1b46d33dc7f381614c
2022-10-07 08:57:58 +00:00
Andrew Scull
1c6cf7c74a Merge logic of DICE HAL and diced in to dice-service
The DICE HAL and diced are replaced with dice-service which implements
the diced services and also contains the HAL logic directly, without
exposing an implementation of the HAL service.

Bug: 243133253
Test: atest MicrodroidTests
Change-Id: Ia0edeadb04a3fdd37ee1a69a875a7b29586702c5
2022-09-27 22:18:46 +00:00
Rob Seymour
ecbadbb141 Allow service managers access to apex data.
VintfObject will monitor for /apex directory for VINTF data.
Add permissions for service managers to read this data.

Bug: 239055387
Test: m && boot
Change-Id: I179e008dadfcb323cde58a8a460bcfa2825a7b4f
2022-09-23 21:33:58 +00:00
Alan Stokes
d014aa2ca1 Modify authfs related permissions
Allow microdroid_manager to start authfs when needed.

Migrate the authfs-related permissions from compos to
microdroid_payload, so it can be used by any payload.

Move a neverallow to the correct file.

Bug: 245262525
Test: atest MicrodroidTests MicrodroidHostTestCases
Test: atest ComposHostTestCases
Change-Id: I0f5eb9c11bdb427b1f78c9fc721c40de76add484
2022-09-23 15:55:47 +01:00
Jiyong Park
75e8c1f461 Microdroid: remove logd and logcat
Previously in Microdroid, processes send log messages to logd over
socket and then logcat ran to hand the message to the host side over the
serial console.

That has changed. Now, the liblog library which processes use to emit
logs directly sends the given message to the serial console. Liblog does
this by reading a new system property ro.log.file_logger.path. When this
is set, liblog doesn't use the logd logger, but opens the file that the
sysprop refers to and writes logs there.

This change implments sepolicy side of the story.

* logd and logcat types are removed since they no longer are needed.
* existing references to those types are removed as well.
* a new property type `log_prop` is introduced and the two system
  properties are labaled as log_prop
* all processes have read access to the system properties
* all processes have append access to /dev/hvc2

Bug: 222592894
Test: run microdroid, see log is still emitted.

Change-Id: I4c4f3f4fd0e7babeab28ddf39471e914445ef4da
2022-09-14 14:27:26 +00:00
Treehugger Robot
19a06c383a Merge "microdroid: Allow payload read /proc/meminfo" 2022-08-24 09:55:52 +00:00
Bart Van Assche
aa9113f378 Remove bdev_type
Bug: 202520796
Change-Id: If067a0fa51e97a4fc2c6b60864e4dc7c51abeded
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-08-23 16:01:17 -07:00
Jiyong Park
bc0e0dce04 Allow microdroid_manager to run kexec
/system/bin/kexec in Microdroid is now properly labeled as kexec_exec.
The binary is responsible for loading the crashkernel into memory so
that when a kernel panic occurs the crashkernel is executed to dump the
RAM.

Microdroid_manager executes the kexec binary as part of the boot
process. It does this only when the kernel is booted with a memory
reserved for the crashkernel, which is determined by checking if
`crashkernel=` is included in the cmdline. For this, it is allowed to
read /proc/cmdline.

Bug: 238404545
Test: boot microdroid
Change-Id: Id08ba9610e3849ba811367917df8dfcc1774b561
2022-08-23 00:02:36 +09:00
David Brazdil
744ae7f798 microdroid: Allow payload read /proc/meminfo
/proc/meminfo contains useful information about the amount of memory
available to the VM and the payload. Let microdroid_payload domain read
the file.

Test: atest MicrodroidBenchmarks
Change-Id: I22d4888cf84e78ce8ed0803e7ebdeb7fca370e1f
2022-08-19 13:57:33 +01:00
Alan Stokes
07ce6daa44 De-dupe compos rules
compos has the microdroid_payload attribute, so we don't need to
duplicate rules that apply to that. This .te should only have things
that differentiate compos from other payloads.

Test: Presubmits
Change-Id: Ib5b8c52f9a068a583fc1471ac6cf0e4aef906857
2022-08-19 11:34:53 +01:00
Jiyong Park
6438f66960 Remove an obsolete rule for microdroid_manager
The fuse supports file contexts. Microdroid_manager no longer needs the
access to the fuse label.

Bug: 188400186
Test: run microdroid test
Change-Id: I9a17a96c6d07a466e1fa01d65279e467a874da3f
2022-08-16 14:40:55 +09:00
Steven Moreland
46138cca6a Merge "Fully prepare vendor_service removal." 2022-08-01 23:20:05 +00:00
Steven Moreland
fd1eb68337 servicemanager started property
If something starts before servicemanager does,
intelligently wait for servicemanager to start rather
than sleeping for 1s.

Bug: 239382640
Test: boot
Change-Id: If0380c3a1fce937b0939cd6137fcb25f3e47d14c
2022-07-28 17:09:14 +00:00
Steven Moreland
e6b2acbfc4 Fully prepare vendor_service removal.
Removes all references to vendor_service in policy except the
definition of this type, which also needs to be removed by
clients.

We don't need this because interface type shouldn't be associated
with where they are served. We can serve HALs from anywhere if they are
implemented in software.

Bug: 237115222
Test: builds
Change-Id: If370a904af81e015e7e1f7a408c4bfde2ebff9a4
2022-07-25 22:20:16 +00:00
Inseob Kim
9dd70bc942 Merge "Allow microdroid_manager to stop tombstoned" 2022-07-14 16:09:23 +00:00
Inseob Kim
fa4c5bff42 Allow microdroid_manager to stop tombstoned
If export_tombstones is false, leaving tombstoned running has no
meaning. However, we still can't selectively start tombstoned, because
post-fs-data happens eariler than config parsing. Thus, this change
allows microdroid_manager to stop tombstoned on demand.

Bug: 236588647
Test: atest MicrodroidTests
Change-Id: I813fe667f3394bdd234e204f3d35a27f3a182cb2
2022-07-13 18:59:50 +09:00
Inseob Kim
202fe3c2d6 microdroid: Remove redundant dontaudit from shell
Bug: 238135989
Test: atest MicrodroidHostTestCases
Change-Id: Ia74ee40e952ffc3bf18e1ff890efcff5219ef33a
2022-07-08 08:56:16 +00:00
Inseob Kim
3f0ea4ffde Make logd and logcat bootstrappable
Because we want to collect early kernel logs, before apexd is run.

Bug: 236451404
Test: atest MicrodroidTests
Change-Id: Id84f5b36df00394eb3444fdef5654c6ec0759faf
2022-07-06 14:51:28 +09:00
Jiyong Park
6fb4511df4 Label ro.build.version.known_codenames in Microdroid
Bug: 236602028
Test: atest ComposHostTestCases
Change-Id: I7a479f32f58964b60468b7d19c9cd9f47a334741
2022-06-21 10:59:03 +09:00
Inseob Kim
44f68942fa Allow microdroid_manager to write serial device
A serial device is used to pass failure reason to host.

Bug: 220071963
Test: atest MicrodroidTests
Change-Id: I085e902b4f0a79d3c8d2cd5c737ad169caac3659
2022-06-13 18:00:11 +09:00
Treehugger Robot
fd4b4f8c8e Merge "Selinux permissions for tombstone_transmit inside VM" 2022-05-17 17:51:44 +00:00
Shikha Panwar
2df14574fa Selinux permissions for tombstone_transmit inside VM
r.android.com/2060021 made it possible for tombstone_transmit to remove
the tombstone file from guest after reading it. This is the required
Selinux policy for that.

Bug: 232403725
Test: atest MicrodroidHostTestCases & check vm logs for avc:
denials

Change-Id: Ic071c0bd5ecb85f4ceae84e435afdec155fbba0b
2022-05-17 11:10:42 +00:00
Victor Hsieh
7026c1043b Allow odrefresh to access dalvik system properties
We recently started to forward dalvik related system properties to
CompOS for odrefresh to use.  The properties are set indeed, but we
still need to allow odrefresh to use.

Bug: 231579544
Test: Cherry pick aosp/2096406, run composd_cmd test-compile
      See ro.dalvik.vm.*, dalvik.vm.* and
      persist.device_config.runtime_native_boot.enable_uffd_gc
      properties in cache-info.xml
Ignore-AOSP-First: Will cherry pick
Change-Id: I5a44384bf39c572878b1d305c3df9860d9324eda
Merged-In: I5a44384bf39c572878b1d305c3df9860d9324eda
2022-05-16 11:53:27 -07:00
Victor Hsieh
3423bc4bcb Allow composd to pass some system properties to CompOS
Bug: 231579544
Test: see allowlisted system properties in the VM
Change-Id: Idb263087639e4677e437ac2fcd2726ee71547f48
2022-05-10 16:19:19 -07:00
Victor Hsieh
a62b3ff58a Allow microdroid_manager to set dev.bootcomplete
... and shell to get the same property for testing.

Bug: 230774156
Test: atest MicrodroidTestCase
Change-Id: Iaf04072c2b394d44ef1253fd048d5ccf757a8b89
2022-05-02 10:33:49 -07:00
Shikha Panwar
8feef80fab Merge "Allow microdroid to start tombstone_transmit service" 2022-04-20 11:08:23 +00:00
Jooyung Han
0b3d56d35f apkdmverity: use LOOP_CONFIGURE
LOOP_CONFIGURE is more efficient than LOOP_SET_FD/SET_STATUS64.

apkdmverity has used the latter because LOOP_CONFIGURE didn't work for
loop-mounting IDSIG file.

apkdmverity can use LOOP_CONFIGURE and enabling DIRECT_IO only when
necessary.

Bug: 191344832
Test: atest MicrodroidTestApp
Change-Id: I9503f17a689e2447acee1f6ef9c2aac53cf3c457
2022-04-16 00:07:39 +00:00
Shikha Panwar
23ffb50e5a Allow microdroid to start tombstone_transmit service
... and other required changes for setup

Test: atest MicrodroidHostTestCases
Change-Id: I300ac5db375e5d9f0edb3168effd2f8b9d7c5fc6
2022-04-13 21:09:38 +00:00
Shikha Panwar
a9f1dc9708 Selinux configs for enabling tombstones be passed to host
For Guest: tombstone_tranmit needs permissions for:
1. keeping track of files being written on /data/tombstones.
2. creating vsock socket to talk to virtualizationservice (to forward
   these tombstones)

These permissions will be similar to tombstone_tarnsmit on cuttlefish
(device/google/cuttlefish/guest/monitoring/tombstone_transmit/tombstone_transmit.cpp)

For Host (virtualizationservice) needs:
1. permission to  connect to tombstoned.
2. permission to use fd belonging to tombstoned.
3. append and related permissions on tombstone_data file.

Test: Tested by crashing a process in guest (started using microdroid
demo)

Change-Id: Ifd0728d792bda98ba139f18fa9406494a714879d
2022-04-05 13:09:04 +00:00
Jiyong Park
db9b8670b3 Remove unnecessary entries from microdroid vendor file_contexts
Bug: 225148395
Test: watch TH
Change-Id: Id368605c396fdb79c0044c407abb08ab8c90fa32
2022-04-05 16:41:26 +09:00
Treehugger Robot
c2b73ca1b2 Merge "microdroid: dont audit access to event-log-tags" 2022-03-24 22:16:47 +00:00
Victor Hsieh
e82248bcb0 Merge "Allow odrefresh to use userfaultfd" 2022-03-24 15:15:17 +00:00
Alan Stokes
f69f5a6512 Remove redundant neverallow
commit 7fd8933f0c removed this from host
sepolicy. It's redundant here as well.

Bug: 223596375
Test: Builds
Change-Id: I39d7432c6e31f49de5eb8dca8acc7e9c5d190617
2022-03-24 11:56:20 +00:00
Victor Hsieh
6c874fb295 Allow odrefresh to use userfaultfd
This isn't really used at the moment, but since the decision was to keep
the capability for future ART change, we should also allow it in CompOS
for consistency.

While I'm on in, rearrange the policy to group mirrored policies
together.

Bug: 209488862
Test: None
Change-Id: Id6afafc42005e711127a1e0831d4dd03e48959eb
2022-03-23 17:21:22 -07:00
Oleg Matcovschi
f21542906d microdroid: dont audit access to event-log-tags
Bug: 225223271
Test: run microdroid, confirm no denial messages
Signed-off-by: Oleg Matcovschi <omatcovschi@google.com>
Change-Id: I505402c5ff886c18c06133825f9a7ced84c17c1f
2022-03-23 08:55:19 -07:00
Inseob Kim
85091cd806 Allow init to relabelto console_device
Init will try restorecon /dev/console, together with /dev, at the second
stage boot.

Bug: 193118220
Test: atest MicrodroidHostTestCases
Change-Id: Ie9796368b54bb0773eabf5ff6feb2b4aa41d0bfa
2022-03-22 22:11:03 +09:00
Alan Stokes
7bde36e94e Remove redundant sepolicy
We don't use MLS in Microdroid, so we don't need MLS rules, nor
mlstrusted[subject|object] labels. (We keep one MLS rule to satisfy
checkpolicy.)

A lot of attributes are unused in Microdroid, so we can remove their
declarations and any references to them. (That may not make the
compiled policy smaller, since hopefully they get optimised out
anyway, but it means there is less policy for humans to deal with.)

Remove labels that relate only to apps, which we don't have - MAC
permissions, run-as, seapp_contexts.

In passing, fix a comment snafu in both system & microdroid policy.

Bug: 223596375
Test: Run staged-apex-compile & compos_verify, no denials
Test: atest MicrodroidTests MicrodroidHostTestCases
Change-Id: Ifd3589945a2d8b4c0361e00eec5678795513fd8c
2022-03-15 15:43:50 +00:00
Andrew Scull
629e12499a Merge "Define access to AVF chosen node properties" 2022-03-14 17:06:24 +00:00
Andrew Scull
2dba72540c Define access to AVF chosen node properties
Give microdroid_manager and the DICE HAL access to the AVF chosen node
properties that are used to indicate that the VM is booting in strict
more and that the current boot is provisioning a new VM instance.

Bug: 221051866
Bug: 217376291
Test: atest MicrodroidTests
Change-Id: Ie8451fc80671557086f8d825ad01600f9cb4557a
2022-03-14 11:38:45 +00:00
Inseob Kim
35e87367b8 microdroid: Set mls_cats to 1
Because MLS isn't really used in microdroid, setting it to 1 may help
improve performance a bit.

Bug: 223596384
Test: atest MicrodroidTests
Change-Id: Iace4a45ccda98e34fbf82b16ff2096a53b543132
2022-03-10 13:16:13 +09:00
Victor Hsieh
2a017b61a6 Allow dex2oat to use userfaultfd in microdroid
Bug: 209488862
Test: Follow instructions in b/209488862#comment12, compilation can
      only succeed with this patch
Change-Id: I6475a1be0db635de96b9f8fdbf9dd3a76c3a759b
2022-03-08 22:29:43 +00:00
Alan Stokes
ff648192d9 Block crash_dump from no_crash_dump_domain
These domains already can't transition to crash_dump, but also need to
make sure crash_dump can't be run and pointed at them.

Bug: 218494522
Test: Builds
Change-Id: I76f88faf8ff4c88e85eaf6a8db546dc644a71928
2022-02-24 16:36:40 +00:00
Treehugger Robot
275836a9af Merge "Dontaudit property access by odrefresh in the VM" 2022-02-23 12:07:45 +00:00
Victor Hsieh
e2156d071e Dontaudit property access by odrefresh in the VM
Bug: 210030607
Test: composd_cmd test-compile, no more denials in vm.log
Change-Id: I728398f812680354b813d03e0d23eecca330c47e
2022-02-22 23:10:04 +00:00
Alan Stokes
0c5449b193 Remove now-unused permissions
CompOS no longer talks directly to DICE (compos_key_helper does). odsign
no longer promotes or deletes instance CompOS files, and the key files
don't exist any more.

Bug: 218494522
Test: Manual; trigger compilation, reboot & watch odsign
Change-Id: Ibc251180122e6e4789b4be5669da3da67517b49c
2022-02-22 17:40:05 +00:00
Treehugger Robot
5273f3a486 Merge "Modify sepolicy for compos key changes" 2022-02-18 09:03:30 +00:00
Treehugger Robot
92ec679578 Merge "Remove needless bootloader_prop rule" 2022-02-17 15:51:31 +00:00
Andrew Scull
9738638c03 Let the DICE HAL getattr the device node
Make sure all the permissions are granted to let the HAL do its work
properly.

Bug: 214231981
Test: atest MicrodroidTestApp
Change-Id: I54c633b8163ea313c87856fb0513074a76ac86a1
2022-02-17 12:35:22 +00:00
Alan Stokes
766caba5de Modify sepolicy for compos key changes
Add the compos_key_helper domain for the process which has access to
the signing key, make sure it can't be crashdumped. Also extend that
protection to diced & its HAL.

Rename compos_verify_key to compos_verify, because it doesn't verify
keys any more.

Move exec types used by Microdroid to file.te in the host rather than
their own dedicated files.

Bug: 218494522
Test: atest CompOsSigningHostTest CompOsDenialHostTest
Change-Id: I942667355d8ce29b3a9eb093e0b9c4f6ee0df6c1
2022-02-17 12:14:40 +00:00
Andrew Scull
12bd3d9d2e Remove needless bootloader_prop rule
Bootloader properties are available to all domains so don't need special
policy rules for microdroid_manager.

Test: atest MicrodroidTests
Change-Id: I0ccf6b28467a47c0f3cf7715b9ff34d01e8ac970
2022-02-16 09:40:29 +00:00
Andrew Scull
b13117f3ba Add ro.boot.microdroid.app_debuggable
This property is set in the bootconfig to reflect the debuggability of
the payload app. It is consumed microdroid_manager as a DICE input and
by compos to make choices based on the debuggability, e.g. not doing
test builds in non-debug states.

Bug: 219740340
Test: atest ComposHostTestCases
Test: atest MicrodroidTests
Change-Id: If84710f1fdbab957f5d19ce6ba3daad7e3e65935
2022-02-16 09:40:27 +00:00
Inseob Kim
74caef3591 Add microdroid sepolicy test support
MicrodroidHostTestCases will pull the VM's sepolicy and check it against
system/sepolicy/microdroid's neverallow rules, using sepolicy-analyze
tool.

Bug: 218461215
Test: atest MicrodroidHostTestCases
Change-Id: I62a69053996b71d69dd2bf6b7eabc8b701095477
2022-02-09 23:35:44 +09:00
Jiyong Park
30c416a4bd Allow microdroid_manager to BLKFLSBUF on the instance disk
Microdroid_manager uses the ioctl to flush data to the block device.

Bug: 208639280
Test: atest MicrodroidTestApp
Change-Id: Icd708702618850e1f003b16bdc8a1698c45f6442
2022-02-07 15:13:22 +09:00
Andrew Scull
248e8a998f Allow the microdroid app to use diced
Bug: 214231981
Test: atest MicrodroidTestApp
Change-Id: I9672d678c7b698d15a0efa8dab567dbc2696ca81
2022-01-30 22:42:38 +00:00
Andrew Scull
6f2529c01b Touch up microdroid sepolicy after removing keystore
Avoid divergence in the files that will eventually shared with the main
Android sepolicy and fix a style mistake.

Bug: 215747811
Test: atest MicrodroidTests
Change-Id: I40b0bebb432d73ab6ab847c117e72d8bc18fe873
2022-01-28 13:07:16 +00:00
Andrew Scull
6c288a2676 Remove hwservicemanager from microdroid sepolicy
With the keymint HAL removed from microdroid, there are no more legacy
HALs meaning no further need for hwservicemanager.

Bug: 215747811
Test: atest MicrodroidTests
Change-Id: I111f3456399ef91e51d1cfead67659601c23db9e
2022-01-27 21:48:37 +00:00
Andrew Scull
af2c894f2c Remove keymint from microdroid sepolicy
The keymint HAL has been removed from microdroid to remove the
corresponding sepolicy.

Bug: 215747811
Test: atest MicrodroidTests
Change-Id: I08aae50dd9a4575954db40ec974625e43bff2335
2022-01-27 21:48:37 +00:00
Andrew Scull
f75d5cde48 Remove keystore from microdroid sepolicy
The keystore service has been removed from microdroid to remove the
corresponding sepolicy.

Bug: 215747811
Test: atest MicrodroidTests
Change-Id: I6600b47f8b8c6bba05b1f59b4d87713283805817
2022-01-27 21:48:37 +00:00
Treehugger Robot
fabaac131a Merge "Delete more unused policies by CompOS" 2022-01-25 20:54:41 +00:00
Treehugger Robot
c8ff1677ed Merge "Add context for ro.boot.microdroid.debuggable property" 2022-01-25 20:41:07 +00:00
Victor Hsieh
ea38d6925d Delete more unused policies by CompOS
Bug: 205750213
Test: TH
Change-Id: Ie08465e8801a74d61f85715e85a856293c4232d5
2022-01-25 08:40:46 -08:00
Andrew Scull
30373f3015 Add context for ro.boot.microdroid.debuggable property
This property is read by microdroid_manager to check whether the VM is
in debug mode. Give it a context to satisfy the sepolicy.

Bug: 214231981
Test: atest MicrodroidTestApp
Change-Id: I9d4bda5e487324c95229c7978e8fe0a53fa9f616
2022-01-25 16:07:21 +00:00
Andrew Scull
f451a1407f Give DICE HAL access to driver
The driver facilitates the handover of values from the bootloader so
needs to be accessible by the HAL.

Bug: 214231981
Test: run microdroid with a "google,open-dice" DT node
Change-Id: Ib5317e6a42befe22d8f1dbefeb9803f5ec92b061
2022-01-25 15:22:42 +00:00
Jiyong Park
16c1ae3a3d Add use_bionic_libs macro
... to dedupe rules for allowing access to bootstrap bionic libraries.

Bug: N/A
Test: m
Change-Id: I575487416a356c22f5f06f1713032f11d979d7d4
2022-01-25 09:47:56 +09:00
Treehugger Robot
db8d838e5a Merge "Update compos permissions" 2022-01-24 17:01:52 +00:00
Andrew Scull
f94a381585 Make the DICE HAL a bootstrap process
This HAL starts before APEXs are activated so needs access to the
bootstrap bionic libraries.

Bug: 214231981
Test: run microdroid
Change-Id: If82729eb2eff812916f257d24ce206e371be0c56
2022-01-21 18:19:21 +00:00
Jiyong Park
f252d81ec9 Allow microdroid_manager to talk to diced
microdroid_manager needs to give the measurements to diced and get
per-VM secret from it for encrypting/decrypting the instance disk.

Bug: 214231981
Test: run microdroid
Change-Id: Ia4cab3f40263619e554466433cbb065e70ae0f07
2022-01-21 18:19:03 +00:00
Alan Stokes
7409470917 Update compos permissions
We no longer use keystore, nor do we run dex2oat directly.

But we do now use IDiceNode::derive() to get our CDI_seal for key
derivation.

Bug: 214233409
Bug: 210998077
Test: atest ComposKeyTestCase
Change-Id: Id8ba882e7c250ad0365a7f493801e02cb5a0b700
2022-01-21 15:15:19 +00:00
Jiyong Park
92382fe69f Make servicemanager and diced bootstrap processes
The two are now started before APEXes are activated. Therefore they need
access to the bootstrap bionic libraries.

file_contexts is also updated because their file names are changed to
avoid the conflict with their non-bootstrap variants.

Bug: 214231981
Test: m
Change-Id: I30fb1422f228b71251d6618dd7f6e4e5422717f8
2022-01-21 13:41:26 +00:00
Jiyong Park
c9a7de49ea Revert "use dalvik.vm.boot-dex2oat-threads inside microdroid"
This reverts commit eee72d6cb3d9f5c6001192247861b28cb0787827.

REASON: not needed. See the other CL in the same topic.
Bug: 197358423
Test: m
Change-Id: Ice0813ed9e349e37c83b163e2c21f17bb1105013
2022-01-19 01:37:18 +09:00
Treehugger Robot
4da68c0fe4 Merge "use dalvik.vm.boot-dex2oat-threads inside microdroid" 2022-01-18 13:40:30 +00:00
Alan Stokes
50d2195cab Allow compos to use diced
Bug: 214233409
Test: composd_cmd dice
Change-Id: I82b4bd87db879f378d2fafb6e2db7e2544fef5de
2022-01-17 15:48:00 +00:00
Alan Stokes
f3ec0742ed Add diced security class
Add diced to security_class and access_vectors so it can check its
permissions in side Microdroid.

This was part of commit 2b6c6063ae
outside the VM.

Bug: 214231981
Test: composd_cmd dice
Change-Id: Ia503db183d16a4efcb975f654bb4483df44f51ad
2022-01-17 15:42:32 +00:00
Jiyong Park
2832f957e7 Merge "Add policies for diced and hal_dice in microdroid" 2022-01-17 13:29:34 +00:00
Jiyong Park
1d9c9ba231 use dalvik.vm.boot-dex2oat-threads inside microdroid
Previously, all dalvik.vm.* properties were not used / ignored in
Microdroid. However this change makes use of
dalvik.vm.boot-dex2oat-threads which controls the concurrency level of
dex2oat.

Specifically, on the host-side, the number of vCPUs in the compos VM is
configured from the system property having the same name. Then inside
the compos VM, compsvc which runs in the compos domain, sets the system
property to be the number of vCPUs in the VM. In other words, the system
properties get the same value both in the host and the guest VMs. Then
finally, the dex2oat process running inside the VM reads the system
property and configures its concurrency level accordingly.

Bug: 197358423
Test: run compos

Change-Id: I8d2394a7192a7b55a910f317e12e2b1f60b89636
2022-01-14 00:40:49 +09:00
Treehugger Robot
70cd2da646 Merge "Allow authfs to read extra APK mount" 2022-01-13 01:06:01 +00:00
Jiyong Park
8948c1ce4b Add policies for diced and hal_dice in microdroid
Bug: 214231981
Test: run microdroid and check diced is up and running
Change-Id: I605d7d6a790b8a14e575e67e1dcf02eaf7a5eafc
2022-01-13 01:37:00 +09:00
Alan Stokes
67a8605deb Remove obsolete ioctl allow
No longer used, so remove the allow.

Bug: 199259751
Test: Presubmits
Change-Id: Iea61d29d14b13de86f7fbd6b6e416eea745b615e
2022-01-07 10:42:17 +00:00
Victor Hsieh
a59b030341 Allow authfs to read extra APK mount
Bug: 206869687
Test: Add debug log to compos.  See correct content from the proto.
Change-Id: I4f2b4096808efc1b15c218a225b451731f37e43d
2022-01-05 15:21:51 -08:00
Alan Stokes
d313282433 Allow compos to run derive_classpath
We run it in the compos domain, since it doesn't require very much
additional access.

Bug: 189164487
Test: composd_cmd test-compile
Change-Id: I9ef26dd60225505086e45185289e3e03d0a8de8e
2022-01-05 18:06:27 +00:00
Treehugger Robot
76867eabd1 Merge "Remove inaccurate comment" 2021-12-20 10:59:29 +00:00
Victor Hsieh
048866ca7d Remove inaccurate comment
... from 14f188718a

Bug: None
Test: None
Change-Id: I133bc96f4cf7ae4092fef8ee4eac9533524a71b1
2021-12-16 13:56:48 -08:00
Treehugger Robot
a6d6b6aee8 Merge "Add apexd_payload_metadata_prop" 2021-12-16 19:18:43 +00:00
Victor Hsieh
6e5eb7cb11 Merge "Allow dex2oat to search in authfs directories" 2021-12-16 16:23:49 +00:00
Alan Stokes
14f188718a Grant compos permissions for signing
CompOS needs to read the artifacts on authfs that odrefresh has
created and write signature files for them.

(But it no longer needs to create any directories, so removed that.)

Fixes:
avc: denied { open } for comm="compsvc"
path="/data/misc/authfs/1/11/test-artifacts/...art" dev="fuse" ino=81
scontext=u:r:compos:s0 tcontext=u:object_r:authfs_fuse:s0 tclass=file
permissive=0
avc: denied { create } for comm="compsvc" name="compos.info"
scontext=u:r:compos:s0 tcontext=u:object_r:authfs_fuse:s0 tclass=file
permissive=0

Bug: 161471326
Test: composd_cmd async_odrefresh (with microdroid selinux enforced)
Change-Id: Ie02dedf1f18926cdbbd39e4a950c5aec80adee32
2021-12-16 13:40:38 +00:00
Richard Fung
0c7c2679b0 Add apexd_payload_metadata_prop
This should be read-only and corresponds to apexd.payload_metadata.path

Bug: 191097666
Test: android-sh -c 'setprop apexd.payload_metadata.path'
See permission denied
atest MicrodroidHostTestCases

Change-Id: Ifcb7da1266769895974d4fef86139bad5891a4ec
2021-12-16 03:00:06 +00:00
Victor Hsieh
a341025f87 Allow odrefresh to use FD inherited from compsvc
If FD use is not allowed, execve(2) returns EACCESS and the process is
killed by SIGSEGV.

Minijail closes any FDs by default and open /dev/null for FD 0-2. For
now, odrefresh doesn't use any FD. But until we could tell minijail to
not create FD 0-2 (which could be arguable), allow the permission.

Bug: 210909688
Test: composd_cmd async-odrefresh # exit 80 in enforced mode
Change-Id: I8643d8bfc8da03439a04491fba5ba6de663760eb
2021-12-15 16:54:28 -08:00
Victor Hsieh
e2a4d0c918 Allow dex2oat to search in authfs directories
dex2oat checks $ANDROID_ROOT exist, which is a directory in an authfs
mount. Give it permission to search along the path.

Strictly speaking, this isn't change how dex2oat execute in this
particular case, for now. Functions like LocationIsOnSystemFramework
make sure getenv(ANDROID_ROOT) exists. But either way, for those kind of
location checks, it won't match the mount path in /data/misc/authfs
anyway.

Bug: 205750213
Test: no more SELinux denials from dex2oat
Change-Id: I1b52dfdeb057443304f02784b6aa180d7db28bd8
2021-12-15 13:37:34 -08:00
Victor Hsieh
b415c7388f Declare dalvik.vm. property and dontaudit explicitly
dex2oat currently uses some properties as flags (see
art/libartbase/base/flags.cc). For CompOS, we don't really need such
properties, and actually should avoid global state. So dontaudit
explicitly.

Bug: 210030607
Test: no more default_prop denials for dex2oat
Change-Id: I10852f2a7df4dac7a9389eab3f53f91328104f96
2021-12-15 09:30:22 -08:00
Victor Hsieh
3ea775e483 Include log.tag and persist.log.tag in log_tag_prop
The two properties are not just prefixes. See __android_log_level in
system/logging/liblog/properties.cpp.

Bug: 210030607
Test: no longer seeing denials with default_prop in odrefresh
Change-Id: If2c9cba7aa65802e81c79c7d3d9735cbf14a6efa
2021-12-15 09:21:23 -08:00
Victor Hsieh
fe95b5b318 Define ro.build.version.{codename,sdk} in microdroid
The `__builtin_available` macro is used in used in several libraries in
microdroid, including liblog. The macro internally uses
ro.build.version.{codename,sdk}[1]. This change defines the context for
these properties.

[1] https://reviews.llvm.org/rG516a01b5f36d4188778a34202cd11856d70ac808

Bug: 210030607
Test: No longer seeing denied access of default_prop from odrefresh
Change-Id: I51bc52f679a174daccc05a1e2d6c9fda9e6b12cb
2021-12-15 08:11:13 -08:00
Jeff Vander Stoep
bc0fa66cbe Policy for using Apex sepolicy
Bug: 199914227
Test: aosp/1910032
Change-Id: I0726facbf0c28c486ef6501718a6013a040e4b0e
2021-12-14 13:54:03 +01:00
Alan Stokes
6e48ea981a Merge "Revert "Revert "More neverallow rules""" 2021-12-10 10:27:13 +00:00
Alan Stokes
9c2e162e87 Revert "Revert "More neverallow rules""
This reverts commit a0e49cea04.

Reason for revert: I don't think this was the culprit after all
Bug: 204853211

Change-Id: Iadc1c8df5ec2affcdbbf9e7bdc3eac54c47f4ebf
2021-12-10 09:06:08 +00:00
Alan Stokes
c6c31eb7b3 Merge "Revert "More neverallow rules"" 2021-12-09 14:06:35 +00:00
Treehugger Robot
c9d812e359 Merge "Run Virtualization tests when we change microdroid policy" 2021-12-09 13:12:55 +00:00
Treehugger Robot
8a564d32b7 Merge "Remove obsolete TODO" 2021-12-09 11:53:29 +00:00
Alan Stokes
fe9cfa610e Run Virtualization tests when we change microdroid policy
Bug: 204853211
Test: N/A
Change-Id: Ic5c921ad4980fb01e20a5765e5049812f6664dfb
2021-12-09 11:35:36 +00:00
Alan Stokes
a0e49cea04 Revert "More neverallow rules"
This reverts commit 72c0134384.

Reason for revert: Looks like this may have broken ComposHostTestCases
Bug: 204853211

Change-Id: I83816a49d3be056e4c9a718ea02911ca022cb984
2021-12-09 11:19:52 +00:00
Inseob Kim
28d0530c35 Remove obsolete TODO
Bug: 208722875
Test: N/A
Change-Id: I7ac440164140d7b95a1a7674e219bf9c2b1b83bd
2021-12-09 19:05:54 +09:00
Treehugger Robot
3e664a0e6d Merge "Allow odrefresh to read from a pipe from compos" 2021-12-09 09:45:30 +00:00
Victor Hsieh
1494f6b9a5 Allow odrefresh to read from a pipe from compos
This is copied from dex2oat.te. By using minijail, the child process
currently requires to communicate with the parent by a pipe, before
actually exec'ing the executable.

Bug: 205750213
Test: no longer see the avc error
Change-Id: I4d59fc8d32150d9e08abba06203eb5164ecd3c75
2021-12-08 15:00:22 -08:00
Alan Stokes
72c0134384 More neverallow rules
When we cut down microdroid policy we removed a whole lot of
neverallow rules that were in public/domain.te. Many of these are
irrelevant, but there are some that look quite important. So this CL
restores many of them. This makes no immediate difference (none of
these rules are currently violated, except as mentioned below), but it
might catch mistakes, or at least make us stop and think before
introducing potentially risky policy changes.

Process:
- Paste in all the neverallow rules from public/domain.te in Android
  policy.
- Delete all references to non-existent labels.
- Delete everything makred full-trebly-only,

I also deleted some attributes we clearly don't need, and hence
associated neverallows. (I suspect there are more attributes we could
remove.)

And then I fixed a neverallow violation for microdroid_payload - we
were allowing it unrestricted ioctl access.

Bug: 204853211
Test: Policy builds without error
Test: No denials running composd_cmd forced-compile-test
Change-Id: I21035dee93a881b34941338cc7ce82503cc65e59
2021-12-08 14:56:45 +00:00
Alan Stokes
26239da92b Restrict making memory executable
All code must reside in files.

Bug: 204853211
Test: Builds, no neverallow violations
Change-Id: I124a4c567fff76e143582e189b8cb9feeae5d7d0
2021-12-08 12:36:05 +00:00
Inseob Kim
8565b96a3a microdroid: Add support for extra apk files
extra_apk_file is a new label only for APK files passed to microdroid.
microdroid_manager will create directories under /mnt/extra-apk/, and
zipfuse will mount APK block devices to the directories.

Currently only payload can read the files.

Bug: 205224817
Test: manually edit vm config and see APK files mounted
Change-Id: Ie5afb3156f22bb18979ec70904be675e8ff285a7
2021-12-08 14:10:28 +09:00
Treehugger Robot
9a93d79a92 Merge changes I81ab0a73,Ia66015b7
* changes:
  Allow compsvc to execute odrefresh
  Allow composd to run fd_server
2021-12-08 00:28:52 +00:00
Victor Hsieh
f97cc1fd26 Allow compsvc to execute odrefresh
Bug: 205750213
Test: /apex/com.android.compos/bin/composd_cmd forced-odrefresh
      # With SELinux enforced in the VM, plus some hacks in ART,
      # observed odrefresh exited 80.
Change-Id: I81ab0a73314fdcea69c69350c792ff7acab5aab8
2021-12-07 08:08:00 -08:00
Jiyong Park
3db645b83d Allow microdroid_manager to read /proc/bootconfig
... so that it can ensure that the bootconfig hasn't changed since the
last boot.

Bug: 208639280
Test: m
Change-Id: I2310a0df0ebbef9d6fe47dbad2538ecbe7bc84e6
2021-12-06 21:16:09 +09:00
Treehugger Robot
f5646ff42b Merge "Add logd.ready" 2021-12-02 03:34:00 +00:00
Inseob Kim
2df19cba08 microdroid: Run apk mount utils from MM
For now, the command for apkdmverity and zipfuse is hard-coded in the
init script file. To support passing extra APKs, microdroid_manager
needs to parse the vm config, and then manually run apkdmverity and
zipfuse with appropriate parameters.

Bug: 205224817
Test: atest MicrodroidHostTestCases ComposHostTestCases
Change-Id: I482b548b2a414f3b5136cea199d551cc88402caf
2021-12-01 19:46:33 +09:00