Commit Graph

549 Commits

Author SHA1 Message Date
Yu Ning 6a38aa83b6 Allow the use of a custom Android DT directory
On platforms that use ACPI instead of Device Tree (DT), such as
Ranchu x86/x86_64, /proc/device-tree/firmware/android/ does not
exist. As a result, Android O is unable to mount /system, etc.
at the first stage of init:

 init: First stage mount skipped (missing/incompatible fstab in
 device tree)

Those platforms may create another directory that mimics the layout
of the standard DT directory in procfs, and store early mount
configuration there. E.g., Ranchu x86/x86_64 creates one in sysfs
using information encoded in the ACPI tables:

 https://android-review.googlesource.com/442472
 https://android-review.googlesource.com/443432
 https://android-review.googlesource.com/442393
 https://android-review.googlesource.com/442395

Therefore, instead of hardcoding the Android DT path, load it from
the kernel command line using a new Android-specific property key
("androidboot.android_dt_dir"). If no such property exists, fall
back to the standard procfs path (so no change is needed for DT-
aware platforms).

Note that init/ and fs_mgr/ each have their own copy of the Android
DT path, because they do not share any global state. A future CL
should remove the duplication by refactoring.

With this CL as well as the above ones, the said warning is gone,
but early mount fails. That is a separate bug, though, and will be
addressed by another CL.

Test: Boot patched sdk_phone_x86-userdebug system image with patched
      Goldfish 3.18 x86 kernel in patched Android Emulator, verify
      the "init: First stage mount skipped" warning no longer shows
      in dmesg.

Signed-off-by: Yu Ning <yu.ning@intel.com>

(cherry picked from commit c08d2cb0fb7ce470e128c7571553aa12ae9b57a4)

Change-Id: Ia8d5f68e044fde0ecf5c7b14e40f040ff42bc35d
2017-07-31 15:27:09 -07:00
Bowgo Tsai 2e774b01f8 Merge "fs_mgr_verity: allow verification error when the device is unlocked" am: a68f633675 am: 84937296c6 am: e5de94756b
am: 2e19aa92ed

Change-Id: If3779eceac8084723c101a6f7fa9091c4f09128e
2017-07-20 02:03:34 +00:00
Bowgo Tsai 2e19aa92ed Merge "fs_mgr_verity: allow verification error when the device is unlocked" am: a68f633675 am: 84937296c6
am: e5de94756b

Change-Id: Iedca76aea1c93320bbba29bcd013d1cd331380de
2017-07-20 02:01:05 +00:00
Bowgo Tsai 84937296c6 Merge "fs_mgr_verity: allow verification error when the device is unlocked"
am: a68f633675

Change-Id: Iba60c7f544ae86a1487354a9e799cab7167f37ad
2017-07-20 01:55:04 +00:00
Bowgo Tsai b674894199 fs_mgr_verity: allow verification error when the device is unlocked
On a A/B device, the image combination in VTS is:
  - system.img (userdebug): provided by Google (system as root)
  - vendor.img (user): provided by the OEM

The generic system.img provided by Google doesn't have /verity_key.
So verified boot will fail when it tries to verify the signature of
vendor.img. This CL allows signature verification error (including
no verity_key) when the device is unlocked.

This CL also changes the return value to FS_MGR_SETUP_VERITY_SKIPPED when
signature verification failed in logging mode. Otherwise, first stage
mount will fail because it assumes verity device initialization should be
successful when receiving FS_MGR_SETUP_VERITY_SUCCESS.

Bug: 63821912
Test: boot generic system.img on a A/B device
Change-Id: I33e5ef753913ae9f0c8b02c518ae94d4c8505611
2017-07-19 18:45:40 +08:00
Tom Cherry a222129aff Merge changes from topic 'ext4_encryption_flag' am: 5be05733c2 am: 5a6226929e am: d165de95da
am: e1442a5df0

Change-Id: I470057eb4ccc0536eed869114cb999daf36469dc
2017-07-14 23:22:26 +00:00
Tom Cherry e1442a5df0 Merge changes from topic 'ext4_encryption_flag' am: 5be05733c2 am: 5a6226929e
am: d165de95da

Change-Id: I11ebc6c79bcd5cf6b8fd619b1a71582b7c788d41
2017-07-14 23:18:02 +00:00
Tom Cherry 5a6226929e Merge changes from topic 'ext4_encryption_flag'
am: 5be05733c2

