Commit graph

827 commits

Author SHA1 Message Date
Paul Lawrence
c735bfe5da Fix bug in fs_mgr with calling vdc
Parameter count was hard coded to 3, make dynamic

Test: Metadata encrypted device boots

Change-Id: I25bb5adb7f27fc392564bfa6ed3ed2efeb5c5a40
2018-08-29 12:56:53 -07:00
Tom Cherry
7b02605bf2 Merge "Switch root to /system in first stage mount" 2018-08-29 17:05:40 +00:00
Mark Salyzyn
40b45b87c3 fs_mgr: set overlayfs_file context
Security minded hardening, let's not depend on reboot and restorecon.

Test: manual, make sure all sepolicy context are as expected before reboot
Bug: 109821005
Change-Id: I9d3419ce57be072daa55f704f75df7775fbaf5fb
2018-08-28 22:21:00 +00:00
Mark Salyzyn
62aeb16e1d fs_mgr: overlayfs skip mount points that are more specific
This is an optimization to limit us to an optimal set of overlay
mounts.  If an entry is identical or more specific (eg: /vendor is
less specific than /vendor/firmware_file), then no need to craft an
override for it.

We do the check in the setup and mount_all paths.

Test: confirm on devices with more specific mounts they do not get override
Bug: 109821005
Change-Id: If34775455fc7989903f70bc4f075c948db91ce37
2018-08-28 13:32:08 -07:00
Treehugger Robot
065cdf322f Merge "fs_mgr: correct support for ro.build.system_root_image" 2018-08-28 20:31:11 +00:00
David Anderson
356386246d fs_mgr: Better error messages in fs_mgr_update_verity_state.
With verity disabled, fs_mgr_update_verity_state spews some confusing
error messages from device-mapper. This change checks whether a device
exists and logs an explicit error.

Bug: N/A
Test: AVB properties are set correctly on AVB device
      Messages are logged correctly with AVB disabled

Change-Id: If490c18cfec2d63ad784972c13ceef63d9aa3e4c
2018-08-28 10:42:00 -07:00
Mark Salyzyn
d3dc3c825a fs_mgr: correct support for ro.build.system_root_image
Failed to convert fstab entries from "/" to "/system" when setting
up directory tree.  Introduce an internal fs_mgr_mount_point to
simplify conversion.

Test: manual
Bug: 109821005
Change-Id: Iadc1e967b92702cf01b6522f8f13b2cf3685f2af
2018-08-28 07:38:58 -07:00
Treehugger Robot
993ae1f271 Merge changes Ifab22a4c,I03eb9c78
* changes:
  fs_mgr: add fs_mgr_has_shared_blocks and make default if overlayfs
  fs_mgr: add overlayfs for small-space filesystems
2018-08-25 00:14:47 +00:00
Tom Cherry
4590a2aeb7 Switch root to /system in first stage mount
Bug: 79173823
Bug: 79758715
Test: boot hikey and observe that /system is the new root
Change-Id: I22f58f1332150ebae8e7e24eccfe780ff29eba7f
2018-08-23 11:12:57 -07:00
David Anderson
ee4075d84d liblp: Add ReadImageFromBlob.
This change enables reading metadata images from memory, for situations
where using file descriptors is not practical (such as fastbootd flash).

Bug: 78793464
Test: liblp_test gtest
Change-Id: I9ad08b0ddd4cbb96e87583237a90785e0f4befa4
2018-08-22 10:03:09 -07:00
David Anderson
1eb3ea37dc liblp: Refactor ParseMetadata to read from non-descriptors.
This is in preparation for "fastboot flash super", where we want to
verify the validity of a super image before writing it. To do so, we
need to parse the image from the download buffer, and it is useful to do
this from memory rather than a file descriptor.

Bug: 78793464
Test: liblp_test gtest
Change-Id: I7fb1ef4fdf2e8f1d93aea38f75626157fcb4bfc1
2018-08-22 10:03:09 -07:00
David Anderson
f1222908f4 liblp: Always copy geometry to LpMetadata.
Callers of ParseMetadata must manually copy geometry to the final
LpMetadata structure, which is error-prone. Instead, force callers to
pass geometry to ParseMetadata to ensure it is always propagated.

Bug: N/A
Test: liblp_test gtest

