-
Notifications
You must be signed in to change notification settings - Fork 402
Always ensure /dev/{u,random} are in initramfs #2331
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2431,9 +2431,17 @@ else | |
if ! ( | ||
umask 077 | ||
cd "$initdir" | ||
# We generate two initramfs "chunks"; the primary one with all the files first. This is done | ||
# asynchronously. | ||
mkfifo ${DRACUT_TMPDIR}/main.fifo | ||
mkfifo ${DRACUT_TMPDIR}/random.fifo | ||
cat ${DRACUT_TMPDIR}/main.fifo ${DRACUT_TMPDIR}/random.fifo | $compress >> "${DRACUT_TMPDIR}/initramfs.img" & | ||
find . -print0 | sort -z \ | ||
| cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null ${cpio_owner:+-R "$cpio_owner"} -H newc -o --quiet \ | ||
| $compress >> "${DRACUT_TMPDIR}/initramfs.img" | ||
| cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null ${cpio_owner:+-R "$cpio_owner"} -H newc -o --quiet > ${DRACUT_TMPDIR}/main.fifo | ||
# Next, in order to avoid requiring privilege at initramfs generation time, which we may not have | ||
# in a container image, append a pre-generated cpio blob with /dev/{u,random}. | ||
zcat ${dracutsysrootdir}/${dracutbasedir}/dracut-random.cpio.gz > ${DRACUT_TMPDIR}/random.fifo | ||
wait | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Asynchronous append here also seems like overkill given the size of the trailing archive. |
||
); then | ||
dfatal "Creation of $outfile failed" | ||
exit 1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,16 +70,4 @@ install() { | |
inst_multiple sha512hmac rmmod insmod mount uname umount grep sed cut find sort | ||
|
||
inst_simple /etc/system-fips | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the simplicity of cpio and what's needed here, it's tempting to propose just using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm yes, I think the cpio format may be sufficiently simple that we could do it via |
||
[ -c "${initdir}"/dev/random ] || mknod "${initdir}"/dev/random c 1 8 \ | ||
|| { | ||
dfatal "Cannot create /dev/random" | ||
dfatal "To create an initramfs with fips support, dracut has to run as root" | ||
return 1 | ||
} | ||
[ -c "${initdir}"/dev/urandom ] || mknod "${initdir}"/dev/urandom c 1 9 \ | ||
|| { | ||
dfatal "Cannot create /dev/urandom" | ||
dfatal "To create an initramfs with fips support, dracut has to run as root" | ||
return 1 | ||
} | ||
} |
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.
I don't think compression makes much sense for a two (or three with
/dev
) item cpio archive.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.
One thing I forgot to mention: GNU cpio unnecessarily zero-pads archives out to the next "block-size" (default=512) alignment, while the newc / SVR4 spec only requires 4-byte alignment, so any bundled archive with GNU cpio padding could be trimmed down.
In matching GNU cpio quirks, dracut-cpio does the same:
https://github.com/dracutdevs/dracut/blob/master/src/dracut-cpio/src/main.rs#L644