Commit graph

1175 commits

Author SHA1 Message Date
Mark Salyzyn
94a0dedbc4 fs_mgr: overlayfs: test: Add --print-time option
Make it easier to collect test execution time.

Clean up some noise restoring device to original state.

Test: adb-remount-test.sh --print-time
Bug: 123079041
Change-Id: I56f12698ff25362dcefcf8a6ddd8f96a23b37f34
2019-02-25 21:33:33 +00:00
Treehugger Robot
084d3b9124 Merge "libfs_avb: support rollback protection for Live GSI" 2019-02-22 16:28:23 +00:00
Bowgo Tsai
918668a2cd libfs_avb: support rollback protection for Live GSI
This commit extracts the security patch level (SPL), e.g.,
com.android.build.system.security_patch = 2019-04-05 from AVB property
descriptors when attempting to mount a standalone image (e.g., live
GSI). Then compares the SPL between the old system.img and the new live
system.img for rollback protection.

Bug: 122705329
Test: boot an old Live GSI, checks rollback is detected
Change-Id: I7aae58c0b2062a3ff57ed932ad58e7b604453fed
2019-02-21 10:32:18 +08:00
Tom Cherry
15800946e0 __android_log_is_debuggable() shouldn't be an apex symbol
Remove a superfluous check in fs_mgr, since those return values are
already impossible for a non-debuggable build.  Replace a one time
call to __android_log_is_debuggable(), since there's no reason to
cache the value or use this symbol.

Test: build
Change-Id: Icd4bef7b616c49d304303747388d7e3018c6fcfc
2019-02-20 12:52:02 -08:00
Bowgo Tsai
9bbaa7bbee Adding GSI fstab entries when needed
In ReadFstabFromFile(), currently it always adds 'system_gsi' and
'userdata_gsi' fstab entries when running in Live GSI. As the API
might be used to load a fstab file without "/system" and/or "/data",
it's better to replace "/system" with 'system_gsi' and "/data" with
'userdata_gsi', instead of adding 'system_gsi' and 'userdata_gsi'
unconditionally.

Bug: 124640105
Test: boot a Live GSI, then `atest libfs_avb_device_test`

Change-Id: I52928f95b9ebd12ce09ffd538caf96a2de430dbc
2019-02-18 13:27:53 +00:00
Paul Trautrim
c10d3fdb2c Add presubmit test for vendor overlay
Add a test that creates files in the appropriate vendor_overlay directory and
verifies that they are correctly overlaid (or not) onto /vendor after rebooting.

Test: locally running atest
Change-Id: I65860dbeb837f86ac030fa51b3af93844e82de96
2019-02-16 08:24:35 +09:00
Mark Salyzyn
bbe33f7826 fs_mgr: harden adb-remount-test.sh
Harden adb-remount-test.sh script.  Add --no-color and --color
options.  Allows --serial to be passed in.  Add a recovery handler
that restores the device to verity enabled if possible.  List the
partitions sizes as they may be relevant to triaging errors.  Allow
for devices that have a mixed set of remounts, some direct, some
with overlayfs.  Allow two scripts to run at the same time on a host
machine targetting different devices.  Detect if wrong adb is used
for adb reboot-fastboot.

Add a build target for adb-remount-test.sh so that the script
is landed into the host tools bin for easy pickup.

Test: adb-remount-test.sh
Bug: 123079041
Change-Id: I6369a245a656419067ec4350a4dbdf78c9b0533e
2019-02-15 14:28:19 -08:00
David Anderson
cb13a7766e Merge "Enable metadata encryption for userdata_gsi." 2019-02-14 20:27:05 +00:00
Mark Salyzyn
dffdb4374b fs_mgr: overlayfs: export fs_mgr_overlayfs_candidate_list
Refactor fs_mgr_candidate_list into fs_mgr_overlayfs_candidate_list
that reports all the possible candidates.  The caller is responsible
for filtering out any that have verity enabled.