Change-Id: I5b24b9d94ab1857db600c40bf6d3c9d8aaa47368
2018-08-22 10:03:09 -07:00
Treehugger Robot
d1d06109ed Merge "liblp: FlashPartitionTable should update all slots." 2018-08-22 16:45:33 +00:00
Treehugger Robot
56d079b40a Merge "libdm: remove libbase dependency in header." 2018-08-22 15:30:43 +00:00
David Anderson
c720aa1893 liblp: FlashPartitionTable should update all slots.
Logical partition metadata has "slots" for AB purposes, but when
flashing or updating the partition table via fastboot, there is no
reason not to synchronize all copies of the metadata. It makes the state
of the super partition much more clear. It also makes the super
partition less likely to break on a slot change from the user, for
example if a "_b" partition is created before changing to the "b" slot.

Bug: 78793464
Test: liblp_test gtest
Change-Id: I3c44f0362f21f87d0bfc3a5c3394e26dc3dd38be
2018-08-21 16:18:32 -07:00
Yifan Hong
d449e2e59f libdm: remove libbase dependency in header.
libbase logging macros conflicts with libchrome's logging macros.
Test: compiles

Change-Id: I02697baa87c1466caf2e4ef58b0c8b2635982527
2018-08-16 11:12:36 -07:00
Tao Bao
d262346b57 Merge "fs_mgr: Drop some unneeded dependencies." 2018-08-15 18:14:16 +00:00
Mark Salyzyn
3ff87d89ef fs_mgr: add fs_mgr_has_shared_blocks and make default if overlayfs
Add fs_mgr_has_shared_blocks in fs_mgr.  Use it as a default decision
to utilize overlayfs if not overridden by the platform.

Test: compile
Bug: 109821005
Change-Id: Ifab22a4c9898966515e268349c24bb4c28a39368
2018-08-15 10:07:27 -07:00
Mark Salyzyn
53c96da749 fs_mgr: add overlayfs for small-space filesystems
If free space on the systems partition is less than 1%, then we may
use overlayfs to override the filesystem.

Test: manual
Bug: 109821005
Change-Id: I03eb9c7882cfd18db418a51e4964404f73f5ceb7
2018-08-15 10:07:16 -07:00
Tom Cherry
066fcdf820 Include some warnings about vendor_available for fsmgr.
The interface to fsmgr is subpar and while we haven't had time to
revisit it, we absolutely do not want to expose this to vendors in a
way that would force us to keep this interface in the future.

Test: n/a
Change-Id: I970048aa2e45d7f7eca357d052141e90d6e01123
2018-08-14 13:11:14 -07:00
Mark Salyzyn
7186787342 fs_mgr: correct error handling
Fix a few areas that mismanage error return values, and can result in
confusing messaging from the adb commands.

Test: manual
Bug: 109821005
Change-Id: Ib00069c9605df453ac8f600c7906649deebfd626
2018-08-14 07:56:03 -07:00
Mark Salyzyn
5f6b06973b fs_mgr: use ro.persistent_properties.ready
Replace more complicated logic that determines that persistent
properties are now valid with a simple check of
ro.persistent_properties.ready.

Test: manual
Bug: 109821005
Change-Id: I3e43df8283cb97abbf5c0333e64db4ad11703798
2018-08-14 07:55:55 -07:00
Tao Bao
7aa4608053 fs_mgr: Drop some unneeded dependencies.
libfs_mgr doesn't have direct dependencies on libfec_rs / libkeyutils /
libsquashfs_utils. They were only needed when libfec and libext4_utils
were statically linked into libfs_mgr.

Bug: 112494634
Test: `m -j installclean && m -j bootimage` with aosp_taimen-userdebug.
      Check the installed files in recovery image.
Test: `mmma -j system/core/fs_mgr`
Change-Id: I4b12c2df344fabba4942b6db943cf43a031b591d
2018-08-13 23:03:03 -07:00
Greg Kaiser
b4bf8c66a3 fs_mgr: Small fix in overlayfs setup/teardown
In user builds, we fix fs_mgr_overlayfs_{setup,teardown} to
properly set the optional 'change' boolean, if it was provided.

Test: TreeHugger
Change-Id: I91fc99d801f8fd782b21f0ecaecddfc7744f0c3e
2018-08-10 05:24:25 -07:00
Mark Salyzyn
d9e6c2020e fs_mgr: get fs_mgr_mount_all to call fs_mgr_overlayfs_mount_all
After fs_mgr_mount_all has added the resources, let
fs_mgr_overlayfs_mount_all to read-only mount overlayfs over the
possible system partitions.

