Commit Graph

337 Commits

Author SHA1 Message Date
Andrew Gunnerson d69fdaadae ci.yml: Only cancel previous runs for pull requests
Fixes: #177

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-10-01 19:09:58 -04:00
Andrew Gunnerson f0a631951a CHANGELOG.md: Add entry for PR #178
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-10-01 16:39:13 -04:00
Andrew Gunnerson 83265e584a Merge pull request #178 from chenxiaolong/cpio
cpio: Only reassign inodes when missing
2023-10-01 16:38:13 -04:00
Andrew Gunnerson ddb8911efd cpio: Only reassign inodes when missing
This way, archives with hard links can pass through `cpio unpack` and
`cpio pack`, even though there's no explicit support for hard links.

This also changes the trailer entry logic to not set an inode number.
AOSP's mkbootfs and magiskboot both start at 300000 and increment by one
for each entry, including the trailer. However, GNU cpio, bsdcpio,
busybox, and toybox all set it to 0, which makes more sense given that
it doesn't represent anything on disk.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-10-01 16:16:04 -04:00
Andrew Gunnerson 72be84b2fc CHANGELOG.md: Add entry for PR #176
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-30 23:19:53 -04:00
Andrew Gunnerson 81d77d8610 Merge pull request #176 from chenxiaolong/prost
Switch to prost for protobuf encoding/decoding
2023-09-30 23:18:55 -04:00
Andrew Gunnerson 4651b755ba Switch to prost for protobuf encoding/decoding
There are several things we had to work around with quick-protobuf, like
forcing no_std mode to use BTreeMaps and avoiding helper functions to
read and write non-size-delimited messages. In addition, the pb-rs code
generator doesn't support adding #[derive]s to enums and the existing
support for adding derives to structs is broken due to incorrect string
concatenation.

Prost doesn't have these limitations and bugs. I originally avoided it
because prost_build required the external `protoc` binary, but now that
the protox library exists, the code generation can be done entirely in
Rust without external tools.

Prost also fully supports adding custom attributes to structs, enums,
and fields. This will be helpful for future payload unpack and pack
commands where the payload manifest would have to be serialized to TOML.

The e2e checksums had to be updated because prost's serialized bytes on
the wire differ from quick-protobuf, despite having the same semantic
meaning. Since all checksums need to be updated anyway, the Magisk apk
and OTA images have all been updated to the latest versions.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-30 22:27:46 -04:00
Andrew Gunnerson 979699e3dc CHANGELOG.md: Add entry for PR #175
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-30 20:03:06 -04:00
Andrew Gunnerson beee2c7c90 Merge pull request #175 from chenxiaolong/boot
boot: Rename header.toml to boot.toml for consistency
2023-09-30 20:00:11 -04:00
Andrew Gunnerson 206916e544 boot: Rename header.toml to boot.toml for consistency
This also changes the serialization to use a `type` field instead of
spewing the enum variant name everywhere.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-30 19:43:04 -04:00
Andrew Gunnerson aaed44ad73 CHANGELOG.md: Add entry for PR #174
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-30 19:42:47 -04:00
Andrew Gunnerson 37b33f803a Merge pull request #174 from chenxiaolong/deps
Update dependencies
2023-09-30 19:41:30 -04:00
Andrew Gunnerson e72b55dc57 Update dependencies
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-30 19:23:30 -04:00
Andrew Gunnerson 5b01feb344 CHANGELOG.md: Add entry for PR #173
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-30 17:51:18 -04:00
Andrew Gunnerson 2f7556b530 Merge pull request #173 from chenxiaolong/cpio
Add CLI for packing and unpacking cpio archive
2023-09-30 17:49:54 -04:00
Andrew Gunnerson f25196f0a2 Add CLI for packing and unpacking cpio archive
The new commands behave exactly like the existing `avb` and `boot`
subcommands. This completes the last piece of the puzzle for exposing
useful interfaces to avbroot's internal parsers.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-30 00:50:30 -04:00
Andrew Gunnerson 2735a6558e CHANGELOG.md: Add entry for PR #172
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-29 19:10:39 -04:00
Andrew Gunnerson 0c03fceb96 Merge pull request #172 from chenxiaolong/cpio
Add streaming CPIO reader and writer
2023-09-29 19:09:20 -04:00
Andrew Gunnerson 164274eb97 Add streaming CPIO reader and writer
The Magisk boot image patcher still reads all the entries into memory
for simplicity, but everything else now uses the streaming reader.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-29 18:47:37 -04:00
Andrew Gunnerson 61129e8ec7 Version 2.1.1
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v2.1.1
2023-09-28 21:53:15 -04:00
Andrew Gunnerson e1f4fa1ee8 CHANGELOG.md: Add entry for PR #171
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 21:51:15 -04:00
Andrew Gunnerson d15a29e9a7 Merge pull request #171 from chenxiaolong/openat
Use handle-based directory operations instead of path-based
2023-09-28 21:37:44 -04:00
Andrew Gunnerson 26a3bafc3d Use handle-based directory operations instead of path-based
This prevents avbroot writing to locations where it shouldn't due to
manipulation from external processes. For example, replacing the output
directory for `avbroot ota extract` with a symlink.

