Commit graph

86 commits

Author SHA1 Message Date
Treehugger Robot
68e5958902 Merge "Add the 'bdev_type' attribute to all block device types" 2021-09-10 01:27:48 +00:00
Jooyung Han
53c773a3fd make zipfuse a bootstrap process
Bug: n/a
Test: MicrodroidHostTestCases
Change-Id: Ia2ad615e919f4fcb0452d8458e505ecfbdd5818f
2021-09-10 08:56:08 +09:00
Inseob Kim
2f7600920d Add vsock permissions to microdroid_payload
microdroid_payload needs to open a vsock server, so this change grants
permissions for that. This change also temporarily grants permissions to
get local CID, which should be removed once the RPC binder API supports
getting CID.

Bug: 195381416
Test: atest MicrodroidHostTestCases
Change-Id: I57a603e74d7552e13a83fa4934621e09e13015fd
2021-09-09 02:30:59 +00:00
Bart Van Assche
8a6f8e51bc Add the 'bdev_type' attribute to all block device types
The following patch iterates over all block devices:
https://android-review.googlesource.com/c/platform/system/core/+/1783847/9

The following patch grants 'init' and 'apexd' permission to iterate over
all block devices:
https://android-review.googlesource.com/c/platform/system/sepolicy/+/1783947

The above SELinux policy change requires to add the 'bdev_type'
attribute to all block devices. Hence this patch.

Bug: 194450129
Test: Untested.
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: Iee1c984f176eb2752194493999921cb1aa24ac64
2021-09-08 16:13:25 -07:00
Jooyung Han
6f3b5e2edc microdroid: rename property to "apk_root_hash"
Bug: 193504400
Test: atest MicrodroidHostTestCases
Change-Id: I3bd0fd337d85b29e5dfdfba49ee5328e48f5be89
2021-09-08 16:05:29 +09:00
Jiyong Park
27bb6c6608 Microdroid boot process is controlled by microdroid_manager
Previously, the boot process of microdroid was mostly implemented in the
init.rc file. microdroid_manager was started first in the background,
then apexd, apkdmverity, and zipfuse were executed in sequence. However,
in order to correctly implement the app payload verification scheme,
most of the early boot process has to be controlled by
microdroid_manager. Specifically, apkdmverity should be started "after"
the apk roothash is read from the instance disk by microdroid_manager.

As an alternative, we could let apkdmverity the read instance disk by
itself. However, this is undesirable because doing so requires multiple
processes - microdroid_manager and apkdmverity - have access to the
instance disk and more seriously the secret key to decrypt it.

Another alternative is to let microdroid_manager do the dm-verity
configuration which apkdmverity does. This also is considered
undesirable because then we would give the permissions for configuring
dm-verity devices to microdroid_manager which is a long-running daemon
process. Note that apkdmverity is not a daemon process.

This CL introduces a few number of changes which are required to let
microdroid_manager directly control the early boot process:

1) microdroid_manager is allowed to start the services apkdmverity and
zipfuse by using the `ctl.start` sysprop.

2) apkdmverity is allowed to use bootstrap bionic libraries as it is now
executed before APEXd activates the APEXes.

3) A new sysprop `microdroid_manager.apk_roothash` is added. It is
written by microdroid_manager and read by apkdmverity. It contains the
roothash read from the instance disk. This value is not a secret.

4) Another new sysprop `apex_config.done` is added. It is set by init
just after `perform_apex_config` and read by microdroid_manager.
Microdroid_manager uses this to wait until linker configuration is ready
so that it can execute app payloads with the config.

Bug: 193504400
Test: atest MicrodroidHostTestCases
Change-Id: If29ce17d7a6cb4859e8ceeffb321724e7f11bf82
2021-09-07 17:13:43 +09:00
Jiyong Park
ee3661ef2b Allow microdroid_manager to write instance.img
Bug: 193504400
Test: atest MicrodroidHostTestCases
Change-Id: Icac8aa7e1badc90d2725c81e3c0f9594b7e18608
2021-08-31 17:14:09 +09:00
Treehugger Robot
037a21ba15 Merge "Add /dev/vsock permissions to microdroid" 2021-08-24 23:35:34 +00:00
Inseob Kim
2e0fb00f22 Add /dev/vsock permissions to microdroid
microdroid_manager needs to know its own CID until the full RPC binder
support is landed.

Bug: 191845268
Test: run MicrodroidDemoApp
Test: atest MicrodroidHostTestCases
Change-Id: I8f6c667f0827d1089baa21417c2b0ba382d94d26
2021-08-24 14:23:18 +09:00
Victor Hsieh
dedb4909c3 Remove unnecessary privileges from dex2oat in VM
With a change in dex2oat to avoid opening /proc/self/fd, this change
removes open and a few other privileges from dex2oat.

Bug: 196404749
Test: ComposHostTestCases
Change-Id: I822c7ef3886a1cde8601e71afa2eb79973cd573c
2021-08-19 14:01:59 -07:00
Bart Van Assche
4dcefe8898 Merge "Add the 'bdev_type' attribute to all block devices" 2021-08-16 16:39:24 +00:00
Victor Hsieh
5f6e4324b3 Allow compos to getattr on authfs
Bug: 161471326
Bug: 196635431
Test: ComposTestCase
Change-Id: I3a4073726d31686c8eb945ba9417cb2afe238d79
2021-08-13 15:48:21 -07:00
Bart Van Assche
27ecd60a79 Add the 'bdev_type' attribute to all block devices
The following patch iterates over all block devices:
https://android-review.googlesource.com/c/platform/system/core/+/1783847/9

The following patch grants 'init' and 'apexd' permission to iterate over
all block devices:
https://android-review.googlesource.com/c/platform/system/sepolicy/+/1783947

The above SELinux policy change requires to add the 'bdev_type'
attribute to all block devices. Hence this patch.

Bug: 194450129
Test: Untested.
Change-Id: I959bae6f9590b1867905d46e194c45b0ea4248df
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-08-13 13:54:02 -07:00
Treehugger Robot
1ca4b5c045 Merge "Define sepolicy for compos and dex2oat" 2021-08-12 14:27:09 +00:00
Victor Hsieh
aa987aaa2d Define sepolicy for compos and dex2oat
Bug: 194474784
Test: ComposTestCase # with debug disabled
Change-Id: I2a53df337356fc8e299837358da2a5a88c9c20d3
2021-08-11 10:42:19 -07:00
Victor Hsieh
5f7c02328c Grant authfs_service and authfs CAP_SYS_ADMIN
CAP_SYS_ADMIN is required to mount a filesystem (currently in authfs, a
child process of authfs_service). It seems the parent also needs to be
allowed.

Bug: 194474784
Test: Use the service (from compsvc), no longer seeing the denials
Change-Id: I122734ee9f11899af4d7b647bc3049e4dbdad09e
2021-08-11 15:48:14 +00:00
Victor Hsieh
a70e6052c2 Allow authfs_service to add itself to service manager
Fixes: 196018177
Test: atest MicrodroidHostTestCases
Change-Id: Ib47b8bf5d5d683e7f163e8f69d8a06ffe8f2675b
2021-08-10 10:55:54 -07:00
Jooyung Han
996da475a1 Merge "microdroid_manager: allow to read dm_device" 2021-08-09 17:49:16 +00:00
Victor Hsieh
14aad3711d Merge "SELinux policy for authfs_service and authfs" 2021-08-09 17:12:22 +00:00
Jooyung Han
797acf9072 Don't audit microdroid_app getattr vsock_socket
Microdroid_manager creates a vsock socket and app's output is redirected
to it.

Bug: 195751698
Test: MicrodroidHostTestCases
Change-Id: I66759067169cc97a6c1fc084395761e06c6e20f6
2021-08-09 12:50:41 +00:00
Victor Hsieh
49c0ec7a67 SELinux policy for authfs_service and authfs
authfs_service is a binder service on microdroid. Upon a request by the
client, the service will create the mount directory, execute authfs to
mount the FUSE, and finally unmount and delete the mount directory.

authfs currently requires more privileges than it should, but it's ok
because the client owns the VM, and all input will be verified by
signatures. But there is plan to keep the privileges isoated in the
service (b/195554831).

Bug: 194717985
Bug: 195554831
Test: Start the service from init, use a test executable to call the
      service API. Only observed denial from the test executable.
Change-Id: Ie53aa9e2796433fc3182357039d0b7ba1c0848ef
2021-08-06 09:16:48 -07:00
Jooyung Han
2ac60775e0 microdroid_manager: allow to read dm_device
Microdroid_manager should verify payloads(APK/APEXes). APK is mounted to
dm_device first and then verified. So, microdroid_manager needs to read
it.

Bug: 190343842
Test: MicrodroidHostTestCases
Change-Id: I530fb8d2394952486f0bad7fb3bed770611cd311
2021-08-07 00:52:00 +09:00
Inseob Kim
7687600c50 Suppress power_supply access inside microdroid
Bug: 193118220
Test: atest MicrodroidHostTestCases
Change-Id: I3dbdcb831c61e9bd24cfdaa10beba9e856e605af
2021-08-05 02:05:16 +00:00
Inseob Kim
2f4b03654a Add servicemanager's service to microdroid policy
Bug: 193118220
Test: atest MicrodroidHostTestCases
Change-Id: I0e57fa913fe857626634f94502b1ad5a0989bdc8
2021-08-04 11:35:57 +00:00
Inseob Kim
0abc4fdf2b Temporarily dontaudit ueventd->tmpfs access
This is the only blocker for SELinux denial test on microdroid. Rather
than consuming more time, this temporarily suppresses the audit message
to turn on the test.

Bug: 193118220
Test: atest MicrodroidHostTestCases -c
Change-Id: Id703107cbaae42352bebe34d0a6373f0701c0f6f
2021-08-04 10:58:22 +00:00
Inseob Kim
ebc11f6a99 Merge "Suppress keystore F2FS related audit" 2021-08-03 02:19:15 +00:00
Inseob Kim
6b5eafedf9 Suppress keystore F2FS related audit
keystore uses sqlite3. sqlite3 calls F2FS_IOC_GET_FEATURES. As
microdroid has nothing to do with that, we just suppress the audit.

Bug: 193118220
Test: atest MicrodroidHostTestCases
Change-Id: I1da00d1fd4b7e208e80a1d9bc5f49c21af684516
2021-07-29 12:18:31 +00:00
Jooyung Han
f9a7dab645 Microdroid_manager is a bootstrap process
Bug: 190343842
Test: MicrodroidHostTestCases
Change-Id: Iaec029726a34f46fd9123d34765a20a1c5dd254a
2021-07-29 17:40:05 +09:00
Alan Stokes
80bb558584 Remove compos_key_cmd from policy
It's a test tool which is generally run as root, and will be deleted
eventually. It doesn't need its own label; system_file works fine.

We never actually allowed it anything, nor defined a transition into
the domain.

Bug: 194474784
Test: Device boots, no denials
Test: compos_key_cmd run from root works
Change-Id: If118798086dae2faadeda658bc02b6eb6e6bf606
2021-07-28 14:36:50 +01:00
Inseob Kim
1f87fbd9fa Add microdroid_payload attribute
microdroid_payload attribute is for processes meant to be run by
microdroid_manager as a payload. Other than microdroid_payload and
crash_dump, transition from microdroid_manager will not be permitted.

Bug: 191263171
Test: atest MicrodroidHostTestCases
Test: atest ComposHostTestCases
Change-Id: I959a8ad8ed83c8de254d7af61fd30bcbffe6b070
2021-07-27 08:30:22 +00:00
Alan Stokes
72cac09097 Add rules for dex2oat.
This is necessary (but not sufficient) to allow CompOsTestCase to
run. Without it we have problems because
system/sepolicy/apex/com.android.art-file_contexts references
dex2oat_exec, and we get an error:

SELinux : Context u:object_r:dex2oat_exec:s0 is not valid (left unmapped).

Bug: 194474784
Test: atest CompOsTestCase (with memory fix patched in)
Change-Id: If229b9891c8fb1acce8d0502675c1712bfed180c
2021-07-23 12:26:26 +01:00
Treehugger Robot
6a4bc81a2b Merge changes I43bf09d8,I1fd35d0e
* changes:
  Disallow microdroid from running arbitrary domains
  Add domain for compos binaries
2021-07-23 09:29:53 +00:00
Inseob Kim
a89d6aa301 Disallow microdroid from running arbitrary domains
Test: atest MicrodroidHostTestCases
Test: atest ComposHostTestCases
Change-Id: I43bf09d85efa4276e929babd854c49ccedfd8058
2021-07-23 06:58:52 +00:00
Jiyong Park
f326072b40 Add more rules around cgroup files in microdroid
The added rules are copied from Android.

Bug: 193118995
Bug: 193118220
Test: adb shell /apex/com.android.virt/bin/vm run-app
/data/local/tmp/virt/MicrodroidDemoApp.apk
/data/local/tmp/virt/MicrodroidDemoApp.apk.idsig
/data/local/tmp/virt/instance.img assets/vm_config.json doesn't show
a selinux denial like the below:
avc:  denied  { create } for  pid=1 comm="init" name="cpus"
scontext=u:r:init:s0 tcontext=u:object_r:cgroup:s0 tclass=file
permissive=0

Change-Id: I3d958e4788fdee5993ff1048e86b81cd93b72b03
2021-07-23 15:48:17 +09:00
Inseob Kim
7560aed40a Add domain for compos binaries
Bug: 191263171
Test: atest MicrodroidHostTestCases
Test: atest ComposHostTestCases
Change-Id: I1fd35d0efe83d2cecaa41580e6d1d0b8f6242b3f
2021-07-23 06:01:39 +00:00
Inseob Kim
e1389977e0 Move microdroid sepolicy to system/sepolicy
Bug: 190511750
Test: boot microdroid
Change-Id: I4aa4a56e9be5103d70469c3508110a973f3e4f12
2021-07-19 07:48:34 +00:00