318 Commits

Author SHA1 Message Date
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
Andrew Gunnerson 07f2e30430 bootimage: Ensure page_size is never 0
Otherwise, we'll panic due to dividing by 0.

(Found by honggfuzz)

Issue: #160

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 19:28:52 -04:00
Andrew Gunnerson 9f34198f07 CHANGELOG.md: Add entry for PR #161
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 19:28:23 -04:00
Andrew Gunnerson 9d8e82651e Merge pull request #161 from chenxiaolong/honggfuzz
Add initial honggfuzz fuzzing infrastructure
2023-09-27 19:27:00 -04:00
Andrew Gunnerson 5b22d7b603 Add initial honggfuzz fuzzing infrastructure
This initially includes fuzzers for the AVB and boot image parsers. The
initial input corpus are the same test files we use for the round trip
tests.

Issue: #160

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-27 19:15:42 -04:00
Andrew Gunnerson 11d19de0a1 CHANGELOG.md: Add entry for PR #158, #159
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-26 23:21:44 -04:00
Andrew Gunnerson fc4c2e63da Merge pull request #159 from chenxiaolong/limits
bootimage: Enforce size limits to prevent DoS
2023-09-26 23:17:40 -04:00
Andrew Gunnerson ee28a57a74 bootimage: Enforce size limits to prevent DoS
The kernel, ramdisk(s), second stage bootloader, and device tree
components are limited to 64 MiB. In practice, no device has boot
partitions larger than 64 MiB, so this limit should never be hit. The
vendor v4 bootconfig component is limited to 1 KiB, which is about ~25x
the size of the Pixel 7 Pro's bootconfig.

Issue: #157

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-26 23:02:24 -04:00
Andrew Gunnerson 101512b894 Merge pull request #158 from chenxiaolong/limits
avb: Enforce size limits to prevent DoS
2023-09-26 20:52:18 -04:00
Andrew Gunnerson 50913db375 avb: Enforce size limits to prevent DoS
AVB 2.0 mandates that the header is 64 KiB or less, so enforce this both
when parsing and when writing vbmeta headers. Hash trees and FEC data
are also read into memory, so enforce limits corresponding to a 4 GiB
partition image.

Since these limits are so small, this lets us remove nearly all checked
integer conversions since a direct cast will never result in truncation.

Issue: #157

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-26 20:38:19 -04:00
Andrew Gunnerson 699ea92dbf CHANGELOG.md: Add entry for PR #156
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-21 01:47:08 -04:00
Andrew Gunnerson 667b99254c Merge pull request #156 from chenxiaolong/passphrase
Consolidate logic for determining passphrase source priority
2023-09-21 01:45:46 -04:00
Andrew Gunnerson e41814a425 Consolidate logic for determining passphrase source priority
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-20 23:35:25 -04:00
Andrew Gunnerson dff2fff028 Version 2.1.0
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v2.1.0
2023-09-19 23:56:58 -04:00
Andrew Gunnerson 67bca2e58c CHANGELOG.md: Add entry for PR #153
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-19 23:54:51 -04:00
Andrew Gunnerson 1f08cb6d40 Merge pull request #154 from chenxiaolong/changelog
Shorten changelog links
2023-09-19 23:53:28 -04:00
Andrew Gunnerson ed68f09cb9 Shorten changelog links
The longer PR links have weird line wrapping behavior on the Github web
UI, making it more difficult to read.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-19 23:09:23 -04:00
Andrew Gunnerson 64c11c2dc3 Merge pull request #153 from chenxiaolong/error
Disambiguate some error fields and add more error context
2023-09-19 23:08:15 -04:00
Andrew Gunnerson 5115134b5a Disambiguate some error fields and add more error context
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-19 22:54:43 -04:00
Andrew Gunnerson a2d81d6bfe CHANGELOG.md: Add entry for PR #152
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-09-19 22:53:14 -04:00