Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify/extract --all Failed to extract images from payload #138

Closed
AgentOak opened this issue Sep 7, 2023 · 3 comments · Fixed by #139
Closed

verify/extract --all Failed to extract images from payload #138

AgentOak opened this issue Sep 7, 2023 · 3 comments · Fixed by #139
Assignees

Comments

@AgentOak
Copy link
Contributor

AgentOak commented Sep 7, 2023

avbroot 2.0.2 (Note: it might be good to have a version command, or display version in output)
Device: Google Pixel 4a (sunfish)
ROM: CalyxOS sunfish-ota_update-23412000.zip

 $ ./avbroot ota patch --input sunfish-ota_update-23412000.zip --privkey-avb ~/avbroot/avb.key --privkey
-ota ~/avbroot/ota.key --cert-ota ~/avbroot/ota.crt --magisk Magisk.v26.3.apk --magisk-preinit-device metadata
[*] Replacing zip entry: META-INF/com/android/otacert
[*] Copying zip entry: apex_info.pb
[*] Copying zip entry: care_map.pb
[*] Patching zip entry: payload.bin
[*] Extracting from original payload: vbmeta
[*] Extracting from original payload: boot
[*] Extracting from original payload: vbmeta_system
[*] Patching boot images: boot
[*] Patching vbmeta images: vbmeta
[*] vbmeta signature algorithm type changed to Sha256Rsa4096
[*] Compressing replacement images: boot, vbmeta
[*] Generating new OTA payload
[*] Patching zip entry: payload_properties.txt
[*] Generating new OTA metadata
[*] Verifying metadata offsets
[*] Completed after 18.2s
$ ./avbroot ota verify --input sunfish-ota_update-23412000.zip.patched --cert-ota ~/avbroot/ota.crt --p
ublic-key-avb ~/avbroot/avb_pkmd.bin
[*] Verifying whole-file signature
[*] Verifying payload
[*] Extracting partition images to temporary directory
[*] Extracting from the payload: abl, aop, boot, devcfg, dtbo, hyp, keymaster, modem, product, qupfw, system, system_ext, tz, uefisecapp, vbmeta, vbmeta_system, vendor, xbl, xbl_config
Error: Failed to extract images from payload

Caused by:
    0: I/O error
    1: invalid options

ota extract works (creates boot.img, vbmeta.img and vbmeta_system.img), but the same thing happens when running ota extract --all:

$ ./avbroot ota extract --all --input sunfish-ota_update-23412000.zip.patched --directory extract
[*] Extracting from the payload: abl, aop, boot, devcfg, dtbo, hyp, keymaster, modem, product, qupfw, system, system_ext, tz, uefisecapp, vbmeta, vbmeta_system, vendor, xbl, xbl_config
Error: Failed to extract images from payload

Caused by:
    0: I/O error
    1: invalid options
@chenxiaolong
Copy link
Owner

Thanks for the logs!

It looks like this is a multithreading-related issue. Strangely enough, I cannot reproduce it with the default behavior (16 threads in my case), but if I force it to be single threaded with RAYON_NUM_THREADS=1 avbroot <...>, then it breaks.

I'm looking into it now.

avbroot 2.0.2 (Note: it might be good to have a version command, or display version in output)

Good idea. I'll definitely add a version command.

@chenxiaolong chenxiaolong self-assigned this Sep 7, 2023
chenxiaolong added a commit that referenced this issue Sep 7, 2023
When using the xz2/static feature, the xz2 crate uses a bundled version
of xz 5.2 and doesn't enable all of the available encoders and decoders.
This prevents certain payload data from being decompressed.

Fixes: #138

Signed-off-by: Andrew Gunnerson <[email protected]>
chenxiaolong added a commit that referenced this issue Sep 7, 2023
Issue: #138

Signed-off-by: Andrew Gunnerson <[email protected]>
chenxiaolong added a commit that referenced this issue Sep 7, 2023
When using the xz2/static feature, the xz2 crate uses a bundled version
of xz 5.2 and doesn't enable all of the available encoders and decoders.
This prevents certain payload data from being decompressed.

Fixes: #138

Signed-off-by: Andrew Gunnerson <[email protected]>
@chenxiaolong
Copy link
Owner

So it turns out this wasn't a bug in avbroot, but in the Rust xz2 dependency. For the precompiled binaries, it's using a buggy/old version of xz (5.2 instead of the latest 5.4.4).

Folks who built from source weren't affected because the default behavior is to use the (presumably not buggy) system version of xz.

This should be fixed by #139. --version will be added by #140. Both of these will be included in version 2.0.3, which I plan to release later today.

@AgentOak
Copy link
Contributor Author

AgentOak commented Sep 7, 2023

Thank you! Confirm fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants