Commit graph

31519 commits

Author SHA1 Message Date
Bowgo Tsai
92ca58b5bd fs_mgr: support AVB in fs_mgr_update_verity_state()
fs_mgr_update_verity_state() is invoked by 'verity_update_state' in
init.rc. It will then set property "partition.system.verified" and
"partition.vendor.verified" to verify_mode. We should support this for
AVB as well.

Also change the order of static libs in init to fix the build error
after this change:
  system/extras/ext4_utils/ext4_crypt.cpp:69: error: undefined reference to 'property_get'

Bug: 35416769
Test: Mount /system and /vendor with vboot 2.0 (AVB), check the following properties exist.
      - [partition.system.verified]: [2]
      - [partition.vendor.verified]: [2]
Test: Mount /system and /vendor with vboot 1.0, check the following properties exist.
      - [partition.system.verified]: [0]
      - [partition.vendor.verified]: [0]

Change-Id: I4328d66a8cb93f26e7960e620a0b2292d5f15900
Merged-In: I4328d66a8cb93f26e7960e620a0b2292d5f15900
(cherry picked from commit aaf70e77dc)
2017-04-14 21:53:49 +08:00
Bowgo Tsai
51c027285b init: support early_mount with vboot 2.0 (external/avb/libavb)
libavb requires verifying AVB metadata on all verified partitions at
once. For example, /vbmeta, /boot, /system and /vendor. We need to
invoke device_init() for those partitions even if we only want to early
mount some of them, like /vendor and /system.

This CL gets all AVB partitions and the early mount partitions from
device tree through "firmware/android/vbmeta" and "firmware/fstab",
respectively. The following is an example to early mount /vendor
partition on bullhead:

firmware {
    android {
        compatible = "android,firmware";
        vbmeta {
            compatible = "android,vbmeta";
            parts = "boot,system,vendor";
            by_name_prefix="/dev/block/platform/soc.0/f9824900.sdhci/by-name"
        };
        fstab {
            compatible = "android,fstab";
            vendor {
                compatible = "android,vendor";
                dev = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor";
                type = "ext4";
                mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
                fsmgr_flags = "wait,avb";
            };
        };
    };
};

Bug: 33254008
Test: early mount /vendor with vboot 2.0 (AVB) on bullhead
Test: early mount /system without dm-verity on bullhead
Test: early mount /vendor with vboot 1.0 on sailfish

Change-Id: I89a1f77c97124f309346b33d9e700544b92ecf05
Merged-In: I89a1f77c97124f309346b33d9e700544b92ecf05
(cherry picked from commit 8bba52fc4b)
2017-04-14 21:53:39 +08:00
Bowgo Tsai
a01f2f68ec fs_mgr: adds/changes some public APIs for early mount in init
Several changes in this CL:
  - Moves class FsManagerAvbHandle to public API
  - Adds a parameter 'wait_for_verity_dev' for FsManagerAvbHandle::SetUpAvb()
    to allow not to wait for verity device gets created
  - Adds FsManagerAvbHandle::AvbHashtreeDisabled() to query whether AVB is disabled
  - Adds fs_mgr_is_avb() to query whether a fstab_rec has MF_AVB flag

Bug: 33254008
Test: test AVB on bullhead
Change-Id: I89c43ca574ae632db8a700fc2590a1f80212c993
Merged-In: I89c43ca574ae632db8a700fc2590a1f80212c993
(cherry picked from commit 80d1ad17ed)
2017-04-14 21:51:26 +08:00
Bowgo Tsai
4ae3e510b3 fs_mgr_avb: refactors how vbmeta is loaded
Adds two classes FsManagerAvbhandle and FsManagerAvbVerifier to replace the
following functions or struct:

    - fs_mgr_load_vbmeta_images() -> FsManagerAvbhandle::Open()
    - fs_mgr_unload_vbmeta_images() -> deleted
    - fs_mgr_setup_avb() -> FsManagerAvbhandle::SetUpAvb()

    - androidboot_vbmeta -> FsManagerAvbVerifier
    - load_vbmeta_prop() -> FsManagerAvbVerifier::Create()
    - verify_vbmeta_images() -> FsManagerAvbVerifier::VerifyVbmetaImages()

And only invokes FsManagerAvbhandle::Open() when there is a fstab entry having
'avb' flag (need HASHTREE descriptor). fs_mgr_is_avb_used() can be
removed as it only checks system property "ro.boot.vbmeta.hash_alg" to
decide whether vbmeta needs to be loaded, which might not be accurate.

For example, there are only HASH descriptors in the verified chain but
no HASHTREE descriptors. In this case, the fs_mgr doesn't have to do
anything because it only takes care of HASHTREE descriptors.

Also adds a new class FsManagerAvbOps to provide the C++ binding
FsManagerAvbOps::AvbSlotVerify() for libavb->avb_slot_verify().

Bug: 33254008
Test: test AVB on bullhead
Change-Id: I8fe15ba01c277152630a2a5c1c5c7f25fbf34030
Merged-In: I8fe15ba01c277152630a2a5c1c5c7f25fbf34030
(cherry picked from commit 95c966a859)
2017-04-14 21:50:55 +08:00
Bowgo Tsai
c1f9cbaf8d fs_mgr: adding fs_mgr_get_slot_suffix() public API
The function returns "_a" or "_b" based on two possible values in
kernel cmdline:

  - androidboot.slot = a or b OR
  - androidboot.slot_suffix = _a or _b

Bug: 33254008
Bug: 36533366
Test: boot sailfish
Change-Id: Ia0a524e4145ebf61af5821f42ecad212c95ed748
Merged-In: Ia0a524e4145ebf61af5821f42ecad212c95ed748
(cherry picked from commit 87d0836cda)
2017-04-14 21:49:33 +08:00
TreeHugger Robot
5975d4e337 Merge changes I76212f65,I6a29c678 into oc-dev
* changes:
  init.rc: create /data/misc/reboot owned by system
  reboot: fix owner and permissions of last_reboot_reason file
2017-04-14 01:29:39 +00:00
TreeHugger Robot
d12835d19f Merge "init.rc: start all 3 servicemanagers early" into oc-dev 2017-04-14 01:15:47 +00:00
TreeHugger Robot
e003513ccf Merge "libutils: export system_headers" into oc-dev 2017-04-14 01:13:33 +00:00
Todd Poynor
e1e6edcf33 init.rc: create /data/misc/reboot owned by system
Directory will be read and modified by system uid.

Bug: 37251463
Test: Manual: reboot and inspect
Change-Id: I76212f65af991ff9ad0969b9c0b8460b80fb9cd2
2017-04-13 15:48:11 -07:00
Todd Poynor
dff584659c reboot: fix owner and permissions of last_reboot_reason file
Default signature WriteStringToFile creates world-writeable files.
Set owner and group system and remove read/write for non-owner.

Bug: 37251463
Test: Manual: reboot, inspect
Change-Id: I6a29c678168dcae611b120dc52170f4eee7069a9
2017-04-13 15:48:11 -07:00
Wei Wang
00cdc10662 init.rc: start all 3 servicemanagers early
With the binder traffic of composer moved to vndbinder,
vndservicemanager is needed to be started early to get bootanim
displayed quickly.

Also servicemanager is required to be start early to support early
bootanim and sufaceflinger.

Bug: 37306311
Test: bootanim regression fixed
Change-Id: Ice1e05bdb3fe4e67a63a49f1db8afdb018c7b61b
2017-04-13 21:06:17 +00:00
Steven Moreland
b084bc3545 libutils: export system_headers
vendor + vendor_available modules built with BOARD_VNDK_VERSION :=
current aren't allowed to use global headers. Since libutils uses
system headers itself, it should export them as well.

Also added some items into windows-deprecated.h. This file is supposed
to be in sync with the libnativewindow variant until all dependencies on
it can be fixed. However, it is missing some updates. This matters when
including libsystem_headers adds system headers before libnativewindow
headers in the lookup paths.

Bug: 33241851
Test: building with BOARD_VNDK_VERSION := current produces many fewer
errors.

Change-Id: I950821f1dae3ddc110db50869247913d5b1aa638
2017-04-13 12:05:16 -07:00
Keun-young Park
1c438c1baa use s_max_mnt_count to detect mke2fs generated partition
- Old tool will set it to 10 while mke2fs will set it to -1.
- For now, only tag it.
- TODO: possibly add different policy per image tool version.

bug: 32246772
Test: check dmesg after reboot

(cherry picked from commit 95e233f9ff)

Change-Id: Icd4758e240009d7b37df2d8a0e2a20d5ddbe4906
2017-04-13 11:32:53 -07:00
Jeffrey Vander Stoep
57d4c59559 Merge "init: expand generated attributes on sepolicy compile" into oc-dev 2017-04-13 18:11:08 +00:00
Jeff Vander Stoep
d278253378 init: expand generated attributes on sepolicy compile
Expand auto generated attributes in selinux policy when doing
on-device compile of platform + vendor selinux policy.

Bug: 3650825
Test: Build and boot Marlin
Change-Id: Icc1c3af0b504236ae13fd8a5155c2109befd7688
2017-04-13 17:32:51 +00:00
Vijay Venkatraman
95f9a9678d Merge "Moved include/backtrace to libbacktrace/include" into oc-dev 2017-04-13 16:53:13 +00:00
Vijay Venkatraman
a130b80069 Moved include/backtrace to libbacktrace/include
Export libbacktrace_headers

cherry-pick from commit 8f2c28d572

Bug: 33241851
Test: Build sailfish
Change-Id: Ied4168425ded95724d051ffdc9965c5927bc05ae
Merged-In: Iba310ffc21d17ba542bed954a960ab305037061c
2017-04-13 09:26:20 -07:00
TreeHugger Robot
bed3cbd8ac Merge "libutils: mark as vendor_available" into oc-dev 2017-04-13 04:55:20 +00:00
Martijn Coenen
f8952a196c Merge "restorecon hwservice_contexts." into oc-dev 2017-04-13 03:34:48 +00:00
Martijn Coenen
6887273a28 restorecon hwservice_contexts.
Test: marlin boots, angler boots
Bug: 34454312
Change-Id: I5da8b0b10a7a4c0e6e0c9aea39004852889e8d97
2017-04-12 18:02:33 -07:00
Jaesoo Lee
a02b1f5bed Merge "disable module loading after BOOT_COMPLETED broadcast" into oc-dev 2017-04-12 22:58:18 +00:00
TreeHugger Robot
a22648179d Merge "Moved all files from include/system to libsystem/include/system" into oc-dev 2017-04-12 20:56:21 +00:00
Dan Cashman
692c3e4d38 init: use platform sepolicy version indicated by /vendor.
It's possible, in the event of a platform update, for the platform
SELinux policy to change from the policy on which the vendor SELinux
policy was originally based.  In this case, a different mapping file
to bridge the differences between the new policy and the old needs to
be selected.

Make init choose which mapping policy file to use based on the version
reported in /vendor/etc/selinux/plat_sepolicy_vers.txt.

Bug: 36783775
Test: Force compilation of sepolicy on-device with mapping file changed
to new location and name, using the value reported on /vendor.

Change-Id: I63c883ccb79dd31c92dabe44a55c4ab50a3735e6
2017-04-12 10:45:08 -07:00
Steven Moreland
91527edec8 libutils: mark as vendor_available
By setting vendor_available, the following may become true:

* a prebuilt library from this release may be used at runtime by
  in a later releasse (by vendor code compiled against this release).
  so this library shouldn't depend on runtime state that may change
  in the future.
* this library may be loaded twice into a single process (potentially
  an old version and a newer version). The symbols will be isolated
  using linker namespaces, but this may break assumptions about 1
  library in 1 process (your singletons will run twice).

Background:

This means that these modules may be built and installed twice --
once for the system partition and once for the vendor partition. The
system version will build just like today, and will be used by the
framework components on /system. The vendor version will build
against a reduced set of exports and libraries -- similar to, but
separate from, the NDK. This means that all your dependencies must
also mark vendor_available.

At runtime, /system binaries will load libraries from /system/lib*,
while /vendor binaries will load libraries from /vendor/lib*. There
are some exceptions in both directions -- bionic(libc,etc) and liblog
are always loaded from /system. And SP-HALs (OpenGL, etc) may load
/vendor code into /system processes, but the dependencies of those
libraries will load from /vendor until it reaches a library that's
always on /system. In the SP-HAL case, if both framework and vendor
libraries depend on a library of the same name, both versions will be
loaded, but they will be isolated from each other.

It's possible to compile differently -- reducing your source files,
exporting different include directories, etc. For details see:

https://android-review.googlesource.com/368372

None of this is enabled unless the device opts into the system/vendor
split with BOARD_VNDK_VERSION := current.

Bug: 36426473
Bug: 36079834
Test: m -j libutils
Test: attempt to compile with BOARD_VNDK_VERSION := current
Merged-In: I6c1279a74ef071851401e38bbdd377f13827694c
Change-Id: I6c1279a74ef071851401e38bbdd377f13827694c
2017-04-12 16:00:02 +00:00
Tianjie Xu
585e6a89d7 Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426 am: 556afe82f2 -s ours am: de0f0b8ecc am: 89054eb706 am: ebcba388f5 am: 1bc2862ac5 -s ours am: c800d82044 am: 497461adc5 am: 02e7225f78 am: 587efe8ee9
am: 745f034705  -s ours

