FS#76812 - [mkinitcpio] 34 symlink corner case can result in unbootable system

Attached to Project: Arch Linux
Opened by Taeyeon Mori (Orochimarufan) - Monday, 12 December 2022, 22:58 GMT
Last edited by Morten Linderud (Foxboron) - Thursday, 12 January 2023, 14:57 GMT
Task Type Bug Report
Category Arch Projects
Status Closed
Assigned To Giancarlo Razzolini (grazzolini)
Morten Linderud (Foxboron)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
mkinitcpio 34's add_file breaks with symlinks that become a self-referential loop when copied to their new name inside the image
# ln -s crypttab crypttab.initramfs
# add_file crypttab.initramfs crypttab

This worked in 33, though I suspect only by coincidence; The new outcome is not all that surprising when actually given some consideration.
It should either be explicitly allowed and effectively turned it into a (dereferenced) copy of the target, or disallowed completely and reported as an error.
Either way, it should be detected and not silently build a broken initramfs, since there is no immediately obvious (to a user, without considering mkinitcpio hook internals) reason why having crypttab.initramfs be a symlink to crypttab should be problematic and hence it's an easy mistake to make.
If this is deemed too much effort, there should probably at least be warnings about symlinking files intended for the initramfs on the wiki, preferrably whenever such files are mentioned.

Additional info:
* mkinitcpio 34-2

Steps to reproduce:
- Use sd-encrypt hook (or otherwise add_file '/etc/crypttab.initramfs' '/etc/crypttab')
- # ln -s crypttab /etc/crypttab.initramfs
- # mkinitcpio -P
- /etc/crypttab in initramfs will be a symlink to itself (loop). System won't boot if reliant on crypttab entries.

Workaround:
Use a hard link for /etc/crypttab.initramfs instead
This task depends upon

Closed by  Morten Linderud (Foxboron)
Thursday, 12 January 2023, 14:57 GMT
Reason for closing:  Fixed
Comment by Fnord Popos (noddy) - Tuesday, 13 December 2022, 17:51 GMT
Bitten by this too, while waking from hibernation. Not the easiest thing to debug.

Have been using sd-encrypt with `/etc/crypttab.initramfs -> crypttab` for some time.
Comment by Toolybird (Toolybird) - Tuesday, 13 December 2022, 20:36 GMT
New development home for mkinitcpio [1]. You might get a quicker/better response over there.

[1] https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio
Comment by nl6720 (nl6720) - Wednesday, 14 December 2022, 12:43 GMT

Loading...