Commit graph

96 commits

Author SHA1 Message Date
Paul Crowley
3d8e105510 Set metadata cipher in fstab
Bug: 147814592
Test: Cuttlefish can use adiantum
Change-Id: I9207ffcdb74dcd36c8b2534b51233a3f8e80dc0b
2020-01-31 14:45:00 -08:00
Paul Crowley
7823e327c1 Rename key_dir to metadata_key_dir and refactor
Bug: 147814592
Test: Crosshatch boots
Change-Id: I18b03486d2e93c6103880d1af68d9f70147fde63
2020-01-30 16:03:45 -08:00
David Anderson
c13586faea remount: Use /data for backing scratch storage.
Currently, this is only enabled for Virtual A/B devices. When /data uses
F2FS, then proper pinning support must be enabled.

Because /data cannot be mounted in recovery, we can't delete the scratch
image backed by /data while in fastbootd. Instead, we mark it as
disabled in /metadata. The remount command now has an init script that
checks for and removes a disabled scratch partition.

Bug: 134949511
Test: adb remount on V A/B device with patched F2FS
Change-Id: Ifc8720378259654472d3822e97059b6c366f601d
2020-01-28 12:04:38 -08:00
Bookatz
685e19dc97 CtsFsMgrTestCases secondary_user
Marks this CTS test module as supporting secondary_user, meaning that
the tests are eligible to be run from a regular Android user other
than the system user (i.e. other than user 0).

Note that 'user' here refers to the concept of users in Android
Multiuser; it is NOT the same as a uid.

Bug: 141773058
Test: module passed with secondary_user params
 (--enable-optional-parameterization --module-parameter secondary_user)

Change-Id: I1829a4297a49cd38b4b8a2558c92941acab8ab9a
2020-01-06 09:49:17 -08:00
Nikita Ioffe
5110628a12 Fix logic to figure out what /data fstab entry was mounted
Now the logic is handled by following API:
GetMountedEntryForUserdata(Fstab* fstab).

Behind the scenes it does the following:
1. Reads /proc/mounts and gets block device /data is actually mounted on.
2. In case of it's a dm-device, recursively goes into it's slaves until
finds the underlying block device.
3. Optimistically assumes that corresponding block device is a symlink
and tries to read it.
4. Reads all the entries corresponding to /data from fstab.
5. For each of them, optimistically tries to readlink block_device.
6. If it matches the resolved block devices, we found our fstab entry!

Also added a test to CtsFsMgrTestCases asserting that /data was mounted
from one of entries in default fstab.

Test: on blueline & taimen, with & without checkpointing:
Test: atest CtsFsMgrTestCases
Test: adb reboot userspace

Bug: 135984674
Change-Id: Ic70daeeb18096c7b134004334cc674dacc6e36f3
2019-11-22 13:34:59 +00:00
Nikita Ioffe
6aa1b01316 Merge changes I7a3c181a,I72c60ec8
* changes:
  Add a test asserting that default fstab has /data entry
  Add fs_mgr_unit_test to CTS
2019-10-29 09:17:04 +00:00
Paul Crowley
51c41e94d9 Merge "fs_mgr: Don't parse encryption options, just keep string" 2019-10-29 02:00:36 +00:00
Paul Crowley
4fa841350f fs_mgr: Don't parse encryption options, just keep string
We now defer parsing encryption options to the fscrypt library. To avoid
adding a dependency, we simply record the options string in the fstab
and defer parsing until it's needed.

Bug: 143307095
Test: cuttlefish still boots
Change-Id: Ied13ea2f731c63b0524aed11db6983a86dab9fa1
2019-10-28 13:41:00 -07:00
Nikita Ioffe
3f334dcaa4 Add a test asserting that default fstab has /data entry
When aosp/1149619 is merged, userspace reboot will start to depend on
the fact that default fstab has an entry for /data, hence this test
to make sure that this is the case.

Bug: 135984674
Test: atest CtsFsMgrTestCases
Change-Id: I7a3c181a6b27a7b4dfc344ff04be712f3fe3376e
2019-10-28 16:47:47 +00:00
Nikita Ioffe
607cbbf1e8 Add fs_mgr_unit_test to CTS
Test: atest --rebuild-module-info CtsFsMgrTestCases
Bug: 135984674
Change-Id: I72c60ec8acdcb3539da091abb4f84e0bc3c6743b
2019-10-28 16:28:02 +00:00
Nikita Ioffe
e93b12847f Fixed fs_mgr#fs_mgr_read_fstab_file_proc_mounts test
It was failing with:
Expected equality of these values:
mnt_opts
Which is: { "data=ordered", "discard", "noatime", "nodev", "nosuid", "rw", "seclabel", "sync" }
fs_options
Which is: { "data=ordered", "discard", "noatime", "nodev", "nosuid", "rw", "seclabel" }

Test: atest fs_mgr_unit_test
Change-Id: I3bb084d62e81fda8948a100515bdaad62d18bb54
2019-10-28 14:42:01 +00:00
Eric Biggers
736557c510 Merge changes from topic "fscrypt-key-mgmt-improvements"
* changes:
  init/fscrypt_init_extensions: support setting v2 encryption policies
  fs_mgr_fstab: support specifying encryption policy version in fstab
2019-10-07 19:09:43 +00:00
Mark Salyzyn
63f97b6f49 fs_mgr: overlayfs: fsck scratch filesystem
Enable fsck phase for scratch filesystem.  Solved a resulting
problem where the end of the fsck executable would result in a
SIGHUP to the caller.

Add some debugging details from adb-remount-test.sh script

Test: adb-remount-test.sh
Bug: 138577868
Bug: 139283818
Bug: 139226412
Change-Id: I129d86b7cf4e938001ba6db8d03247bc9903988d
2019-10-02 13:30:07 -07:00
Eric Biggers
d964376a92 fs_mgr_fstab: support specifying encryption policy version in fstab
Allow the encryption policy version to be specified as a third field in
the "fileencryption=" fstab option, and expose it through the fstab
record so that vold can use it.

Bug: 140500999
Test: tested as series; see If64028d8580584b2c33c614cabd5d6b93657f608.
      Also updated and ran the fs_mgr unit tests.
Change-Id: If5d56f4c84c4cd51e3f14c0a861c3e3ab6ff903f
2019-09-30 10:27:38 -07:00
Mark Salyzyn
6f07a8af11 fs_mgr: overlayfs: test: noatime on rw mounts only
Regression from commit 808763e825
("fs_mgr: overlayfs: noatime").  Test fails on some targets
that do not follow our advise to mount noatime for all partitions.
blueline mounts the system partitions relatime.  In the grand
scheme this is not a problem because we never remount these
partitions read-write because of the overlayfs integration.

Filter out read-only mounts from those enumerated for noatime,
those failures do not concern us in the context of this test.

This test expected to fail if CtsOsTestCases EnvironmentTest fails.

Test: adb-remount-test.sh
Bug: 140253722
Bug: 140014856
Change-Id: I778e7f539ac3f3d6495867e264767f2af25e11c7
2019-08-29 14:12:39 -07:00
Mark Salyzyn
808763e825 fs_mgr: overlayfs: noatime
Should not have used relatime for overlayfs and backing storage
mounts, noatime reduces the wear and tear on the flash device.

This should prevent triggering a falure in the CtsOsTestCases that
tries to spot mounts attached to block storage from updating atime
and resulting in churn.  This statement does not mean we support
performing Cts tests with devices that have deployed
'adb disable-verity' or 'adb remount'.

Post-mortem: relatime was not a 'problem' for overlayfs, copy and
             paste for those flags resulted in the use of relatime
	     for scratch backing storage.

Test: adb-remount-test.sh
Bug: 140014856
Change-Id: Ic97b98ceacaa265094364487ea70cc99b6aee92f
2019-08-28 13:13:13 -07:00
Mark Salyzyn
18085418ee fs_mgr: overlayfs: empty system partitions excluded.
Beside using the 1% threshold for determining that a filesystem
should be an overlayfs candidate, do so also if the free space
is below 8MB.  This will cover nearly empty filesystems that can
not be right-sized below the smallest ext4 filesystem size.

Adjust the test to cover the new cases.

Should test all system partitions, including new /system_ext and
any others that get added in the future.

Fix instance of dir that were supposed to be die.  Using || die
does not work as expected within a function, so use if ! <cond>.

Test: adb-remount-test.sh
Bug: 139471424
Change-Id: If3e4cac5dce7bee998727052130eaf362e9e2fb5
2019-08-15 11:37:18 -07:00
Mark Salyzyn
ae8b8a4e00 fs_mgr: adb-remount-test: non-verity recovery
For devices that do not have verity, or start the test with
verity disabled, but are using overlayfs, use a 'secret' surgical
technique to revert the device back to original state.

