Commit graph

901 commits

Author SHA1 Message Date
Thiébaud Weksteen
5d72d6ce20 Remove unused execution paths when formatting
fastboot uses the internal functions generate_ext4_image and
generate_f2fs_image when called via the `format` subcommand. An option
for populating the newly created fs with an initial directory exists,
but it is not exposed to the command line interface (initial_dir is
always ""). Remove the unused codepaths for this preloading.

Test: atest --host fastboot_test
Bug: 237960487
Change-Id: I7acfe6352cf26b5cbe0e5553b288c3798e96a893
2022-07-21 14:50:05 +10:00
Kelvin Zhang
1fcdce21d6 Add zhangkelvin@ as owner of fastboot
Working on replacing aio w/ liburing in fastboot recently

Change-Id: I8076e2e53dc8d620faf9bff7f37ba2d2538460d6
2022-07-12 11:05:33 -07:00
Kelvin Zhang
6befe78c3c Convert fastboot/libsnapshot to new BootControl client
Thew new client will use AIDL if available, and fallback to HIDL
otherwise.

Test: th
Bug: 227536004
Change-Id: I9af21037a76a4a6db00144f5b2774ea23f3a5cc2
2022-07-08 10:57:53 -07:00
Kelvin Zhang
5cb1b0295e Add lz4 support for VABC
Add lz4 support in CowWriter/CowReader. Lz4 should offer faster
read/write performance but slightly larger COW sizes.

Download time: Reduced from 1264s to 825s (~35% faster)
Filesystem verification time: from 69s to 59s (~15% faster)
COW Size: 2.59GB to 3.21GB, (~25% regression)
Merge time: 37046ms to 27690ms (~25% faster)
Boot time: LZ4 is 2.7% faster

Overall, LZ4 offers faster read/write performance at the cost of 25%
space regression.

Test: th
Bug: 228478555
Change-Id: Ie521852fb3c9ff8a12e55b764c1eb1838f7b2181
2022-06-29 13:10:55 -07:00
David Anderson
ebc8fe19f8 fastboot: Add a command to get current kernel logs.
This adds "fastboot getvar dmesg", usable only in userspace fastboot,
and only on unlocked devices. This is to debug flashing failures when
serial log access is not available.

Bug: 230269532
Test: fastboot getvar dmesg
Change-Id: Ic57881e362efe3f0687f41ab986d30b3a59dc4e4
2022-06-21 19:32:19 -07:00
Keith Mok
1e490f032e fastboot: vendor boot img util OOB
If vendor image size is less than what the header claims,
there is OOB access.
And it did not check page size equal to zero also.

Bug: 234208198
Test: fastboot_fuzzer
Change-Id: Iec08acf9bb354db4c4cd25e3a0c581974fee7eed
2022-06-07 16:14:43 +00:00
David Anderson
954ff922ea fastbootd: Add better logging for flashing failures.
Bug: 233980876
Test: builds, fastboot flashall
Change-Id: Icc81ac4d9a4ca76f7eb757df5524d95f488fcd8c
2022-06-01 22:46:35 -07:00
Michael Bestas
bcf7680614
fastboot: Print OemCmdHandler return message on success
This allows OEM commands to print messages in fastboot output.

Test: run fastboot oem getprop ro.boot.rf_version
      and observe property value being printed in console

Change-Id: Id9bd5a107861a790cd02dc87057600de5bb94d42
2022-05-16 19:42:28 +03:00
Trevor Radcliffe
b0fa575e1f Merge "set isolated: false on fuzzy_fastboot" 2022-05-06 17:11:17 +00:00
Alix Espino
d3918d8d1e Merge "Moved contents of clang_cflags into cflags" 2022-05-03 17:12:37 +00:00
Trevor Radcliffe
1adca2b8e9 set isolated: false on fuzzy_fastboot
fuzzy_fastboot causes vts to fail when it has isolated set to true
so manually set it to false to avoid this.