Regardless of what symlinks or other changes an external process does to
the directory, the cap-std library will use the appropriate `openat2()`
options (or equivalent) to prevent writes outside of the directory.

Fixes: #166

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 21:26:35 -04:00
Andrew Gunnerson 999e31cdf3 CHANGELOG.md: Add entry for PR #170
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 19:53:01 -04:00
Andrew Gunnerson ae2ebbf2aa Merge pull request #170 from chenxiaolong/payload
payload: Add size limit for protobuf manifest
2023-09-28 19:52:21 -04:00
Andrew Gunnerson fea860a382 payload: Add size limit for protobuf manifest
This is the only part of the payload that we have to read entirely into
memory. The limit is currently set to 1 MiB, which is around ~5-6x the
manifest size in all the e2e test suite's images.

Issue: #169

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 19:38:38 -04:00
Andrew Gunnerson 98339aee13 CHANGELOG.md: Add entry for PR #169
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 19:38:19 -04:00
Andrew Gunnerson f8772ef327 Merge pull request #169 from chenxiaolong/ota
ota: Don't preallocate buffer when reading OTA metadata
2023-09-28 19:33:47 -04:00
Andrew Gunnerson 7d62ddc64e ota: Don't preallocate buffer when reading OTA metadata
This way we can't run out of memory if the zip entry lists an invalid
file size that's much bigger than the actual file.

Issue: #157

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 19:22:17 -04:00
Andrew Gunnerson d93378cc24 CHANGELOG.md: Add entry for PR #168
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 19:19:14 -04:00
Andrew Gunnerson 4885e978ee Merge pull request #168 from chenxiaolong/fec
fec: Ensure FEC data size and grid size won't overflow
2023-09-28 19:18:33 -04:00
Andrew Gunnerson ecb2caf47d fec: Ensure FEC data size and grid size won't overflow
This also limits the block size to 16384. There are currently no known
images that use anything larger than 4096.

Issue: #157

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 19:07:04 -04:00
Andrew Gunnerson 525e2a409e CHANGELOG.md: Add entry for PR #167
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 18:55:07 -04:00
Andrew Gunnerson 7e89e9081a Merge pull request #167 from chenxiaolong/fuzz
Add fuzzer for FEC image parser
2023-09-28 18:54:25 -04:00
Andrew Gunnerson 2a57343094 Add fuzzer for FEC image parser
Issue: #160

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-28 18:41:47 -04:00
Andrew Gunnerson cd779e62cb CHANGELOG.md: Add entry for PR #165
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 23:50:08 -04:00
Andrew Gunnerson 96fb8ddc9c Merge pull request #165 from chenxiaolong/cpio
Add fuzzer for cpio
2023-09-27 23:49:23 -04:00
Andrew Gunnerson 0aba185c85 Add fuzzer for cpio
Issue: #160

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 23:21:04 -04:00
Andrew Gunnerson 36dcbe092f CHANGELOG.md: Add entry for PR #164
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 22:22:34 -04:00
Andrew Gunnerson aab9f5216f Merge pull request #164 from chenxiaolong/cpio
cpio: Read data by incremental reallocation after a threshold
2023-09-27 22:21:55 -04:00
Andrew Gunnerson 2a2515c5ef cpio: Read data by incremental reallocation after a threshold
This prevents avbroot from being killed for excessive memory usage due
to the entry header specifying a very large file name or file size
(larger than what's actually contained in the file).

This threshold for switching to incremental reallocation is 1 KiB for
file names and 1 MiB for file data.

Issue: #157

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 21:21:29 -04:00
Andrew Gunnerson 111ec6ff1e CHANGELOG.md: Add entry for PR #133
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 20:55:48 -04:00
Andrew Gunnerson cfd1dfb2eb Merge pull request #133 from chenxiaolong/deny
cargo-deny: Block executables in dependencies
2023-09-27 20:54:45 -04:00
Andrew Gunnerson d7977bab93 cargo-deny: Block executables in dependencies
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 20:44:22 -04:00
Andrew Gunnerson c29d78181a CHANGELOG.md: Add entry for PR #163
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 20:36:59 -04:00
Andrew Gunnerson 42a9a9a12b Merge pull request #163 from chenxiaolong/fuzz
avb: Use checked addition when computing auth/aux block size
2023-09-27 20:35:54 -04:00
Andrew Gunnerson e293331952 avb: Use checked addition when computing auth/aux block size
(Found by honggfuzz)

Issue: #160

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 19:43:15 -04:00
Andrew Gunnerson bf97444f4b CHANGELOG.md: Add entry for PR #162
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 19:42:48 -04:00
Andrew Gunnerson 1fa068b465 Merge pull request #162 from chenxiaolong/fuzz
bootimage: Fix potential divide-by-0 and multiplication overflow
2023-09-27 19:41:53 -04:00
Andrew Gunnerson f85b6eec46 bootimage: Fix panic when validating vendor v4 table size
The multiplication can overflow.

(Found by honggfuzz)

Issue: #160

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 19:28:53 -04:00