Commit Graph

811 Commits

Author SHA1 Message Date
Andrew Gunnerson 39afcf485f Fix clippy lints
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 20:14:52 -04:00
Andrew Gunnerson a3eb8284c8 CHANGELOG.md: Add entry for PR #504
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 20:08:01 -04:00
Andrew Gunnerson e2708d39dd format/payload: Make compression factor required only for CoW v3
It turns out that even though newer versions of delta_generator set this
field for CoW v2 (unused), older versions did not.

Fixes: #493

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 20:03:33 -04:00
Andrew Gunnerson a5f13826e7 CHANGELOG.md: Add entry for PR #503
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 19:21:42 -04:00
Andrew Gunnerson 963456c194 patch/boot: Replace function pointers with opener trait
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 19:19:55 -04:00
Andrew Gunnerson 842a2feb88 CHANGELOG.md: Add entry for PR #502
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 19:02:00 -04:00
Andrew Gunnerson 8bb1f771af format/payload: Remove unnecessary function pointer in extract_images()
The list of output files that are needed are known beforehand. There's
no need to dynamically open them.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 18:47:05 -04:00
Andrew Gunnerson ab51654dad CHANGELOG.md: Add entry for PR #498
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 18:43:26 -04:00
Andrew Gunnerson d75b87d3df Update dependencies
The e2e checksums were updated because the new lzma-rust2 version has
slight differences in compression ratio.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 18:18:39 -04:00
Andrew Gunnerson 73e0404662 CHANGELOG.md: Add entry for PR #501
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 18:18:27 -04:00
Andrew Gunnerson ebb4f18add Use try_for_each where possible (round 2)
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 18:17:46 -04:00
Andrew Gunnerson bee8d80df0 CHANGELOG.md: Add entry for PR #500
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 18:12:08 -04:00
Andrew Gunnerson fdb19e3b97 format/payload: Use dynamic dispatch for large functions
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 17:54:05 -04:00
Andrew Gunnerson cef29fd280 CHANGELOG.md: Add entry for PR #499
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 17:18:00 -04:00
Andrew Gunnerson 58155513af format/payload: Fix out-of-order multithreaded writes
This was a regression from d874921a69.
extract_images()'s open_output parameter was requesting a WriteSeek
instead of a WriteAt, so it received multiple instances of Arc<File>
all with the same underlying File (and file offset).

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-23 17:08:23 -04:00
Andrew Gunnerson 01cdd0b0d3 CHANGELOG.md: Add entry for PR #497
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-22 22:37:07 -04:00
Andrew Gunnerson e39d023855 format/cpio: Fix integer underflow panic in debug builds
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-22 22:35:48 -04:00
Andrew Gunnerson 05c86af298 CHANGELOG.md: Add entry for PR #496
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-22 22:21:45 -04:00
Andrew Gunnerson 759ed7fae5 Use try_for_each where possible
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-22 22:11:32 -04:00
Andrew Gunnerson f6aac1c12f deny.toml: Remove unused git repo URL
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-22 22:07:31 -04:00
Andrew Gunnerson e5b754c786 CHANGELOG.md: Add entry for PR #495
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-22 22:07:31 -04:00
Andrew Gunnerson d874921a69 Replace file reopen concept with ReadAt/WriteAt traits
File reopening was conflating ownership of file-like types with the fact
that they support parallel reads and writes at arbitrary offsets.

The Reopen trait has now been replaced with ReadAt and WriteAt traits,
which are implemented for types that support parallel I/O. If a type
compatible with the standard Read/Write/Seek traits is needed, a new
UserPosFile type can act as the bridge by storing its own userspace file
offset. For the opposite bridge, there's MutexFile, which implements
ReadAt/WriteAt by using locks to make the operations sequential. This is
only really used in the tests though.

This eliminates the need for the PSeekFile and SharedCursor types. The
standard File and Cursor types can be used instead, and if shared
ownership is needed, Arc can be used.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-22 22:07:11 -04:00
Andrew Gunnerson 390dce5f0c CHANGELOG.md: Add entry for PR #492
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-21 18:57:08 -04:00
Andrew Gunnerson 6d939bda25 Use seek_relative where possible
This will not make a meaningful performance difference for our use case,
but does not make things any more complex either.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-21 18:55:21 -04:00
Andrew Gunnerson a40d6ea379 CHANGELOG.md: Add entry for PR #489
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-21 00:50:00 -04:00
Andrew Gunnerson 7d0bb378a6 Switch to rawzip crate for zip file handling
rawzip is a lower-level zip file library that is much more suited for
avbroot's use case. Its speed improvements aren't too important since
OTAs only have a handful of files, but it is a simpler layer of
abstraction and exposes more about zip file internals. We also no longer
need to maintain a perpetual fork of the zip library.

The only caveat is that rawzip (much like avbroot) is built around
writing zip files in a streaming fashion. To support `--zip-mode
seekable`, the output file is post-processed to copy the relevant data
descriptor fields to the local header. The unused data descriptors
remain in the file to avoid needing to shift file data, but this does
not violate the spec and Android's libziparchive accepts it just fine.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-20 21:12:27 -04:00
Andrew Gunnerson 3ed38b8d29 ci.yml: Set RUSTDOCFLAGS to statically link doctests
Prior to Rust 1.89, these tests were just skipped when cross-compiling.
Now, they are actually compiled and ran. Unfortunately, doctests don't
use the normal RUSTFLAGS environment variable, so we also need to set
RUSTDOCFLAGS or else the resulting dynamically linked executable will
fail to run on a non-Android host.