Bug: 178498003
Test: Ran tests that failed presubmit
Change-Id: I871854c26e07ac6ad94feb14703b705a3054c176
2022-04-28 19:30:42 +00:00
Lucas Wei
a85c719661 Merge "fastboot: Add vendor_kernel_boot" 2022-04-25 18:31:36 +00:00
Alix
9640339389 Moved contents of clang_cflags into cflags
Test: Treehugger
Bug: 226636335
Change-Id: I30294801423e6d39ab1d8ed3804c15a6ff0e90e5
2022-04-21 03:41:26 +00:00
Lucas Wei
f0fb5dde89 fastboot: Add vendor_kernel_boot
Bug: 214409109
Signed-off-by: Lucas Wei <lucaswei@google.com>
Change-Id: I8b0baa887e5e2309a1cb4a602fe8f6ca9e22526b
2022-04-02 01:04:23 +08:00
Konstantin Vyshetsky
04a4a10ee1 Merge changes from topic "fastbootd-reset-fd"
* changes:
  fastbootd: reset file descriptor on unaligned writes
  fastbootd: add support to reset fd by handle
  fastbootd: pass handle in place of fd
2022-03-28 20:13:25 +00:00
Konstantin Vyshetsky
57b23d25eb fastbootd: reset file descriptor on unaligned writes
Writes on file descriptors opened with O_DIRECT will fail if the buffer
is not page aligned. This CL will reset the file descriptor without the
O_DIRECT flag for such instances.

Bug: 225108941
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I841c84f5d2c0b9435b394c48b1bfcc2d51d771bb
2022-03-28 10:57:03 -07:00
Konstantin Vyshetsky
1cee2ed239 fastbootd: add support to reset fd by handle
There are cases where the flags the file descriptor was opened with need
to be modified. This CL adds functionality to reset the file descriptor
held by a PartitionHandle, reopening with new flags and repositioning
file offset to previous.

Bug: 225108941
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I9adb0e7696bc6af74e14dd61a6cb0ef10b4c98c8
2022-03-28 10:57:03 -07:00
Konstantin Vyshetsky
b3e1829421 fastbootd: pass handle in place of fd
There are cases such as non 4KB aligned buffers which break writes on
file descriptors opened with O_DIRECT. Flashing functions need more
control over the file descriptor, which is not achievable easily by
having only a file descriptor passed. This CL modifies the logic to pass
the PartitionHandle in place of the file descriptor during flashing.

Bug: 225108941
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I049d0ffb183c9de1267b7e442488c8ba5002186a
2022-03-21 11:35:42 -07:00
LuK1337
9dd073ebfa fastboot: Fallback to "raw" partition type if fastboot hal isn't present
Fastboot format fails to wipe any partition that doesn't at least return
"raw" partition type. Also both android.hardware.fastboot@1.0-impl.pixel
and android.hardware.fastboot@1.1-impl-mock return FileSystemType::RAW
so I assume this is fine.

Change-Id: I5707bddb1ba32edb6359858853d7b1afbf138b9f
2022-03-02 14:28:33 +01:00
David Anderson
982c3410c7 fastbootd: Remove all scratch partitions on update-super.
This ensures that the dynamic "scratch" partition is removed when doing
a flashall operation.

If "scratch" is on /data, disable the partition. Add IsImageDisabled to
ImageManager so EnsureScratchMapped can skip mapping it. Also, fix
"scratch" not getting unmapped if on /data.

Bug: 205987817
Test: adb remount
      adb sync
      adb reboot fastboot
      fastboot flashall --skip-reboot # no errors
Test: adb-remount-test.sh
Change-Id: I4b9702e1dac15fb663635506fb50a8274e1e10d1
2022-02-17 04:16:53 +00:00
Bob Badour
c9605e6ae1 Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  fastboot/fuzzer/Android.bp
  fs_mgr/fuzz/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Change-Id: I3bb21e1af846d175a345c2a3a632dc47ecdd62de
2022-02-10 11:12:20 -08:00
Paweł Grabas
ff9cfac08e Allow disabling AVB on special vbmeta partitions
The vbmeta partition might have additional prefix
(e.g., guest_vbmeta_a) on some virtual machine
environment. Allowing rewriting the disable-verity/
disable-verification bits in the vbmeta image upon
flash under such use case.

Bug: https://partnerissuetracker.corp.google.com/u/1/issues/181791553
Test: manual tests with different names of vbmeta partition
Change-Id: Iacadaf587fce1e1e7fef946f56bbfc7f4e8233d8
2022-02-08 22:40:06 +00:00
Keith Mok
d59e883ee5 Merge "fuzzy_fastboot: Add malformed download command test" 2022-01-19 19:31:49 +00:00
Hridya Valsaraju
ddb215da38 Merge "Add a LICENSE file for fastboot" 2022-01-19 19:05:27 +00:00
Keith Mok
7e87807d16 fuzzy_fastboot: Add malformed download command test
Add a malformed download command test.
And add a sparse file test with very large block size