Sundry improvements to the adb-remount-test.sh script to improve
stability and feedback.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: I2399f83d8ed77d8f3d2ad1405d0c187ccbace764
2019-02-13 10:49:18 -08:00
Treehugger Robot
c7b5c4fa6b Merge "libfs_avb: adding two public APIs" 2019-02-13 03:07:37 +00:00
Tom Cherry
5272f9b017 Merge "Refactor fs_mgr_update_verity_state()" 2019-02-12 17:22:09 +00:00
Bowgo Tsai
cd316ea4a0 libfs_avb: adding two public APIs
The client can include <fs_avb/fs_avb_util.h> to use the two new
functions to load vbmeta for a FstabEntry and extract the hash tree
descriptor from the loaded vbmeta, respectively.

// Given a FstabEntry, loads and verifies the vbmeta.
std::unique_ptr<VBMetaData> LoadAndVerifyVbmeta(...);

// Gets the hashtree descriptor with avb_partition_name from the vbmeta.
std::unique_ptr<FsAvbHashtreeDescriptor> GetHashtreeDescriptor(...);

Bug: 65470881
Test: atest libfs_avb_test
Test: atest libfs_avb_internal_test
Test: atest libfs_avb_device_test
Change-Id: I7d6619eb8140c14734ffb8f8a1b22cddd2f562f0
2019-02-12 22:03:20 +08:00
Tom Cherry
d2ae1c91ed Merge "Remove logic to fake /system in overlayfs" 2019-02-12 01:04:21 +00:00
Tom Cherry
cf80b6d6e5 Refactor fs_mgr_update_verity_state()
fs_mgr_update_verity_state() has two callers with generally different
intentions.  One caller loops through all entries in the default fstab
to set partition.<mount_point>.verified properties.  The other caller
is only interested in whether or a specific mount point has verity
enabled.

Given this, we refactor fs_mgr_update_verity_state() to
fs_mgr_get_verity_mount_point() which takes a single FstabEntry and
returns the mount point used for the dm-verity device or an empty
option if verity is not enabled on that mount point.

Test: adb-remount-test.sh test on blueline
Change-Id: Ic7dd8390509e95b2931b21e544c919a544138864
2019-02-11 12:50:22 -08:00
Tom Cherry
6576e13995 Remove logic to fake /system in overlayfs
It is better to guarantee that a /system or / entry will be present in
first stage mount than it is to maintain the code to fake an entry if
its not present in the input fstab.

Test: adb-remount-test.sh on blueline
Change-Id: I8aa3e704903b8abf06b1c63be071913a9de58eb3
2019-02-08 16:25:24 -08:00
David Anderson
88045aef59 Enable metadata encryption for userdata_gsi.
Rather than constructing a userdata fstab entry from scratch, this patch
will modify the vendor fstab to preserve the desired encryption
properties and filesystem type.

Bug: 123906417
Test: manual test
Change-Id: I338715fc62628169e8eafbf4a3125e4aadf0ff15
2019-02-08 15:44:00 -08:00
Mark Salyzyn
60d5467bd8 fs_mgr: overlayfs: documentation: update kernel patch details
Confusion has occurred with respect to the kernel patch requirements,
added some clarity.

Corrected some spelling mistakes in other areas.

Test: inspect gitties and run spell
Bug: 118225373
Change-Id: I4ff9497aa5a584b20e9cb2028342aa4e7e4660c3
2019-02-08 11:49:05 -08:00
Mark Salyzyn
fab9f08ea5 fs_mgr: overlayfs: fs_mgr_overlay_setup true if already mounted
fs_mgr_overlayfs_setup return false second time around if all
are setup. It should report true if candidate list is all done.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: Ic9e16489e2c8ac4d3de91fcf8cfceedc23595e94
2019-02-06 15:35:45 -08:00
Mark Salyzyn
6d109ecba3 fs_mgr: overlayfs support legacy devices (marlin)
Expand the tests to deal with the boot environment for marlin.
Recognize that older overlayfs drivers do not report to /sys/module
and the parsing /proc/filesystem is another place to interrogate this.