Change-Id: I242f679bb96f9ae71b624db4cbcb54dda5be5ee4
2017-07-14 23:11:43 +00:00
Tom Cherry 5be05733c2 Merge changes from topic 'ext4_encryption_flag'
* changes:
  fs_mgr: set ext4 encryption flag with tune2fs when needed
  fs_mgr: refactor pre-mount logic into prepare_fs_for_mount()
2017-07-14 23:06:30 +00:00
Bowgo Tsai dc43b54d33 Merge "fs_mgr: trim the terminating '\0' when reading from device tree" am: b76158d56a am: 3205cd6cc4 am: 776c67b4d5
am: ec721bdda2

Change-Id: I229b411a591b04de4bb557b1bc5b604d9a2e63d0
2017-07-14 05:32:33 +00:00
Bowgo Tsai ec721bdda2 Merge "fs_mgr: trim the terminating '\0' when reading from device tree" am: b76158d56a am: 3205cd6cc4
am: 776c67b4d5

Change-Id: I5cccad6c1d5df0dd0b5505eaf18353c96ba5ea72
2017-07-14 05:26:30 +00:00
Bowgo Tsai 3205cd6cc4 Merge "fs_mgr: trim the terminating '\0' when reading from device tree"
am: b76158d56a

Change-Id: I8498667cfdd266827a936a9e9a0bac50dc9699f4
2017-07-14 05:18:04 +00:00
Bowgo Tsai f559655912 fs_mgr: trim the terminating '\0' when reading from device tree
Bug: 63637343
Test: boot device
Change-Id: I35ead1ad852493f7f92bdb6c87617fde57b3b0be
2017-07-13 15:11:16 +08:00
Eric Biggers e9811f36e5 fs_mgr: set ext4 encryption flag with tune2fs when needed
Upstream kernels (v4.9+, v4.4.67+) have started to enforce that
encryption policies cannot be set on ext4 directories unless
EXT4_FEATURE_INCOMPAT_ENCRYPT is set in the filesystem superblock, as
was the original design.  Since Android's userspace was not setting this
flag, it was not possible to use "file-based encryption" (FBE) on
devices whose kernels enforce this constraint.  Fix this by updating
fs_mgr to set the flag if needed, similar to how it enables the quota
feature if needed.

Note that it would, eventually, be simpler to set this flag at mkfs
time.  But that seems infeasible for now, given the many different ways
the userdata filesystem can be formatted --- including via 'fastboot',
which I believe is expected to still be compatible with old devices
whose kernel and/or e2fsprogs don't support the 'encrypt' flag.

Bug: 36231741
Change-Id: Ibafb9a7116fc853b62f8ee074a78499399f290a6
2017-07-06 13:31:30 -07:00
Eric Biggers 8d3bcd4b6a fs_mgr: refactor pre-mount logic into prepare_fs_for_mount()
There were several duplications in the code that runs before a
filesystem is mounted.  This made it difficult to start running tune2fs
to set the encryption feature flag.  Refactor to deduplicate the logic,
and improve the log messages.

Bug: 36231741
Change-Id: I90846dad9c5ec85b3c5460615dec4cc19cb7e198
2017-07-06 13:31:30 -07:00
Jinguang Dong d974500314 Merge "fs_mgr: Adding logs when failing to wait for a device file" am: 4ca2a30368 am: 694985721f am: 0ac18b28cd
am: febf2ad9d7

Change-Id: I8070df926d9949583e84dca03e5dd8acc78c8968
2017-07-06 04:24:38 +00:00
Jinguang Dong febf2ad9d7 Merge "fs_mgr: Adding logs when failing to wait for a device file" am: 4ca2a30368 am: 694985721f
am: 0ac18b28cd

Change-Id: I055425b0dfdbccbfa9c72e9bb1390ea483afdb9c
2017-07-06 04:23:26 +00:00
Jinguang Dong 694985721f Merge "fs_mgr: Adding logs when failing to wait for a device file"
am: 4ca2a30368

Change-Id: I19ba38a596527a4544437d126c80123381b065b4
2017-07-06 04:20:55 +00:00
Treehugger Robot 4ca2a30368 Merge "fs_mgr: Adding logs when failing to wait for a device file" 2017-07-06 04:19:00 +00:00
Jinguang Dong 9d344969b0 fs_mgr: Adding logs when failing to wait for a device file
During mount operations, fs_mgr_wait_for_file() is invoked to
ensure the device file exists before starting to mount it. Adding
logs when the wait fails and also skip mounting as it won't be
successful. Also merge fs_mgr_test_access() and wait_for_file()
as fs_mgr_wait_for_file().