Test: compile
Bug: 109821005
Bug: 110985612
Change-Id: I7101a04c57de1a26283b1523636d07fa8e19ffc7
2018-08-08 15:38:53 -07:00
Mark Salyzyn
b28389f5ee fs_mgr: add overlayfs handling for squashfs system filesystems
Logistics for adb remount on developer builds for readonly system
partitions using overlayfs to deal with not being able to remount
with read-write.

Conditions are that filesystem is squashfs, read-only, debug build,
kernel supports overlayfs.  The default is a valid /cache/overlay/
directory, with .../<mount_point>/upper and .../<mount_point>/work,
associated with each system partition <mount_point>.

Will take the sepolicy of context of lowerdir as rootcontext= option.

Add fs_mgr_overlayfs_mount_all() to recurse through
fs_mgr_read_fstab_default(), and checking against /proc/mounts to
add any acceptable overlayfs mounts.  The checking with /proc/mounts
makes sure we do not overlayfs overtop an overlayfs.

Add fs_mgr_overlayfs_setup(const char*, const char* bool*) and
fs_mgr_overlayfs_teardown(const char*, bool*) to respectively setup
or teardown the overlayfs support directories.  Return value
includes success and optional supplied change booleans.

Test: compile
Bug: 109821005
Bug: 110985612
Change-Id: Ie9b4e9ca0f2bdd9275ac2e2e905431636948e131
2018-08-08 15:38:53 -07:00
Greg Kaiser
954c141c48 Revert "Support Speck encryption."
This reverts commit 49c27c5cb2.

Remove the Speck encryption support. It was eventually
decided not to allow Speck in Android P, so this code
is no longer needed and wasn't used outside of testing.

Bug: 112009351
Test: Confirmed AES continues to work with FBE.
Change-Id: Ia5458143be5687fff8d541d8fa2c8ee24a369da4
2018-08-07 10:10:31 -07:00
Xin Li
5d707816ac Merge "Merge Android Pie into master" 2018-08-07 16:51:24 +00:00
Treehugger Robot
4f878cf6cb Merge "fs_mgr: Do not mount empty partitions." 2018-08-07 00:52:34 +00:00
David Anderson
6868cb9f5e fs_mgr: Do not mount empty partitions.
If a logical partition is resized to 0 bytes, it will have no extents.
This is not allowed by device-mapper, but is useful for effectively
compacting partitions with "fastboot flashall". If all logical
partitions are resized to 0, then resized to their intended size, then
we will allocate extents more efficiently.

However, if a partition is left with a zero size (either intentionally
or not), this should not throw the device into a reboot loop due to
CreateLogicalPartitions failing. Instead we skip partitions with no
extents.

Bug: 78793464
Test: with fastbootd:
        fastboot create-partition example 4096
        fastboot resize-partition example 0
      device reboots successfully

Change-Id: I572efa949176c8c3c493ef00438d8badd4d7cf4f
2018-08-06 15:59:38 -07:00
David Anderson
4d71d85805 liblp: Allow flashing to readonly logical partitions.
By default, logical partitions with the readonly flag are created with a
readonly device. This change allows callers of CreateLogicalPartition
to create writable devices so they can still be flashed.

Bug: 78793464
Test: fastboot flash product_services works with fastbootd
Change-Id: Ia8d2761a3067e3b62815acbf0b6fb7f033072ba2
2018-08-06 15:47:26 -07:00
David Anderson
8660f5a85c Merge "liblp: Try to merge extents during partition resizes."
am: b0c9318493

Change-Id: Ib124843c47f710665e1d9134eae11edb7575863e
2018-08-03 15:58:35 -07:00
David Anderson
727c80765d Merge "liblp: Add more logging for logical partition operations."
am: 805bc5d757

Change-Id: If08681fc946f0bd21854459c7efd5986e81a7823
2018-08-03 15:57:21 -07:00
Treehugger Robot
b0c9318493 Merge "liblp: Try to merge extents during partition resizes." 2018-08-03 20:02:41 +00:00
David Anderson
1aab3909f7 liblp: Try to merge extents during partition resizes.
When adding extents to partitions, if the previous extent and new extent
are contiguous, merge them together to avoid allocating unnecessary
device-mapper targets.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I80087df9aea8141c5e16f8d4cdb3dd7da02aee8c
2018-08-03 11:02:25 -07:00
David Anderson
b9f734c936 liblp: Add more logging for logical partition operations.
This logs when partition tables update, when partitions resize, and when
partitions are unmapped from device mapper.

