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

lz4 compression causing kernel panic on boot #117

Closed
krathalan opened this issue Nov 30, 2021 · 6 comments
Closed

lz4 compression causing kernel panic on boot #117

krathalan opened this issue Nov 30, 2021 · 6 comments

Comments

@krathalan
Copy link

With the latest 5.15 kernel I am having an issue where only lz4 compression (not zstd) on the initramfs image is causing the following kernel panic:

initramfs unpacking failed: junk at the end of compressed archive
panic: initrd-release cannot be found

goroutine 1 [running]:
main.main()
    init/main.go:904 +0x9a
....

I noticed that the size of the lz4-compressed initramfs was 57MB. If I manually compressed the initramfs image after generation with lz4's highest compression levels, the lowest size was 60MB. So somewhere data is being lost.

Additionally, I am only having this issue on one computer. My other computer is continuing to output working lz4-compressed initramfs images. The only difference between my two config files is that the one with the lz4 compression problem also includes the following modules: nvidia, nvidia_modeset, nvidia_drm, nvidia_uvm.

To be clear, this issue does not reproduce itself on a kernel version <= 5.14 or a different compression algorithm. I am only having this issue with kernel 5.15 and lz4 compression.

You can see my full config files here:
Broken lz4: https://github.com/krathalan/etc-config/blob/df12d69459fce70a86f22fd9ffdace8258c0aa5b/desktop/booster.yaml
Working lz4: https://github.com/krathalan/etc-config/blob/8b0dc210e341466f52e60f44fcf4c28b84a69a53/laptop/booster.yaml

@anatol
Copy link
Owner

anatol commented Dec 1, 2021

Could you please check thew lz4 archive with lz4 --test booster.img?

Also check the recent booster changes from wip branch. Booster has moved to the newer lz4 library and might fix your situation.

the one with the lz4 compression problem also includes the following modules: nvidia, nvidia_modeset, nvidia_drm, nvidia_uvm.

If you remove these modules does your machine able to read the initramfs image?

@ghost
Copy link

ghost commented Dec 1, 2021

I seem to be having a similar issue and system will throw a kernel panic if I include the Nvidia modules within. If I remove the modules from the booster image the system boots up normally.

I tried using Booster from the wip image however same error remains and system still unbootable. If I run the command lz4 --test booster.img I get: Error 53 : Decoding Failed ! Corrupted input detected !

@anatol
Copy link
Owner

anatol commented Dec 1, 2021

Could you please try wip branch, it uses newer version of lz4 library.

@ghost
Copy link

ghost commented Dec 1, 2021

Had done that already as well, though still remained with the same error

@anatol
Copy link
Owner

anatol commented Dec 1, 2021

I can verify this problem with the latest lz4 library (v4.1.11).

lz4 --test test.img --verbose
*** LZ4 command line interface 64-bits v1.9.3, by Yann Collet ***
Stream followed by undecodable data at position 17712141 
test.img             : decoded 33554432 bytes

ls -l test.img 
-rw-r--r-- 1 anatol anatol 71072487 Dec  1 09:13 test.img

@pierrec it looks like legacy writer produces some invalid output. It is still not clear what triggers it, maybe large size input. I will try to come up with a simple test case for the issue.

Note that lz4 was able to decode only first 33554432 bytes (that is 0x2000000 in hex, the size of the buffer).

anatol added a commit that referenced this issue Feb 12, 2022
anatol added a commit that referenced this issue Feb 17, 2022
anatol added a commit that referenced this issue Feb 20, 2022
anatol added a commit that referenced this issue Feb 20, 2022
anatol added a commit that referenced this issue Mar 5, 2022
anatol added a commit that referenced this issue Mar 8, 2022
anatol added a commit that referenced this issue Mar 8, 2022
github.com/pierrec/lz4 has numerous problems with its legacy writer
(e.g. pierrec/lz4#156) that prevents it using
for initramfs compression.

Replace it with a cli tool ('lz4') wrapper.

Fixes #117
@anatol
Copy link
Owner

anatol commented Mar 8, 2022

The upstream lz4 go library project is unresponsive with this issue and was not able to fix it unfortunately.

I replaced github.com/pierrec/lz4 library with a CLI wrapper. It shows that the LZ4 tests pass now (including tests for large images).

I pushed the fix to replace-lz4-with-cli branch. Please try it and let me know if you see any issues.

@anatol anatol closed this as completed in fe41972 Mar 9, 2022
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

No branches or pull requests

2 participants