adb enable-verity will carry risk in that if the device did not
arrive with verity enabled, we can not guarantee it will boot
if we turn on verity.

Test: atest adb-remount-sh
Bug: 138649540
Change-Id: If6d55c57fb9daca9305c42a4df2c18c7f8c5eefa
2019-08-12 10:14:18 -07:00
Mark Salyzyn
9daf79f43f adb-remount-test: add /system/priv-app
In 4.19+ kernels not yet patched, /system/priv-app/<file> can
cause EPERM on fstat of the directory, resulting in failure to
access content.

Test: adb-remount-test.sh
Bug: 138649540
Change-Id: I96d1acb3cdb80824c9d2ebce415ea6e1253f9c5b
2019-07-30 09:31:45 -07:00
Mark Salyzyn
f6d8a631fa adb-remount-test: support devices that do not have verity
This allows the test to run to completion on cuttlefish

Test: adb-remount-test.sh
Bug: 138649540
Change-Id: Ief00af72af94bf14c1d69499b12ece8cfce2f552
2019-07-30 09:31:37 -07:00
Mark Salyzyn
91eb2c0a25 adb-remount-test add --no-wait-screen option
If the device screen drivers or frameworks are compromised, permit
remount testing without waiting for full boot complete to occur with
the --no-wait-screen option.  In the same vein to support development,
add --wait-adb and --wait-fastboot options to adjust the timeout.

For TreeHugger testing where other (previous) tests demonstrate
framework or screen regressions, it _may_ be advised to switch to the
--no-wait-screen option so that we do not register a false signal.
It should be noted that some of the past issues with overlayfs and
adb remount could introduce boot up, framework or screen regressions,
so it is advised to not use the option if that interlocking logic can
not be set up.

Test: adb-remount-test.sh
Bug: 138649540
Change-Id: Idf8f4a0eb6d7c9139bd4f2c600d14a70dc71902f
2019-07-30 09:31:29 -07:00
David Anderson
c65121306a Introduce inotify-based replacements for fs_mgr_wait_for_file.
Bug: 134966533
Test: fs_mgr_unit_test gtest
Change-Id: I36802b87cec59b5277267eb919851ca390fea425
2019-06-18 15:27:09 -07:00
Mark Salyzyn
bc79fea7a1 fs_mgr: overlayfs: test: spelling mistake
Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I7bc68c15f53f94d1c14e2da91157ade362bc72f8
2019-06-05 11:12:05 -07:00
Mark Salyzyn
4d702e8dea fs_mgr: overlayfs: test: triage data missing after failure flash scratch
After flashing empty image to scratch device, the device did not
return after 3 minutes.  It also did not collect any triage data
reporting only:

[  FAILED  ] did not reboot after flash

Add triage data, increase timeout to 4 minutes.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: Ic607abb5b2575d630bf6c27817a38a90820d24e1
2019-06-03 12:53:07 -07:00
Mark Salyzyn
cfe658a04e adb-remount-test: do not brick devices that support overlayfs but do not use it
restore() should not run adb enable-verity if device does not
use overlayfs even though it supports it.

Test: adb-remount-test
Bug: 132070014
Change-Id: I55d0e1a87eca9c5f258a1587c844f2a6e4b13b29
2019-05-28 08:11:54 -07:00
Mark Salyzyn
d07ab7e544 adb-remount-test: provide additional mount details
For the wipe and remount vendor test, report the df and
mount states to help triage.

Test: adb-remount-test.sh
Bug: 129319403
Change-Id: I4d9a87766d9857a974e601324ab77f69681bfd28
2019-05-28 08:08:49 -07:00
Mark Salyzyn
67788ef8a1 adb-remount-test: check devt and inode
Check to make sure st_dev and st_ino for the uploaded content
is as expected.

Test: adb-remount-test
Bug: 129319403
Bug: 132395411
Change-Id: I89826fc2740dfd2ead4bcd8988cfbbc315b77b09
2019-05-28 08:08:49 -07:00
Mark Salyzyn
d5f89343b1 adb-remount-test: add an avc check
Check if adb remount resulted in any unlabeled references just before
rebooting the device.