Suppress adb push and pull noise during testing.  Resolve APEX
failures.  Add some cleanup to test script.

NB: Running test to completion is difficult because marlin's USB
    driver is flakey enough through the multitude of reboots and
    may not reconnect.  The tester will have to notice when a reboot
    is stalling and manually disconnect and reconnect the USB
    connection to trigger discovery and to continue through the
    test sequences.  To make this easier, report when we are
    waiting for the device to make it easier to babysit.

Test: system/core/fs_mgr/tests/adb-remount-test.sh
Bug: 120448575
Bug: 123079041
Change-Id: I5fc5f01b4e4788ac57541cb5235f7ac4e4284d71
2019-02-06 15:35:29 -08:00
Treehugger Robot
bece53e515 Merge "fs_mgr: fstab: logspam from empty flags" 2019-02-06 17:59:42 +00:00
Mark Salyzyn
c0d09a2603 fs_mgr: fstab: logspam from empty flags
If a flag is empty (eg: reading /proc/mounts), skip instead of
reporting "unknown flag: ". Do the same for "defaults".

Test: compile
Change-Id: Ibc3dc7154bbef4bb5dc6522d3226b6ca1e60ec24
2019-02-05 14:31:38 -08:00
Tom Cherry
7dec4fdd38 fs_mgr: Remove fs_mgr_flags #define's
These are no longer used but I missed them in the last CL.

Test: treehugger
Change-Id: Iea5235cf2d105c80a406f0ef020080859c0d2ff7
2019-02-05 13:04:21 -08:00
Tom Cherry
7303edd194 Merge "Remove old C fs_mgr interface" 2019-02-05 17:06:03 +00:00
Tom Cherry
685c2c7b1e Remove old C fs_mgr interface
Remove superfluous fs_mgr flags as well.

Bug: 62292478
Test: tree hugger, fs_mgr_unit_test
Change-Id: Ib307400941b46ca8bcb51d479668efd82fc3ed2d
2019-02-04 15:09:02 -08:00
Dan Shi
5c937a3a5d Move the tests to postsubmit group
The tests are failing on ToT.

Bug: 123852953
Test: None
Change-Id: I2e75c99d913f6954290aa9d6aada8797bf931977
2019-02-04 10:31:32 -08:00
Treehugger Robot
0ed7819d6a Merge "Restrict zram_writeback permission" 2019-02-02 03:31:38 +00:00
Wei Wang
aa25756426 Restrict zram_writeback permission
Bug: 74582279
Bug: 122659265
Test: Build
Change-Id: Iba610929bc02d7ee5a590f8ec5b440269dbc12f5
2019-02-01 11:57:00 -08:00
Treehugger Robot
66e76443a0 Merge "Support getting public key data" 2019-01-31 23:29:19 +00:00
Tom Cherry
54ea49ba05 Merge "Add android::fs_mgr namespace for new Fstab code" 2019-01-31 19:35:54 +00:00
Bowgo Tsai
7ee1aaea74 Support getting public key data
This allows the client to get the public key data without need to
provide the expected key data to load vbmeta. Then do the comparison by
themselves, to allow "key rotation".

Bug: 65470881
Test: atest libfs_avb_test
Test: atest libfs_avb_internal_test
Test: boot a device
Change-Id: Icd4e317c2f79cd35e46cdd14f858575ee692facd
2019-01-31 16:49:33 +08:00
Treehugger Robot
a15f385821 Merge changes from topic "move_bionic_to_apex3"
* changes:
  Handle adb sync with Bionic under /bionic
  Proper mount namespace configuration for bionic
2019-01-31 04:46:49 +00:00
Tom Cherry
a3530e6366 Add android::fs_mgr namespace for new Fstab code
Should have been done a while ago, but better late than never.

