Commit graph

1332 commits

Author SHA1 Message Date
liyong
089941c800 Fix unsigned type sub overflow issue when isntall DSU
writer->size() is block size aligned and could be bigger than remaining_bytes
If remaining_bytes is bigger, set remaining_bytes to 0 to avoid sub overflow error.

Bug: 136727859
Test: Successfully install a DSU
Change-Id: If493b0f206561239caec2ee234f7cfd70bf927a7
2019-07-04 11:29:19 +00:00
Paul Lawrence
323959ea27 Make ext4 userdata checkpoints work with metadata encryption
When both ext4 user data checkpoints and metadata encryption are
enabled, we are creating two stacked dm devices. This had not been
properly thought through or debugged.

Test: Enable metadata encryption on taimen (add
keydirectory=/metadata/vold/metadata_encryption to flags for userdata in
fstab.hardware)
    Unfortunately metadata is not wiped by fastboot -w, so it is
    necessary to rm metadata/vold -rf whenever you wipe data.
    fastboot flashall -w works
    fastboot reboot -w works
    A normal boot works
    Disable checkpoint commits with
    setprop persist.vold.dont_commit_checkpoint 1
    vdc checkpoint startCheckpoint 10
    adb reboot
    wait for device to fully boot then
    adb reboot
    Wait for device to fully boot then
    adb logcat -d | grep Checkpoint shows the rollback in the logs

    This tests encryption on top of checkpoints with commit, encryption
    without checkpoints, and rollback, which seems to be the key cases.

Bug: 135905679
Change-Id: I24387a2943dce28b918c34894f24911b20429be7
2019-06-26 15:09:07 -07:00
David Anderson
87db478ad6 Merge "libfiemap_writer: Improve device unwrapping to support simple linear devices." 2019-06-20 23:59:06 +00:00
David Anderson
1bfcd580c8 libfiemap_writer: Improve device unwrapping to support simple linear devices.
Normally we reject complex dm targets that would invalidate or shift the
block mappings returned via FIEMAP/FIBMAP. Currently the only targets
allowed are crypt, default-key, and bow. This patch adds support for
"linear" as long as there is only one linear target and it targets
sector 0 of the underlying block device.

This is useful for testing gsid, so we can simulate how a
metadata-encrypted device works without having to create a dm-crypt or
dm-default-key node.

Bug: 134536978
Test: manual test
Change-Id: I7c12bc20d95ff4c90402e66bafb4cf2fce7818e2
2019-06-20 13:39:11 -07:00
David Anderson
99f610da3d Merge "liblp: Handle invalid alignment offsets correctly." 2019-06-20 19:09:52 +00:00
David Anderson
0b5c3552cc Merge "Remove fs_mgr_wait_for_file." 2019-06-20 19:09:26 +00:00
David Anderson
ea0dda1473 libdm: Add LoopControl helpers for enabling direct IO.
Bug: 134536978
Test: manual test
Change-Id: Iae25434ac54186fd6006b56eeb7a7f577a880053
2019-06-19 19:29:15 -07:00
David Anderson
d106f1e225 libdm: Add helpers for getting the device number of a dm device.
device-mapper will accept a "major:minor" string in place of a path for
any target parameter that specifies another block devie. This is useful
to have a helper for, since it lets us avoid a call to WaitForFile().

Bug: 134536978
Test: manual test
Change-Id: I13fd6699dd5d405bfa676830825b006b7810aa0f
2019-06-19 19:29:09 -07:00
David Anderson
2ca0700b45 liblp: Handle invalid alignment offsets correctly.
When stacking devices with dm-linear, it is possible to get a -1
alignment offset. In this case we should set alignment_offset to 0
rather than fail later trying to divide -1 by the sector size.

Bug: 134536978
Test: manual test
Change-Id: I3862fdda69531a3b230b7316707469a49ba871d6
2019-06-19 19:23:55 -07:00
David Anderson
02427f5f71 Merge "Introduce inotify-based replacements for fs_mgr_wait_for_file." 2019-06-19 19:39:34 +00:00
David Anderson
5c475c70d0 Remove fs_mgr_wait_for_file.
This transitions all callers to WaitForFile/WaitForFileDeleted.