Change-Id: I12e470e1fbd46fd10f8092343d7950145da00cca
2017-04-11 20:20:38 +00:00
Tianjie Xu
06e1a3d8b2 Do Not Merge: Fix out of bound read in libziparchive am: a8d932f2a5 am: 368f3d273d -s ours am: f7903d4374 am: 18ccbc2ece am: df5ee70490 am: cce7621064 -s ours am: 01574980eb am: 2d37855038 am: 3c3eed744e am: 5fa554a46a
am: 223de992a4  -s ours

Change-Id: Ia2898016ac6aee1d72a58c62766e989e5d6d5dcf
2017-04-11 20:20:25 +00:00
Tianjie Xu
745f034705 Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426 am: 556afe82f2 -s ours am: de0f0b8ecc am: 89054eb706 am: ebcba388f5 am: 1bc2862ac5 -s ours am: c800d82044 am: 497461adc5 am: 02e7225f78
am: 587efe8ee9

Change-Id: Ief97c37295007df0da7ae36efeee8ac541f5e722
2017-04-11 20:20:01 +00:00
Tianjie Xu
223de992a4 Do Not Merge: Fix out of bound read in libziparchive am: a8d932f2a5 am: 368f3d273d -s ours am: f7903d4374 am: 18ccbc2ece am: df5ee70490 am: cce7621064 -s ours am: 01574980eb am: 2d37855038 am: 3c3eed744e
am: 5fa554a46a

Change-Id: I80db3090f5ab0efd50051a5fec2c61a5e947ab50
2017-04-11 20:15:01 +00:00
Tianjie Xu
587efe8ee9 Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426 am: 556afe82f2 -s ours am: de0f0b8ecc am: 89054eb706 am: ebcba388f5 am: 1bc2862ac5 -s ours am: c800d82044 am: 497461adc5
am: 02e7225f78

Change-Id: I687fc898264c93bedb34076bfa6d981d5059f381
2017-04-11 20:15:01 +00:00
Tianjie Xu
e170e3876b Fix out of bound read in libziparchive am: d9fd1863f4 am: 6908996434 am: 25c0d68d29 am: ed33065bfc am: bc8c8e4b56 am: afddaba0cc am: 0b1ad23070 am: d4b4f0a1e1
am: 2aea56db64

Change-Id: Ib2eebcb64ffb95737ef4a739dddf181dcdaa9fae
2017-04-11 20:11:24 +00:00
Tianjie Xu
02e7225f78 Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426 am: 556afe82f2 -s ours am: de0f0b8ecc am: 89054eb706 am: ebcba388f5 am: 1bc2862ac5 -s ours am: c800d82044
am: 497461adc5

Change-Id: I0b66858b609852df5a04aed279412fb2d03975a2
2017-04-11 20:11:00 +00:00
Tianjie Xu
5fa554a46a Do Not Merge: Fix out of bound read in libziparchive am: a8d932f2a5 am: 368f3d273d -s ours am: f7903d4374 am: 18ccbc2ece am: df5ee70490 am: cce7621064 -s ours am: 01574980eb am: 2d37855038
am: 3c3eed744e

Change-Id: I065c6eb98fcd7af9e486a211fb6f8611bcc7a5d3
2017-04-11 20:10:30 +00:00
Tianjie Xu
2aea56db64 Fix out of bound read in libziparchive am: d9fd1863f4 am: 6908996434 am: 25c0d68d29 am: ed33065bfc am: bc8c8e4b56 am: afddaba0cc am: 0b1ad23070
am: d4b4f0a1e1

Change-Id: Ib8d12d33296b0b5d618f4815e99eddebda342a5a
2017-04-11 20:05:01 +00:00
Tianjie Xu
3c3eed744e Do Not Merge: Fix out of bound read in libziparchive am: a8d932f2a5 am: 368f3d273d -s ours am: f7903d4374 am: 18ccbc2ece am: df5ee70490 am: cce7621064 -s ours am: 01574980eb
am: 2d37855038

Change-Id: I7cd9d0c60ef387cac0454e2adbe6d437899212a6
2017-04-11 20:05:01 +00:00
Tianjie Xu
497461adc5 Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426 am: 556afe82f2 -s ours am: de0f0b8ecc am: 89054eb706 am: ebcba388f5 am: 1bc2862ac5 -s ours
am: c800d82044

Change-Id: I09b7718561380c974ce2977b4390e12f262c11d7
2017-04-11 20:05:01 +00:00
Tianjie Xu
d4b4f0a1e1 Fix out of bound read in libziparchive am: d9fd1863f4 am: 6908996434 am: 25c0d68d29 am: ed33065bfc am: bc8c8e4b56 am: afddaba0cc
am: 0b1ad23070