Bug: N/A
Test: N/A
Change-Id: I1125332c79fccc3ebc556b3b48856901e2503c47
2018-08-03 10:59:43 -07:00
David Anderson
0bade5b848 Merge changes from topic "liblp-blocksize"
am: d0e5bcc13f

Change-Id: I95e14110705740db955800fc05ff9b1371226cc1
2018-08-02 12:31:15 -07:00
David Anderson
4d9c7459c4 liblp: Require block-aligned partition sizes.
DM_TABLE_LOAD will reject dm-linear entries if their size is not a
multiple of the backing device's logical block size. For example, a
partition of 10GiB+512 bytes will fail to map in device-mapper if the
logical block size is 4096 bytes. To address this, this patch adds a
few changes to liblp:

The block size given to lpmake is now recorded in LpGeometryMetadata.
The block size must be a multiple of the sector size. In addition,
partiton sizes are now aligned to the block size, and the super
partition must have enough free space to allocate at least one block (in
addition to storing metadata).

GrowPartition now has multiple checks that the block-size invariant is not
violated, to ensure that no invalid partition tables will be created.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I484aac1f9b90ebd92dc1c89ce1e09cd89bbb441e
2018-08-02 10:33:41 -07:00
David Anderson
de1daa72aa liblp: Simplify GrowPartition().
The partition resize algorithm duplicates a lot of logic because it
handles the final free interval separately from other free intervals.
This is unnecessary and makes it harder to change the actual algorithm.

This change makes GrowPartition() treat the final free space region the
same as free gaps in between partitions. It does this by converting the
extent list into a gap list, and then adds a final gap for the remainder
of the free space. The resize function no longer has to treat the end of
the disk separately.

This patch does not change the way partitions are allocated, it is
purely a refactoring.

Bug: 79173901
Test: liblp_test gtest
Change-Id: I4780f20b23fe021eac62de874b061857712c04fe
2018-08-02 09:14:47 -07:00
David Anderson
432a51dcdc Merge "liblp: Add a ResizePartition helper to MetadataBuilder."
am: ddcee93c01

Change-Id: I187c1aba212a754d282f3ec7a65f3fda549f6e28
2018-08-02 09:13:02 -07:00
Treehugger Robot
ddcee93c01 Merge "liblp: Add a ResizePartition helper to MetadataBuilder." 2018-08-02 16:01:24 +00:00
David Anderson
2e755e38af liblp: Add a ResizePartition helper to MetadataBuilder.
This change is to assist with implementing the fastbootd "resize-partition"
command. The GrowPartition and ShrinkPartition functions are now
private.

Bug: 78793464
Test: N/A
Change-Id: Ic66a3052359e2558663272ff6e014704206b197e
2018-08-01 17:41:29 -07:00
Luis Hector Chavez
d4ee791365 Merge "fs_mgr: Always mount tmpfs with MS_NOEXEC"
am: 8f2a34a89b

Change-Id: I80ac903329f24756ef8a3d9bade11f446b2e1c31
2018-08-01 16:16:27 -07:00
Treehugger Robot
8f2a34a89b Merge "fs_mgr: Always mount tmpfs with MS_NOEXEC" 2018-08-01 22:41:56 +00:00
Tom Cherry
780d80b5a6 Merge "init: run fsck for early mount partitions"
am: 6e05552e35

Change-Id: I6b44584616557ef3c58039eff6ce7eaf3c2d7623
2018-08-01 14:11:19 -07:00
Tom Cherry
6e05552e35 Merge "init: run fsck for early mount partitions" 2018-08-01 21:02:35 +00:00
Tom Cherry
81ae07509d init: run fsck for early mount partitions
Bug: 111883560
Test: fsck runs successfully during early mount
Change-Id: I19bcd2610f87f5331f94c228fcbec8f9379fc5e8
2018-07-31 13:58:17 -07:00
David Anderson
4444219482 Merge "liblp: Allow building liblp as a shared library."
am: 2756339c77

Change-Id: I20ea48eff3843461cdc00c470643088d350195f6
2018-07-28 15:57:51 -07:00
David Anderson
f792e4163d liblp: Allow building liblp as a shared library.
Bug: 79173901
Test: system image, partition_tools both build
Change-Id: I70f45d4cebfbddc39d03aa3fb3a56b6c48a20d7e
2018-07-27 19:34:56 -07:00
Jerry Zhang
3051d54902 Merge "Move recovery to /system/bin"
am: 0937a84521

Change-Id: Ic3f3eb82178e6c5af22945e3aaaac3f86beb4ec8
2018-07-27 13:34:11 -07:00