Upstream change: https://github.com/rust-lang/cargo/pull/15462

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-19 20:13:56 -04:00
Ivan 0717981d62 README.ru.md: Update translation
* https://github.com/chenxiaolong/avbroot/commit/f393d7adc42e43b2857a60c3b5fd404b14f042c4
* https://github.com/chenxiaolong/avbroot/commit/2f964bf113512bd7ff33eb3e47116305a262e9fc
* https://github.com/chenxiaolong/avbroot/commit/a2fe6fc9d882d4fd955d03b3a2046c5a41d5840c
* https://github.com/chenxiaolong/avbroot/commit/2683781737230b98172de335a6597363c6d71ff2

Signed-off-by: Ivan <reddxae@proton.me>
2025-08-14 12:20:38 +03:00
Ivan 556f86e4df README.md: Use "device" as a generic reference, clarifying & style improvements
* Use "device" as a generic reference instead of "phone" throughout the project description as more than just phones can support custom AVB functionality.
* Finalize the clarification on signing key generation in the initial setup section introduced by commit https://github.com/chenxiaolong/avbroot/commit/2f964bf113512bd7ff33eb3e47116305a262e9fc.
* The "warning" in the merging snapshots section is marked in bold and uppercase, aligning with the rest of the text, while less important "notes" don't stand out in the same way.

Signed-off-by: Ivan <reddxae@proton.me>
2025-08-14 12:19:38 +03:00
Andrew Gunnerson c019ccad1c Version 3.20.0
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v3.20.0
2025-08-10 22:35:40 -04:00
Andrew Gunnerson 192e737dd3 CHANGELOG.md: Add entry for PR #487
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 22:24:42 -04:00
Andrew Gunnerson 339267149f Update dependencies and fix clippy lints
if-let chains!

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 22:21:24 -04:00
Andrew Gunnerson 21c2536759 CHANGELOG.md: Add entry for PR #486
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 22:10:31 -04:00
Andrew Gunnerson 185f02c209 cli/avb: verify-device: Use bootloader's reported key digest by default
This removes the need for the user to explicitly specify a public key to
verify against.

Issue: #482

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 22:03:09 -04:00
Andrew Gunnerson a8908d6d06 CHANGELOG.md: Add entry for PR #485
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 21:57:42 -04:00
Andrew Gunnerson 2683781737 cli/avb: Add new subcommand to verify device partitions
This adds a new `avbroot avb verify-device` subcommand, which is just
like the normal `verify` subcommand, except it reads the actual
partitions on the device. This is only available with the Android build
of avbroot since it needs to run on the actual device.

Fixes: #482

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 21:24:28 -04:00
Andrew Gunnerson 44b90936bf CHANGELOG.md: Add entry for PR #484
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 19:59:41 -04:00
Andrew Gunnerson d7369e73e9 Remove cap-std and cap-tempfile dependencies
There is not much benefit for our use case to have kernel-level
openat-style sandboxing of paths. We already check all untrusted paths
for safety and the sandboxing prevented the use of symlinks that point
outside of the parent directory of specified paths.

This commit also moves the path safety checks to the util module to
avoid having multiple implementations spread out everywhere.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 19:50:43 -04:00
Andrew Gunnerson bb5c97ea1b CHANGELOG.md: Add entry for PR #483
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 16:35:40 -04:00
Andrew Gunnerson ac95660e23 Switch to rust-lzma2 for XZ compression/decompression
The performance, both in CPU time and compression ratios, is very
comparable to liblzma. This lets us drop the last remaining
compression-related dependency written in C.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-10 16:20:41 -04:00
Andrew Gunnerson 2bac85f080 Version 3.19.0
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v3.19.0
2025-08-07 23:23:18 -04:00
Andrew Gunnerson fa99a3bb98 CHANGELOG.md: Add entry for PR #479
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-07 23:20:12 -04:00
Andrew Gunnerson 0d5bc574b2 cli/ota: Re-sign signed image when header verification fails
Previously, unless forced, `avbroot avb pack` would only re-sign an
image if the packing process changed the header (eg. root digest).
However, this isn't sufficient when packing an image after the user
modifies avb.toml manually. This is especially the case when packing a
vbmeta image, which never triggered the old check because it does not
contain a raw image.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-07 23:14:06 -04:00
Andrew Gunnerson e34c48c92b CHANGELOG.md: Add entry for PR #478
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-07 23:13:47 -04:00
Andrew Gunnerson 8ea08ef98c cli/avb: Warn when verifying image with insecure flags
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-07 23:10:24 -04:00
Andrew Gunnerson 779b1116e1 CHANGELOG.md: Add entry for PR #477
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-07 23:09:24 -04:00
Andrew Gunnerson 821c5fe088 format/avb: Fix verifying unsigned AVB images
Previously, Header::verify() tried to always decode the public_key
field, even if the header was unsigned. This prevented verifying
unsigned images with `avbroot avb verify`. Verifying unsigned images
referenced by signed images was unaffected.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-07 23:04:01 -04:00
Andrew Gunnerson 6a1da333eb Version 3.18.1
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v3.18.1
2025-08-07 01:53:44 -04:00
Andrew Gunnerson 256483d248 CHANGELOG.md: Add entry for PR #476
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-07 01:53:25 -04:00
Andrew Gunnerson 2314c371a8 sparse: Fix u32 overflow when unpacking files with large holes
CHUNK_TYPE_RAW is the only chunk type that's guaranteed to not overflow
a u32 when its number of blocks is multiplied by the block size.
CHUNK_TYPE_FILL and CHUNK_TYPE_DONT_CARE require a u64.

Issue: #472

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2025-08-07 01:36:22 -04:00