Test: adb-remount-test.sh
Bug: 129319403
Bug: 132395411
Change-Id: Ica0c14da39773f615d9b5e4cfc4602bd50c70e4e
2019-05-28 08:08:49 -07:00
Mark Salyzyn
53ec0a4649 adb-remount-test: parameterize fastboot_wait & adb_wait, increase timeout
Increase adb_wait time to 3 minutes since blueline device takes
maximum 2:38 (ten samples) to perform a ramdump should an
inopportune kernel panic occur.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: Icfbb799f9420035a755090c9fc5fc2ee05dd68d3
2019-05-28 08:08:49 -07:00
Mark Salyzyn
359c56493c adb-remount-test: report wait duration
Report any unusual durations for how long it took to wait for the
device to come back if --print-time flag.  Also report the boot
reason if unexpected.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I233bbc7b01b025739d7d63191cb62952fa4b7b2a
2019-05-28 08:08:49 -07:00
Mark Salyzyn
00dd058a15 adb-remount-test: check vendor image signature before using
When developing and using the adb remount test, if device under test
is flashed from another source than the current visible tree, make
sure that the vendor image as-built and visible in a sandbox build
is not used indiscriminantly.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I30569a7c871f4c4038b0f7f9c05f5f1a5d12c766
2019-05-28 08:08:49 -07:00
Mark Salyzyn
dbd99f0d2b adb-remount-test: report usb user on unexpected connection
Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I1bc4009b71cac4ac4e06df38cc4da77f2819b88b
2019-05-28 08:08:49 -07:00
Mark Salyzyn
93bb1d0d6d adb-remount-test: wait-for-screen
If we reboot too agressively after a fresh flash either just before
test is run, or after vendor is flashed, we run the risk the device
will consider it a bad boot and head towards recovery or revert to
previous system.

Add checks to wait for the screen.

This can result in the test reporting issues with boot complete,
which will not fail the test currently, but can be used to determine
if the device under test is in a boot loop or fragile state.

Test: fastboot flashall ; adb-remount-test.sh
Bug: 132070014
Change-Id: Ia1b3800c44222cb8fbd9b00e897b32a256996ebc
2019-05-28 08:08:49 -07:00
Mark Salyzyn
277e413ac4 adb-remount-test: adb_reboot stdin issue
adb reboot can pull stdin content, block it.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I36f0bb7486cec2a18cd2b5550650a19f05c904b5
2019-05-28 08:08:49 -07:00
Mark Salyzyn
37921491a5 adb-remount-test: try to fixup device after reboot (recovery)
If device records a boot failure, the device could enter recovery
mode.  If so, try another reboot to see if the device will heal.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I4bee37e11f6344ab1ce176233d7d4e50df132cd7
2019-05-22 14:48:06 -07:00
Mark Salyzyn
30afd8b90b adb-remount-test: try to fixup device after reboot (fastboot)
If bootloader records a boot failure for a slot, the device can
enter fastboot mode.  If so, set the expected slot and reboot.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I801dcec7fd94ff084e54f585370d3c704a0de265
2019-05-22 14:47:58 -07:00
Mark Salyzyn
fb31593542 adb-remount-test: report lsusb for broken connection
Get more details about the usb connection when it times out.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I784bea3a2cefcef423b576854abb795add47d123
2019-05-22 14:47:50 -07:00
Mark Salyzyn
1e5ab4811a adb-remount-test: stderr cleanup
Push stderr redirection to outer blocks if possible.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: Id3b2dfdcf0d778053e10fdb26eb0b1d99b455a46
2019-05-22 14:47:41 -07:00
Tom Cherry
f7545cea34 Vboot1.0: remove code to read verity state in userspace
The code to read verity state in userspace is deprecated in favor of
having the bootloader read and report the state, so this change
removes this now unused code.

Bug: 73456517
Test: boot
Change-Id: Ib626fd61850bce3016179ca92a9831c2ac29c032
2019-04-19 16:53:33 -07:00
Treehugger Robot
66b0c31f60 Merge "Increase adb-remount timeout" 2019-04-08 15:13:47 +00:00
Julien Desprez
c25a9da325 Increase adb-remount timeout
Unblocked the previous error we are now reaching the
default 5min timeout which is too short for this test.
Increase it to 1h.

Test: None
Bug: 117670584
Change-Id: I7fe40e54a7fb978392ee919226c0f05413e7349e
2019-04-03 08:27:29 -07:00
Julien Desprez
74239ea1b1 Replace reboot-fastboot by reboot fastboot
Older host adb client do not recognize reboot-fastboot,
switch it for "adb reboot fastboot" which should be the
same.

Test: None
Bug: 117670584
Change-Id: Iec5230ca66ec18fe7d7c0ebd3f9ab9596a6e7b3c
2019-04-02 17:04:39 -07:00
Julien Desprez
61dea3d154 Add the basic config to run through atest
Add basic config that can run through atest the remount
script.
Very first step before being able to run in infra.

Test: atest adb-remount-sh
Bug: 117670584
Change-Id: I399f79fb7d7cd1b8a832be23efb3b625be693f7e
2019-03-28 10:21:02 -07:00
Mark Salyzyn
b43448941a fs_mgr: overlay: test is alarming on legacy eng builds.
On taimen-eng build, the test reports:

  [  WARNING ] user fastboot missing required to invalidate, ignoring a failure
  ERROR: expected "cat: /vendor/hello: No such file or directory"
         got "Hello World! Fri Mar 22 08:56:32 PDT 2019"
  [  FAILED  ] vendor content after flash vendor

Which is a result of a corner case problem on devices that need to
use overlayfs to support adb remount, but do not have fastbootd as
required by Dynamic Android Partitions (DAP).  These legacy non-DAP
devices we consider this a Known Issue.

The message however is too alarming when reporting this Known Issue
that the test has notified you it accepts.  Use standard notification
output format, and change the result to a series of WARNING instead.

The output would then look like:

  [  WARNING ] user fastboot missing required to invalidate, ignoring a failure
  [  WARNING ] expected "cat: /vendor/hello: No such file or directory"
  [  WARNING ] got "Hello World! Fri Mar 22 08:56:32 PDT 2019"
  [  WARNING ] vendor content after flash vendor

Which still tells us there is an issue, but does not cause a state
of extreme alarm when looking at the test output.

Test: adb-remount-test.sh
Bug: 120448575
Bug: 128876541
Bug: 123079041
Change-Id: I1d8d60f23f7670ade7eae1be629264f7507e0cfd
2019-03-22 09:41:20 -07:00
Mark Salyzyn
a497ab9b55 fs_mgr: remount: manufacture a missing / entry for default fstab
Adjust adb-remount-test.sh to run on cuttlefish.

Test: adb-remount-test.sh
Bug: 128033396
Change-Id: I86825a519fcc821f7da67b0570d7eb2043ae4b42
2019-03-19 16:45:12 -07:00
Mark Salyzyn
60a76f330c fs_mgr: overlay: suppress noise associated with test mounting scratch partition
Add internal fs_mgr_is_ext4 and fs_mgr_is_f2fs to get heads up on
mount failures and thus bypass trying.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Ieb1f8c19ced930b6fe2d1791ef710ce528da7e37
2019-03-18 12:50:00 -07:00
Mark Salyzyn
448fc9783c fs_mgr: test: track device active slot throughout
Report any discrepancy in the active slot.

Fix a problem with problematic error propagation for adb_cat()

Test: adb-remount-test.sh
Bug: 126256072
Change-Id: I8a5d4e364945c5e60d252333886987b8dca0cfb3
2019-03-06 08:25:36 -08:00
Mark Salyzyn
f4e7422c65 fs_mgr: remount: add partition argument list
Can supply a specific partition to remount.  Partitions can be
specified by name or mount point.  Some extra work to differentiate
an unknown partition, invalid partition, or one that is covered by
overlayfs.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: Iab6f51c2b5ebe01f1cea3fb235445d5e2f495365
2019-03-04 11:13:05 -08:00
Bowgo Tsai
d214b40685 fs_mgr: fix fs_mgr avb_keys parsing problem
We should check if the fs_mgr option starts with "avb_keys" before
"avb". Otherwise, it will treat "avb_keys" as "avb" fs_mgr option.

Bug: 112103720
Test: atest fs_mgr_unit_test

Change-Id: I88446222fa88e8ecfcd6f96d30ad4336ebe146a8
2019-02-28 10:37:37 +08:00
Mark Salyzyn
1188ce4e1d fs_mgr: remount: add -R argument
The -R flag tells remount it can reboot to disable verity or to
run fsck on an ext4 deduped filesystem, or both.

Testing may include a manual component because adb-remount-test.sh
needs to run from a device in an enable-verity state to test this.

Only recognizes chained avb.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: I6ce4372532d9b933dcca9e2bec544d525b76c4d9
2019-02-27 13:03:13 -08:00