Test: Boot device and manually trigger the timeout issue
Test: Check and confirm whether timeout log info is inside ksmg.

Change-Id: Ide6d7fdca41e03e169e4400f91b7dea327985aaf
2017-07-06 09:51:02 +08:00
Bowgo Tsai e892b7cdef Merge "fs_mgr: allow no verity metadata when the device is unlocked." am: cd0c2d8962 am: 328b56585e am: 06c6bf67e9
am: 3f10ecabf8

Change-Id: Id5317f717bf6d7a1e1be695b773b9abcad41ee56
2017-07-06 01:37:53 +00:00
Bowgo Tsai 3f10ecabf8 Merge "fs_mgr: allow no verity metadata when the device is unlocked." am: cd0c2d8962 am: 328b56585e
am: 06c6bf67e9

Change-Id: Id1f3d275fdeadca1b23a086725b3f63aedc5a141
2017-07-06 01:12:59 +00:00
Bowgo Tsai 328b56585e Merge "fs_mgr: allow no verity metadata when the device is unlocked."
am: cd0c2d8962

Change-Id: Icebfb3c34b3c2878c4015f36dafe893c577b40c9
2017-07-06 00:46:09 +00:00
Treehugger Robot cd0c2d8962 Merge "fs_mgr: allow no verity metadata when the device is unlocked." 2017-07-06 00:29:47 +00:00
Mark Salyzyn 054192270f Merge "fs_mgr: report errno string for __mount errors" am: 6333cd0938 am: eef732555d am: ab6f80c350
am: 0c7862b805

Change-Id: Ica3272ac4c2e76fe2df04eeaa6e07e18d768b0f1
2017-07-05 22:00:16 +00:00
Mark Salyzyn 0c7862b805 Merge "fs_mgr: report errno string for __mount errors" am: 6333cd0938 am: eef732555d
am: ab6f80c350

Change-Id: I1dcef448c82402404652921f8113b2a576158f57
2017-07-05 21:58:15 +00:00
Mark Salyzyn eef732555d Merge "fs_mgr: report errno string for __mount errors"
am: 6333cd0938

Change-Id: Ic3c85f6ed01d5edd2bfd0a29063610b4d8159f31
2017-07-05 21:54:17 +00:00
Bowgo Tsai d1fe3bdbd6 fs_mgr: allow no verity metadata when the device is unlocked.
To boot with generic system.img for project Treble, we should allow no verity
metadata when the device is unlocked. The previous fix checks system property
"ro.boot.flash.locked" but it's unavailable during first stage mount.
This CL checks "androidboot.verifiedbootstate" in kernel command line instead.

Bug: 63268209
Test: boot sailfish without metadata on /vendor

Change-Id: Ifd1dbeb2a2f09cd06903ecdd59bc94b3905a3fbd
2017-07-05 17:22:35 +08:00
Mark Salyzyn 69a5bd4357 fs_mgr: report errno string for __mount errors
Need to know why the mount failed.  clang_format adjustment.

Basically change LINFO to PINFO to cause the log message for the mount
report to be accompanied by a strerror(errno) message appended to the
end so that it is clear why the mount was rejected.

Test: manual
Bug: 63100799
Change-Id: Ic958299759befe5d5b11bdc95fea5d64cad86412
2017-06-28 21:52:34 +00:00
Jiyong Park 28bd98999b resolve merge conflicts of 645026c74 to oc-dr1-dev-plus-aosp
Test: I solemnly swear I tested this conflict resolution.
Merged-In: If8fc73e4ae4c2f8281c41a12f1c18079aab8baa2
Change-Id: Iadfcd7e75044d62f2015dc62c69ee68869b40cd7
2017-06-28 22:52:25 +09:00
Jiyong Park 22ca4f76c2 resolve merge conflicts of 20d9cf2ee to stage-aosp-master
Test: I solemnly swear I tested this conflict resolution.
Merged-In: If8fc73e4ae4c2f8281c41a12f1c18079aab8baa2
Change-Id: Ie7feb839c9da2a11579ed850680c044c9fc3432a
2017-06-28 05:55:43 +00:00
Treehugger Robot 20d9cf2ee7 Merge "fs_mgr: add libfstab for vendor" 2017-06-28 04:57:48 +00:00
TreeHugger Robot 05f113c038 Merge "fs_mgr: add libfstab for vendor" 2017-06-28 03:45:36 +00:00
Jiyong Park e7df1f7623 fs_mgr: add libfstab for vendor
libfstab is a subset of libfs_mgr, intended for vendors to use. It
exposes APIs for reading fstab. Note this 'visible to vendor' does not
mean that the API should be stable forever. The API can be changed in
later releases of Android, ,but the newer Android must not cause
run-time error when there is an older version of this static library
being used somewhere.