Bug: 215236564
Test: bootloader fastboot
Change-Id: I1072ba189ac15b2e1eb8f13ffd754f93c967e2d5
2022-01-19 00:02:51 +00:00
Hridya Valsaraju
99373794b3 Add a LICENSE file for fastboot
The BSD license used by some of the files in the project was lacking a
license_text file.

Bug: 191508821
Test: m fastboot
Change-Id: I3bdfdea3de69ceaa28528b72a09d02d2a9535e85
2022-01-18 14:03:16 -08:00
Keith Mok
a3b72067de Add checking for sparse file format
Sparse file can come from an untrusted source.
Need more checking to ensure that it is not a malformed
file and would not cause any OOB read access.

Update fuzz test for decoding also.

Test: adb reboot fastboot
      fuzzy_fastboot --gtest_filter=Fuzz.Sparse*
      fuzzy_fastboot --gtest_filter=Conformance.Sparse*
      sparse_fuzzer
Bug: 212705418
Change-Id: I7622df307bb00e59faaba8bb2c67cb474cffed8e
2022-01-14 00:37:48 +00:00
Treehugger Robot
0b5bfdce7d Merge "fastboot: make init_boot.img optional" 2022-01-11 03:54:31 +00:00
Devin Moore
60bd33ffd5 fastboot: make init_boot.img optional
Older devices don't build this image because they don't have a partition
for it.

Bug: N/A
Test: m
Change-Id: I56b58c1bc137ce25e426aa4ec6d2303fa7d77ccc
2022-01-11 02:02:59 +00:00
Treehugger Robot
afd4ccd70b Merge "Remove win_sdk" 2022-01-10 20:18:16 +00:00
Cole Faust
eea1dadba8 Remove win_sdk
win_sdk is deprecated, if given on the command line
sdk will be build instead.

Bug: 212724080
Test: Presubmits
Change-Id: Ia92b879fe08f0a1d9ebefc90e369adf1d4aa4112
2022-01-07 14:55:54 -08:00
Devin Moore
cb5098f547 fastboot: make copy_boot_avb_footer more generic
The funciton is now used for init_boot and boot partitions, so the name
and the error messages should be more generic.

Bug: 203698939
Test: m
Change-Id: I168fdcb08accb11b2c9cfc402168744274f59665
2022-01-07 18:03:33 +00:00
Devin Moore
12e5f038a9 Merge changes Ib5a63a7b,If00f581a
* changes:
  fastboot: copy AVB footer from init_boot.img to end of partition
  fastboot: Support flashing init_boot.img into init_boot partition
2022-01-07 16:24:13 +00:00
Hridya Valsaraju
8fb1aa982b fastboot: Add elsk@ to OWNERS file
Also, remove hridya@ from the OWNERS file

Test: N/A
Bug: N/A
Change-Id: I1d5a03ebf9e2e93f555474a6a654e16879b8e96a
2022-01-06 15:29:17 -08:00
Devin Moore
1af1202fbd fastboot: copy AVB footer from init_boot.img to end of partition
Similar to GKI boot.img, init_boot.img is released as a specific size
and should be able to be flashed into partitions that have different
sizes. So the AVB footer is moved from the end of the init_boot.img to
the end of the partition in the case that the partition is larger than
the image.

Bug: 203698939
Test: m
Change-Id: Ib5a63a7bf1b4be4eba4941972750f12e3edb3a17
2022-01-06 22:33:19 +00:00
Devin Moore
dd1eb8733d fastboot: Support flashing init_boot.img into init_boot partition
init_boot_a and init_boot_b partitions are used in A/B devices.

Bug: 203698939
Test: m

Change-Id: If00f581ab7ae340d78d7d55eebafd92ac15d2bc1
2022-01-06 22:32:28 +00:00
Keith Mok
e3f4b84468 Merge changes I75017420,I3612e131
* changes:
  Fix userspace fastboot with fuzzy test
  Fix fuzzy test on too large command
2022-01-05 23:50:12 +00:00
Keith Mok
ba31ce8655 Merge "Fix typo in fuzzy_fastboot README" 2022-01-05 18:43:16 +00:00
Keith Mok
3724bbcbe9 Fix userspace fastboot with fuzzy test
Add more checking for fastboot to detect malformed
requests.
Such as checking no control characters in the command
send from host.
Make sure the download command length is eight bytes.
And report FAIL if download length is zero.

