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

fix(crypt): close crypt devices to release encryption keys get on shutdown #2471

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions modules.d/90crypt/crypt-shutdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# Remove leftover udev control socket to prevent cryptsetup hangup
rm -f /run/udev/control

# Mark crypt devices for deferred removal.
# The dm module removes holding devices, so
# that the encryption keys can be released.
dmsetup ls --target crypt | while read -r name _; do
if ! type "cryptsetup" > /dev/null 2>&1; then
systemd-cryptsetup detach "$name" deferred 2>&1 | vinfo
else
cryptsetup close "$name" --deferred 2>&1 | vinfo
fi
done
4 changes: 3 additions & 1 deletion modules.d/90crypt/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ install() {
fi

inst_hook cmdline 30 "$moddir/parse-crypt.sh"
inst_hook shutdown 24 "$moddir/crypt-shutdown.sh"
LaszloGombos marked this conversation as resolved.
Show resolved Hide resolved
inst_multiple -o cryptsetup
if ! dracut_module_included "systemd"; then
inst_multiple cryptsetup rmdir readlink umount
inst_multiple rmdir readlink umount
inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev
inst_hook cmdline 10 "$moddir/parse-keydev.sh"
Expand Down