Bug: 62990533
Test: BOARD_VNDK_VERSION=current m -j libfstab.vendor
Change-Id: I371174fa1f6b4de6d6dd437b84ce4ed1e8740672
Merged-In: If8fc73e4ae4c2f8281c41a12f1c18079aab8baa2
2017-06-28 11:24:25 +09:00
Mark Salyzyn 4a4259b51b Merge changes Ibe1feb39,I05be83e4,If1422e4d am: a4f086ab20 am: 3a156e6c2b am: ca0c0bb96e
am: 872206fd80

Change-Id: I9c08baaf94f2eaaf2ad9633e70b9cd0c1dd484ed
2017-06-27 22:14:25 +00:00
Mark Salyzyn 872206fd80 Merge changes Ibe1feb39,I05be83e4,If1422e4d am: a4f086ab20 am: 3a156e6c2b
am: ca0c0bb96e

Change-Id: I21636d01cf0cb0bd581104d2bfb5624877bfaf6a
2017-06-27 21:57:34 +00:00
Mark Salyzyn 3a156e6c2b Merge changes Ibe1feb39,I05be83e4,If1422e4d
am: a4f086ab20

Change-Id: I7e5d431c992f9860ca7b42ca81edfbfd1d8e0a1c
2017-06-27 21:52:06 +00:00
Mark Salyzyn cab56c0ba5 fs_mgr: check console-ramoops-0
On later kernels /sys/fs/pstore/console-ramoops becomes
/sys/fs/pstore/console-ramoops-0

Test: none
Bug: 63058217
Change-Id: If1422e4df09b68c44f16608b1d191aeb6378c66b
2017-06-27 09:10:16 -07:00
Jiyong Park 5eeb934689 fs_mgr: add libfstab for vendor
libfstab is a subset of libfs_mgr, intended for vendors to use. It
exposes APIs for reading fstab. Note this 'visible to vendor' does not
mean that the API should be stable forever. The API can be changed in
later releases of Android, ,but the newer Android must not cause
run-time error when there is an older version of this static library
being used somewhere.

Bug: 62990533
Test: BOARD_VNDK_VERSION=current m -j libfstab.vendor
Change-Id: If8fc73e4ae4c2f8281c41a12f1c18079aab8baa2
2017-06-27 16:16:22 +09:00
Bowgo Tsai 8ee91bf77c Merge "AVB: allow no metadata in the generic system.img for project Treble" am: c70bf5836c am: caa5b4417f am: 2410d0c792
am: 61cdb66230

Change-Id: I23cdb0a5826f3378245375c5f5551aa46edd8536
2017-06-24 01:54:51 +00:00
Bowgo Tsai 61cdb66230 Merge "AVB: allow no metadata in the generic system.img for project Treble" am: c70bf5836c am: caa5b4417f
am: 2410d0c792

Change-Id: I5b03a7ac1cdb883df27aca8122c4a1383d805126
2017-06-24 01:51:47 +00:00
Bowgo Tsai 2410d0c792 Merge "AVB: allow no metadata in the generic system.img for project Treble" am: c70bf5836c
am: caa5b4417f

Change-Id: I4859e15d3bf05c22a708761e91b2e52fbb28ca1f
2017-06-24 01:40:33 +00:00
Bowgo Tsai 60f19a0792 AVB: allow no metadata in the generic system.img for project Treble
The generic system.img released from project Treble can't contain any verity
metadata (e.g., vboot 1.0, AVB, or any other implementation) because it's
*generic*. To make any device can boot with it, `avbctl disable-verification`
is introduced to set a new flag AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED
in the top-level vbmeta to disable the entire AVB verification process. This
should be done prior to flash the generic system.img. See the following link
for details:

    https://android-review.googlesource.com/#/c/418399/

This CL checks whether AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED is
set in the top-level vbmeta. When set, skip verifying the vbmeta structs
against androidboot.vbmeta.{hash_alg, size, digest} because it will be
absent in kernel cmdline. Also, only top-level vbmeta struct is read then
returned by libavb in this case.