Change-Id: I7aa4a7bb1e6b5619faadfb4cb3e047746a58b71a
2017-04-11 19:59:59 +00:00
Tianjie Xu
2d37855038 Do Not Merge: Fix out of bound read in libziparchive am: a8d932f2a5 am: 368f3d273d -s ours am: f7903d4374 am: 18ccbc2ece am: df5ee70490 am: cce7621064 -s ours
am: 01574980eb

Change-Id: I3a929ddc6eb1833b0653511d810662dcbaab8153
2017-04-11 19:59:59 +00:00
Tianjie Xu
c800d82044 Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426 am: 556afe82f2 -s ours am: de0f0b8ecc am: 89054eb706 am: ebcba388f5
am: 1bc2862ac5  -s ours

Change-Id: Id0399ee88604a6128e6ce3f7ee934c033d083861
2017-04-11 19:59:58 +00:00
Tianjie Xu
0b1ad23070 Fix out of bound read in libziparchive am: d9fd1863f4 am: 6908996434 am: 25c0d68d29 am: ed33065bfc am: bc8c8e4b56
am: afddaba0cc

Change-Id: Ie8f3874506403c092719f595fa7fb2402c6ecf36
2017-04-11 19:55:28 +00:00
Tianjie Xu
01574980eb Do Not Merge: Fix out of bound read in libziparchive am: a8d932f2a5 am: 368f3d273d -s ours am: f7903d4374 am: 18ccbc2ece am: df5ee70490
am: cce7621064  -s ours

Change-Id: I38c3c45a1043f56a1283d1ed5ad24016ab216bce
2017-04-11 19:55:28 +00:00
Tianjie Xu
1bc2862ac5 Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426 am: 556afe82f2 -s ours am: de0f0b8ecc am: 89054eb706
am: ebcba388f5

Change-Id: Ief12b93faaa3517e750b1702db487bb6e276d14b
2017-04-11 19:55:28 +00:00
Tianjie Xu
afddaba0cc Fix out of bound read in libziparchive am: d9fd1863f4 am: 6908996434 am: 25c0d68d29 am: ed33065bfc
am: bc8c8e4b56

Change-Id: I08e7c9e5c287c920e9c04a4e83f1862646a72e27
2017-04-11 19:51:00 +00:00
Tianjie Xu
cce7621064 Do Not Merge: Fix out of bound read in libziparchive am: a8d932f2a5 am: 368f3d273d -s ours am: f7903d4374 am: 18ccbc2ece
am: df5ee70490

Change-Id: I456228354620c7f5bdf5ccfee6ce9dbbea2e2e8d
2017-04-11 19:50:58 +00:00
Tianjie Xu
ebcba388f5 Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426 am: 556afe82f2 -s ours am: de0f0b8ecc
am: 89054eb706

Change-Id: I817162cb2f4e01ac88b1d81f3e7761a3110d116f
2017-04-11 19:50:57 +00:00
Tianjie Xu
bc8c8e4b56 Fix out of bound read in libziparchive am: d9fd1863f4 am: 6908996434 am: 25c0d68d29
am: ed33065bfc

Change-Id: Ia2b0e05ae0e248d692d9ad4ad62e53613203f08e
2017-04-11 19:45:58 +00:00
Tianjie Xu
df5ee70490 Do Not Merge: Fix out of bound read in libziparchive am: a8d932f2a5 am: 368f3d273d -s ours am: f7903d4374
am: 18ccbc2ece

Change-Id: Ib81a39d60f1d4e7551d759c6da5707c752eaf657
2017-04-11 19:45:58 +00:00
Tianjie Xu
89054eb706 Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426 am: 556afe82f2 -s ours
am: de0f0b8ecc

Change-Id: I71fa5fa39cc2ffc1dde4a68102399f349ee24d72
2017-04-11 19:45:57 +00:00
Tianjie Xu
18ccbc2ece Do Not Merge: Fix out of bound read in libziparchive am: a8d932f2a5 am: 368f3d273d -s ours
am: f7903d4374

Change-Id: Ic2cb35bbe317ef86c7eb177d53402d82a1cbe508
2017-04-11 19:39:58 +00:00
Tianjie Xu
ed33065bfc Fix out of bound read in libziparchive am: d9fd1863f4 am: 6908996434
am: 25c0d68d29

Change-Id: I81cde93d4a07077ef54a46d589db868019ac1520
2017-04-11 19:39:57 +00:00
Tianjie Xu
de0f0b8ecc Do Not Merge: Fix out of bound read in libziparchive am: 6fdfd58fe1 -s ours am: 2b4a6de426
am: 556afe82f2  -s ours

Change-Id: I90fc8d44976b063e450580b5bcb1a079ac09604b
2017-04-11 19:39:56 +00:00