Test: adb reboot fastboot
      fuzzy_fastboot --gtest_filter=Fuzz.DownloadInvalid1
      fuzzy_fastboot --gtest_filter=Fuzz.DownloadInvalid2
      fuzzy_fastboot --gtest_filter=Fuzz.DownloadInvalid7
      fuzzy_fastboot --gtest_filter=Fuzz.DownloadInvalid8
Bug: 212628476
Change-Id: I750174205377395b5328923fb00462d078f3310d
2022-01-04 19:24:23 +00:00
Keith Mok
921ad28a30 Fix fuzzy test on too large command
Device might return I/O error instead of FAIL message
if command send to device is too large.
Since maximum command size in fastboto protocol is 64 bytes.
The device might only try to read 64 bytes for the bulk transfer,
sending data more than that might result in USB I/O error.

Do proper handler for that in fuzzy_fastboot and reset the USB
if I/O error encounter during the Comman.dTooLarge test

Test: adb reboot fastboot
      fuzzy_fastboot --gtest_filter=Fuzz.CommandTooLarge
      fuzzy_fastboot --gtest_filter=Fuzz.BadCommandTooLarge
Bug: 212628476
Change-Id: I3612e131de02435ee3ed7d18f2b2d20b50ae6c3f
2022-01-04 19:24:05 +00:00
Treehugger Robot
5785297922 Merge "fastboot: Add system_dlkm flashing support" 2022-01-04 00:28:41 +00:00
Keith Mok
66f6e63731 Fix typo in fuzzy_fastboot README
The fuzzy_fastboot does not output error
with invalid command line argument.

Fix typo in README for running with gtest_filter

Bug: 212628476
Test: N/A
Change-Id: I4a67a84807b59db50f063f1b9cf60dc964c1df20
2021-12-30 20:33:05 +00:00
Ramji Jiyani
b3ddb534c3 fastboot: Add system_dlkm flashing support
Bug: 200082547
Test: TreeHugger
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
Change-Id: I35e081bbe8674c102324d22d440dcc38493ec25b
2021-12-29 21:00:25 +00:00
Yifan Hong
4cb88dc811 fastboot: use health AIDL HAL
Bug: 208543110
Test: fastboot getvar
Change-Id: Ib83e7ccd53e49367f7af218ffafb7c0a57a514f6
2021-12-06 23:18:32 -08:00
Konstantin Vyshetsky
d5f3da8dc5 fastbootd: use O_DIRECT for write partition
Direct writes for partition flashing significantly increase performance.
Use O_DIRECT flag when opening partition for flashing. Additionally use
a 4096b aligned buffer which is required for O_DIRECT.
Switch from using 8MB write buffer to 1MB write buffer, as the extra
allocation has no performance impact.

Test: flash locally and reach home screen
Bug: 205151372
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I060f438cf698d0fda1e59e35338bb5dc1cd05b51
2021-11-04 13:24:33 -07:00
Konstantin Vyshetsky
81cc119eff fastbootd: allow passage of flags to open partition
Allow caller to pass additional flags when opening a partition. Obsolete
usage of boolean read, and make previous callers use O_RDONLY instead.
Explicitly OR (O_EXCL | O_CLOEXEC | O_BINARY) to keep existing design
working as is.

Test: flash locally and reach home screen
Bug: 205151372
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I48fbca459a17fcf0b0926ab339585e3bd8e31e35
2021-11-04 12:05:48 -07:00
Colin Cross
8a87bdf80d Use HOST_OUT_EXECUTABLES instead of SOONG_HOST_OUT_EXECUTABLES
Soong is installing binaries directly to HOST_OUT_EXECUTABLES instead
of SOONG_HOST_OUT_EXECUTABLES, dist from the HOST_OUT_EXECUTABLES
location.

Bug: 204136549
Test: m checkbuild
Change-Id: Iee7ae8d1ed478aa2a0344fc9f54ad2c146841cb0
2021-10-25 22:41:07 -07:00
Ayushi Khopkar
ce5c033e2b Added fastboot_fuzzer
Test: ./fastboot_fuzzer
Bug: 189053436

Change-Id: Idf9be2f86238eb2c7090402adc54bbb9c0b43582
2021-10-14 00:32:38 +00:00
David Anderson
b72fa73ace Merge "fastboot: Support casefolding in ext4 partitions." 2021-08-27 01:18:06 +00:00
Colin Cross
fb66f3d13f Merge "Include sys/select.h for fd_set" 2021-08-17 18:56:16 +00:00