Note that another flag AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED, usually
set by `adb disable-verity`, is used to signal fs_mgr to skip setting up
dm-verity, but libavb still verifies all vbmeta structs. fs_mgr will
also verify all vbmeta structs against androidboot.vbmeta.{hash_alg,
size, digest} from kernel cmdline as well.

Also rename SetUpAvb() to SetUpAvbHashtree() to better fit its usage.
This function will return kDisabled when any of the above two flags is set.

Finally, regardless of which flag is set or not set, we still only allow two
return values from avb_slot_verify():

   - AVB_SLOT_VERIFY_RESULT_OK: it's still possible to get this value
     when any of these flags are set in build time. e.g.,
     BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2

   - AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION: in most cases we should
     get this value, because the flags are likely set at run time.

Bug: 62523303
Test: boot device with 'avbctl disable-verification'.
Test: boot device with 'avbctl enable-verification'.
Test: boot device with 'adb disable-verity'.
Test: boot device with 'adb enable-verity'.

Test: build image with BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2, then boot device.
      repeat the above steps to boot device again.

Change-Id: Ie8436f3e0e82c78490208f3b85eac5238a9fdfdb
2017-06-24 09:20:15 +08:00
Ben Fennema 6ac5322a33 fs_mgr: properly propagate exec child errors
Child status was being requested, but ignored, so if the exec failed
with something like file not found or permissions denied the return
value with be 0 (success). Passing in NULL instead of &status causes
the failure to be properly returned from execvp instead of in status.

Test: erase f2fs userdata on device without /system/bin/make_f2fs and
      verify device boots into recovery to format the partition instead
      of believing the format succeeded and going into infinite f2fs.fsck
      loop.
Bug: 62901965
Signed-off-by: Ben Fennema <fennema@google.com>
Change-Id: Ia5bbf09d5a666402cba8437abcc56775583ba6d2
2017-06-22 15:08:38 -07:00
Sandeep Patil e37c3df0e8 Merge changes from topic 'eng_first_stage_mount' am: b7e2f272ee am: e5341cf56a am: 91b5f4b172
am: 2980f49447

Change-Id: I7ddb996a9efcc42a3dcde1dc5843304498e7b9a7
2017-06-22 00:24:05 +00:00
Sandeep Patil 2980f49447 Merge changes from topic 'eng_first_stage_mount' am: b7e2f272ee am: e5341cf56a
am: 91b5f4b172

Change-Id: Iea367c4aa1a9fe381c4b5b4b23f6365035b4939d
2017-06-22 00:15:48 +00:00
Sandeep Patil 91b5f4b172 Merge changes from topic 'eng_first_stage_mount' am: b7e2f272ee
am: e5341cf56a

Change-Id: I285217db1c18adfcc10d31280c1ec55d80052e43
2017-06-22 00:08:17 +00:00
Sandeep Patil 95366e97dd fs_mgr: differentiate if fs_mgr_set_verity() was skipped or disabled
In case of non-secure builds (eng variant) fs_mgr_setup_verity() skips
verity checks regardless of fstab options. This is slightly different
than 'adb disable-verity' where it would first read the verity metadata
to check if verity is disabled.

So, this change adds a new return value of FS_MGR_SETUP_VERITY_SKIPPED
instead of piggy backing on the FS_MGR_SETUP_VERITY_DISABLED.

Bug: 62864413
Test: Boot sailfish

Change-Id: I42bf2bdce0ecb18b4c3b568e2bc96bf1590dfb35
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-06-21 15:04:46 -07:00
Jin Qian f71bc0c152 fs_mgr: replace make_ext4 api with e2fsprogs
Execute mke2fs to create empty ext4 filesystem.
Execute e2fsdroid to initialize selinux context.

Test: zero-out first 4k of data partition and reboot,
      fs_mgr successfully formats /data.
Bug: 35219933
Change-Id: If6f72f62c618c64be703b83f0114a4dd0a2b079f
2017-06-20 13:53:56 -07:00
Bowgo Tsai fecd8c26cf Merge "fs_mgr_verity: support updating actual block device path in verity table" am: 4c28ca1ac8 am: 95d78849b4
am: 3b0512b75c

Change-Id: I8d11be54322e57b9bf904907198b7058af7be4df
2017-06-10 03:07:09 +00:00