-
Notifications
You must be signed in to change notification settings - Fork 199
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
libpriv/kernel: Add padding between dracut initramfs and random CPIO #4705
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks. Indeed if this is sufficient that'd be great.
I would say though it'd be cleaner here to deduplicate things and change the Rust API to take a file descriptor as input, then we can have one implementation only in Rust.
rust/src/cliwrap/kernel_install.rs
Outdated
let zeros = &[b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0']; | ||
f.write(&zeros[..8 - misalignment])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
std::io::copy(&mut std::io::repeat(0).take(misalignment), &mut f)?;
How about
|
Calculations are wrong of course... EDIT: Should be fixed and added a unit test, though this also deserves integration testing |
@cgwalters should I add this to the release or we are waiting for a integration test? |
We were thinking of proposing a change to lz4 initrd compression in Fedora, with this change lz4 initrds would still not be FIPS compliant I guess (checking my assumptions)? If this weakens FIPS, it will still make alternate compression algorithms unusable in many scenarios because of the weakening in FIPS compliance. We should still merge this when ready, as it's still an improvement regardless. |
Thanks, I'll update it based on your Rust diff soon and add an integration test for this.
There's actually another (unrelated, small) patch I'd like to get in before cutting a release. Will get that out today. (Edit: #4710).
I'm not sure I follow the link with FIPS compliance. Hmm OK, I think you might be thinking that with this, the |
No; the issue boils down to whether dracut has privileges to create the device nodes at build time, it is orthogonal to the compression algorithm. |
e23ec57
to
69cc681
Compare
Looks like the unit test needs a tweak since we're now appending another 4 bytes in the already-aligned case right? |
Any arbitrary amount of padding between concatenated CPIOs is allowed: https://www.kernel.org/doc/Documentation/early-userspace/buffer-format.txt However, some initramfs decompressors in the kernel expect a minimal amount of padding to detect EOF and allow the kernel outer loop to try out other decompressors for the next payload. This is the case for lz4. This upstream patch allows the lz4 decompressor to treat padding as EOF: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2c484419efc09e7234c667aa72698cb79ba8d8ed But it assumes that the padding is at least 4 bytes. Since padding doesn't hurt regardless of the compression used, let's just unconditionally add it. Fixes coreos#4683. Co-authored-by: Colin Walters <[email protected]>
69cc681
to
9985157
Compare
The initrd appeared to be uncompressed to help with boot speed based on the configuration, however the initrd that was generated was actually gzip compressed, and this added about 100ms or so to the overall boot time. We can now use lz4 for the rpm-ostree since this merge request has now been merged: coreos/rpm-ostree#4705 Here's the boot time results now that lz4 is always used: # cs9-qemu-minimal-regular.x86_64.qcow2 Startup finished in 216ms (kernel) + 1.552s (initrd) + 2.448s (userspace) = 4.218s Startup finished in 216ms (kernel) + 1.514s (initrd) + 2.156s (userspace) = 3.887s Startup finished in 212ms (kernel) + 1.446s (initrd) + 2.180s (userspace) = 3.840s # cs9-qemu-minimal-ostree.x86_64.qcow2 Startup finished in 216ms (kernel) + 1.689s (initrd) + 2.669s (userspace) = 4.575s Startup finished in 207ms (kernel) + 1.643s (initrd) + 2.204s (userspace) = 4.056s Startup finished in 209ms (kernel) + 1.124s (initrd) + 1.373s (userspace) = 2.707s Note that this change requires a patch to be applied to ABL for RideSX4 that removes the 'ro' kernel command line argument. Signed-off-by: Brian Masney <[email protected]>
Any arbitrary amount of padding between concatenated CPIOs is allowed:
https://www.kernel.org/doc/Documentation/early-userspace/buffer-format.txt
However, some initramfs decompressors in the kernel expect a minimal amount of padding to detect EOF and allow the kernel outer loop to try out other decompressors for the next payload. This is the case for lz4. This upstream patch allows the lz4 decompressor to treat padding as EOF:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2c484419efc09e7234c667aa72698cb79ba8d8ed
But it assumes that the padding is at least 4 bytes.
Since padding doesn't hurt regardless of the compression used, let's just unconditionally add it.
Fixes #4683.