Bug: 134966533
Test: device boots
Change-Id: Ic2107c97271adbd82094eda4ea6df3ccd652fd51
2019-06-18 15:27:18 -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
David Anderson
bc53c842e9 Merge "liblp: Remove the slot-suffix requirement in MetadataBuilder." 2019-06-17 22:58:20 +00:00
Treehugger Robot
6860f68475 Merge "VtsKernelLiblpTest: use static test" 2019-06-14 23:00:48 +00:00
Steve Muckle
83019575ac VtsKernelLiblpTest: use static test
To avoid introducing dependencies on target libraries, use a statically
compiled test instead.

Bug: 134912860
Test: run vts-kernel -m VtsKernelLiblpTest
Change-Id: Ie24cc8532c7821cb225c024c240c4d485557bfa7
2019-06-14 11:37:09 -07:00
Jaegeuk Kim
f07d07bf47 fs_mgr_fstab: translate reserve_root to reserved_size in fsmgr
Without this patch, fstab should decribe reserve_root=[# of 4KB blocks] in
f2fs mount option as well as reserved_size=[KB] in fsmgr flag to notify it
to framework.
With this patch, it should be just fine to use reserve_root=[# of 4KB blocks]
in fstab.

Bug: 135003600
Test: checked vold.has_reserved
Change-Id: Iab75f7da9792ad205a6c4d2d0f1eba8c16a5266a
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-06-14 17:38:33 +00:00
David Anderson
935420f968 liblp: Remove the slot-suffix requirement in MetadataBuilder.
Normally MetadataBuilder will refuse to create non-suffixed partitions
on A/B devices. There are some scenarios where this doesn't make sense,
like when gsid needs to build metadata files for
system_gsi/userdata_gsi. It also doesn't make sense for the "scratch"
partition, so we added exceptions.

It turns out that metadata created by gsid cannot be re-imported by
MetadataBuilder, because there's no opportunity to set the "ignore" flag
in MetadataBuilder's constructor. Rather than plumbing a flag through, I
think we should just remove this error. It has too many exceptions
already and it doesn't really protect against anything. The motivation was
to avoid confusion in fastbootd on retrofit devices (where there are two
super partitions), but it's a pretty minor concern.

Bug: 134536978
Test: liblp_test gtest
Change-Id: I4629a3c46070c35bcce1017096338e72aa234371
2019-06-13 16:43:26 -07:00
David Anderson
d5fa799f76 libfiemap_writer: Handle dm stacking more accurately.
Right now we completely unwind a device-mapper stacking, but this will
produce incorrect results if the stack doesn't have a 1:1 block mapping.
For example, extents against a dynamic partition will be invalid if used
against the underlying block device (super). In this case, abort the
device-mapper unwinding early, and leave it to the caller to decide if
the device is valid.

In addition to fixing a potentially serious bug, this will allow us to
test gsid by simulating various device types (FBE vs FDE, for example).

Bug: 134536978
Test: fiemap_writer_test gtest
Change-Id: I8164e2b71c4868f5494e17e08d209b65fa0ed4ef
2019-06-11 14:04:46 -07:00
David Anderson
e53417a8ee Merge "liblp: Add helpers for finding partitions and partition sizes." 2019-06-11 20:27:53 +00:00
Sahitya Tummala
5928e4f8d3 fs_mgr: run fsck.f2fs with -f option when full mount fails
There are cases where fsck.f2fs -f helps to recover from
corruption and thus helps to mount f2fs successfully.

CRs-Fixed: 2458080
Change-Id: I8d91835e464ef86e6ad4f96b7ac83f9f3d57c14f
2019-06-11 01:36:21 +00:00
Treehugger Robot
2184ecb8ad Merge "fs_mgr: support -o sync" 2019-06-10 21:40:23 +00:00
Jaegeuk Kim
5ffa970489 fs_mgr: support -o sync
Bug: 134172577
Change-Id: I1ad8811b07657727d8227d3668f58b0fbc7e7609
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-06-10 10:57:52 -07:00
David Anderson
196d2ba7b9 liblp: Add helpers for finding partitions and partition sizes.
These tend to get manually, so let's promote to actual helpers.

Bug: 134536978
Test: liblp_test gtest
Change-Id: Ifb79c8d6f247cc3f9635bf6adfd1c99907340002
2019-06-07 11:09:28 -07:00
David Anderson
1e05e55820 liblp: Replace some |const char*| inputs with std::string.
Bug: 134536978
Test: builds
Change-Id: I23dba6747be334f42506f969d6d52b293c69f0bd
2019-06-07 11:09:26 -07:00
Bo Hu
f17902b392 Merge "fs_mgr: Don't report 'Skip mounting partitions'" 2019-06-07 13:07:54 +00:00
bohu
42b28b09b0 fs_mgr: Don't report 'Skip mounting partitions'
when the skip mount partition is not in the fstab

BUG: 133854834
Change-Id: I51de91f34525560c008fbe8648fa2cd6f56dcf8e
2019-06-05 18:24:50 +00: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
e0c581fec3 fs_mgr: overlayfs: pre-emptive filesystem setup
If we just disabled verity, take the step to setup the backing
storage for overlayfs.

Test: adb-remount-test.sh
Bug: 130131892
Change-Id: Ic56569eaf363e4417a0ce5df11ee5480a07b8b03
2019-05-31 11:23:01 -07:00
Mark Salyzyn
370aac75ea Merge changes I55d0e1a8,I4d9a8776
* changes:
  adb-remount-test: do not brick devices that support overlayfs but do not use it
  adb-remount-test: provide additional mount details
2019-05-30 00:19:55 +00:00
Mark Salyzyn
d9b60303a0 fs_mgr: remount reboot if overlayfs got setup
Cosmetic fix.

If overlayfs gets setup by the remount command, ask user to reboot
since the device is not 100% in a state to run, and is merely only
in a state to take push and sync operations.

overlayfs is only truly ready for developing and running if the
overly mounts had occurred in first stage init, this happens when
the device is rebooted.

We did not completely remove overlapping dead ext4 dedupe code in a
previous change, complete the process.

Simplification for adb remount, the message:

    Now reboot your device for settings to take effect

will only occur on the pass that causes the overlays to be populated,
in the same boot session. If subsequent, and ineffectual in any case,
remount command occurs again, it will not request a reboot.

Test: adb-remount-test.sh
Bug: 130131892
Change-Id: I7c4f408546687c49249883e2641b9bc63f68afd0
2019-05-29 16:44:52 -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
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
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
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
Tao Bao
3c94eaad5f Merge "fs_mgr: Fix EnsurePathMounted with a given mount_point." 2019-05-15 16:10:18 +00:00
Mark Salyzyn
fe04d7ce7e Merge "fs_mgr: overlayfs readme caveats" 2019-05-14 20:28:17 +00:00
David Anderson
57467074a2 Merge "libdm: Add dm-crypt and dm-default-key support to libdm." 2019-05-14 20:00:39 +00:00
Mark Salyzyn
8338b01bae fs_mgr: overlayfs readme caveats
Itemized list of additional overlayfs caveats

Test: none
Bug: 109821005
Change-Id: I3550ddf6544749cdc68c803f0577002346890518
2019-05-14 10:29:25 -07:00
Mark Salyzyn
98a0128e44 fs_mgr: overlayfs: ReadFstabFromFile touches errno
Regression from commit 77c28476f1
("Remove the mount points defined in skip_mount.cfg from
ReadDefaultFstab()") resulted in ReadFstabFromFile to report
errno ENOENT even upon success, preventing clear error propagation
for real failures (ReadFstabFromFile would _always_ report ENOENT).

The bad error propagation resulted in an adb remount failure.

Added immunization against future adjustments that may also
result in a similar regression in adb remount behaviors.

Test: adb-remount-test.sh
Bug: 132594161
Bug: 128961335
Change-Id: Icf5d48bbfc6d938d4b9657ca8004a6a6ddaab5a6
2019-05-13 10:02:51 -07:00