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

magiskboot unable to process sfx gzip kernel #1714

13-beta2 opened this issue Jul 21, 2019 · 2 comments


Copy link

commented Jul 21, 2019

Magiskboot util is unable to detect and unpack zImage with "classic" layout:

  • decompressor code (starts with a bunch of arm32 nops)
  • gzipped kernel
  • dtbo chunk

As seen in 7-zip:
Not a problem in case of pre-P kernel, but my kernel is system-as-root, so it must be patched to force using injected ramdisk.

Att: patched kernel of xiaomi redmi 7a.


This comment has been minimized.

Copy link

commented Jul 22, 2019

Unfortunately, there is no way to patch armeabi zImage kernel since the gzip size cannot be ensured to be the same size when repacking after patching. The gzipped kernel size depends on the compression algorithm, and there is no guarantee that after modifying the original file, the deflate algorithm (what gzip uses) will produce a binary with the same size.

I had tried to patch the offset/pad zeros in the case when the size mismatch, but none of it works.

BTW, I think your device should be using A only system-as-root right? You should try to install Magisk to the recovery as normal boot images might not work anyways.

@topjohnwu topjohnwu closed this Jul 22, 2019

@topjohnwu topjohnwu added the wontfix label Jul 22, 2019


This comment has been minimized.

Copy link

commented Jul 22, 2019

@topjohnwu Thanks for prompt reply. Your concerns are clear. Re-compress patched binary into same sized file is barely achievable.
But pls let me add some details. AFAIK vendor kernel are usually compressed using default settings and any optimized compression usually leads to smaller file. I've managed to successfully boot with patched boot.img using re-compressed kernel binary simply OVERWRITTEN over original binary in zImage. (So I had next layout: untouched decompressor code, then patched gzipped kernel, then short tail of original gzipped kernel and at last untouched dtbo binary.) In this case there is no need to do any kind of fixups in decompressor code nor dtbo.

Agree. This sounds like quite dirty workaround, but I believe this way of magisk delivery much more convenient for end users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.