Test: treehugger
Change-Id: I0ea6e8d459cd3f3b3ce2d00a7a6a9786d52c52dd
2019-01-30 20:20:05 -08:00
Treehugger Robot
083797adfd Merge "Improved libdm and dmctl to handle very large numbers of extents" 2019-01-31 02:00:32 +00:00
Bowgo Tsai
ee6114fb1d Enable AVB for dynamic GSI (f.k.a. Live Image)
Bug: 117960205
Test: Use the dynamic Android to start GSI, checks verity is enabled.
Change-Id: I93b321808ba278b162fec5e231bff7229cac3937
2019-01-31 07:06:14 +08:00
Paul Lawrence
605fef0e17 Improved libdm and dmctl to handle very large numbers of extents
Enables performance testing with very large numbers of dm-linear devices

Test: Can create device with 16384 extents, and can get its table
Bug: 123261135
Change-Id: I0e78a659eb7616e4db6a8276031e25a0d84f52ba
2019-01-30 13:29:41 -08:00
David Anderson
98910920ba Merge "libfiemap_writer: Remove Flush and Write methods." 2019-01-30 17:34:13 +00:00
Jiyong Park
7c7189c469 Handle adb sync with Bionic under /bionic
Background:
We now have two sets of Bionic: the bootstrap Bionic which is at
/system/{lib|bin}/bootstrap for early processes and the default Bionic
which is from the runtime APEX for all the others. In order to give the
same path for Bionic to both categories of processes, the init prepares
two mount namespaces and bind-mount appropriate Bionic files onto the
common mount points under /bionic. For example,
/system/bin/bootstrap/linker is bind-mounted to /bionic/bin/linker for
the early processes. Likewise, /apex/com.android.runtime/bin/linker is
bind-mounted to the same path for rest of the processes.

In addition, in order not to propagate mount events in one mount
namespace to the other namespace, /bionic itself is created as a mount
namespace (via self bind-mount) and its propagation type is set to
private.

Changes required:
This however requires some adjustments to adb sync and remount
mechanism.

For remounting, /bionic path should also be re-mounted for RW, because
it is a RO mount in the beginning. This remounting is done only for the
system-as-root devices where entire / can be re-mounted as RW.

For synching, the sync thread creates a temporary mount namespace where
there is no bind-mount. This ensures that a path that the thread handles
is pointing to the correct file that is expected from the client side.

In addition, push operation to /bionic path is done without unlinking.
This is required because the mount points under /bionic are gone in the
current mount namespace but are still active in other mount namespaces.
If unlinked, the existing mounts on the path are all silently removed.
In order to prevent the unwanted situation, the moint points are not
unlinked but truncated to 0. This however is not a significant problem
because the files that serve as mount points do not carry any
useful information (i.e. the content is meaningless).

Bug: 879416
Test: adb sync
adb push <random_file> /bionic/bin/linker64
adb push <random_file> /system/bin/bootstrap/bin/linker64
system/core/fs_mgr/tests/adb-remount-test.sh
Change-Id: Id87dc9ee7ec5c43d06b54969b55e2cb394329317
2019-01-30 19:18:22 +09:00
Treehugger Robot
6c44d00d79 Merge "fs_mgr: make changes needed to port vold to new Fstab interface" 2019-01-30 06:31:50 +00:00
Treehugger Robot
30fef71b2c Merge "libfs_avb: support enable verity for a standalone partition" 2019-01-30 02:25:39 +00:00
Tom Cherry
2e545f8b2f fs_mgr: make changes needed to port vold to new Fstab interface
Particularly, capitulate that GetEntryForMountPoint() would be cleaner
than std::find_if() and update the rest of system/core to use it.

Test: build

Change-Id: I982b5a8552d44852d3ab22c20db83afcd4dd652b
2019-01-29 14:56:49 -08:00
David Anderson
1326648f05 libfiemap_writer: Remove Flush and Write methods.
We no longer use these methods since they require write access to the
userdata block device. This patch removes them to simplify FiemapWriter,
and avoid opening userdata with write permissions.

Bug: 122556707
Test: fiemap_writer_test gtest
Change-Id: I0091eb5ff92253533c67c89b0059c34953aae211
2019-01-29 13:49:43 -08:00
Bowgo Tsai
defe1cb5e7 libfs_avb: support enable verity for a standalone partition
The following static function has been added into class AvbHandle to
support loading the AVB hashtree descriptor to enable dm-verity for
a FstabEntry.

  static AvbHashtreeResult SetUpStandaloneAvbHashtree(FstabEntry* fstab_entry);

Bug: 112103720
Bug: 117960205
Test: atest libfs_avb_test
Test: atest libfs_avb_internal_test
Test: Add /system/etc/system_other.avbpubkey, then add
      avb_key=/system/etc/system_other.avbpubkey into /system/etc/fstab.postinstall.
      factory reset, boot a device and checks that system_other is
      mounted with verity (see the serial log below)

Serial log:
-----------
init: [libfs_avb]Built verity table: '1 /dev/block/by-name/system_a
    /dev/block/by-name/system_a 4096 4096 8521
    8521 sha1 895ba03023a35172b393429fadad9ee228b39203
    3405d16fec2cd12ad9e6b36d3bc983e1e83b5e09 10 use_fec_from_device
    /dev/block/by-name/system_a fec_roots 2 fec_blocks 8589 fec_start 8589
    restart_on_corruption ignore_zero_blocks'

init: [libfs_mgr]superblock s_max_mnt_count:65535,/dev/block/dm-7

init: [libfs_mgr]__mount(source=/dev/block/dm-7,target=/postinstall,type=ext4)=0:
Success

Change-Id: Ie339a43ff9c6a7d170e12ef466df666b98ddec19
2019-01-29 22:42:24 +08:00
Treehugger Robot
c90b0eafda Merge "Adding libfs_avb host tests into presubmit" 2019-01-29 01:46:41 +00:00
Treehugger Robot
47a4082f88 Merge "Remove extranous reading of fstab in BuilderTest::block_device_info" 2019-01-29 00:30:54 +00:00
Tom Cherry
b688d917cd Remove the rest of users of the old style fstab
And deprecate one more old style function that is not used after this
change.

Test: boot, disable and enable verity
Change-Id: Id509f479850120352b4ea4dc3b6c40f6e8e2e53e
2019-01-28 12:34:33 -08:00
Tom Cherry
679a6bacc6 Remove extranous reading of fstab in BuilderTest::block_device_info
Previously information from the fstab was needed for this test, but
that's not longer the case, so skip reading the fstab altogether.

Test: build
Change-Id: I3989c62e19ae2d8606f2bc3a617f9cc3da0e5a6f
2019-01-28 11:04:18 -08:00
Tom Cherry
2f0331d9b6 fs_mgr: remove old fs_mgr functions that are not currently used
New code should be using the new Fstab class, so remove these older
functions that don't have current users.

Test: build
Change-Id: I3ba2b12b838b4b46979963869939fd4b65264738
2019-01-28 09:06:10 -08:00
Tom Cherry
561498e357 Merge changes Ibdecf0c9,I41bd92a7,I5669ed10
* changes:
  fs_mgr: test parsing all mount and fs mgr options
  fs_mgr: convert parse_flags over to C++
  fs_mgr: store file_contents_mode and file_names_mode directly
2019-01-28 16:52:25 +00:00
Treehugger Robot
33cff00c1c Merge "fs_mgr: ReadDefaultFstab suppress ReadFstabFromDt logging" 2019-01-26 03:47:49 +00:00
Tom Cherry
eb6da459a0 fs_mgr: test parsing all mount and fs mgr options
Test: these new unit tests
Change-Id: Ibdecf0c97b313dc157b982340ca022b617757383
2019-01-25 16:03:52 -08:00