Bug 1784084

Summary: Automatic unlocking using Clevis + TPM2 doesn't happen for non-root volumes
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: clevisAssignee: Sergio Correia <scorreia>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: high Docs Contact:
Priority: high    
Version: 8.1CC: dapospis, jcall
Target Milestone: rc   
Target Release: 8.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-02-13 11:06:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2019-12-16 17:02:00 UTC
Description of problem:

Trying to automatically unlock a non-root volume, e.g. /home backed on LVM "data" VG and "lv_home" LV, LVM VG being LUKS encrypted backed on /dev/sda3, it happens that automatic unlocking doesn't happen automatically.

Article https://access.redhat.com/articles/4500491 describes how to work around this, but this is extremely complicated. Everything should just work without heavy administration intervention.

The root cause of the issue is there is no clevis-luks-askpass service running *yet* at the time the LVM VG "data" is set up.
Indeed, current clevis-luks-askpass.{path|service} assume that the Network is up, which is false assumption here. It is just *not* possible to delay the opening of the LVM VG until the network is there (this could also create other issues, such as not being able to start services).

To fix all this, it is in fact *sufficient* to start clevis-luks-askpass.{path|service} early during the boot phase, by modifying the corresponding units as shown below:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# cat > /etc/systemd/system/clevis-luks-askpass.path << EOF
[Unit]
Description=Clevis systemd-ask-password Watcher
DefaultDependencies=no
Conflicts=shutdown.target
Before=cryptsetup.target

[Path]
PathChanged=/run/systemd/ask-password

[Install]
WantedBy=cryptsetup.target
EOF
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# cat > /etc/systemd/system/clevis-luks-askpass.service << EOF
[Unit]
Description=Clevis LUKS systemd-ask-password Responder
DefaultDependencies=no
Conflicts=shutdown.target

[Service]
Type=oneshot
ExecStart=/usr/libexec/clevis-luks-askpass -l
EOF
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Enable the unit:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# systemctl daemon-reload
# systemctl enable clevis-luks-askpass.path
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


This solves *all problems* (apparently, please double-check):
- in case Tang is used (Tang requires the network), the service will anyway work because the network has already been set up in the initramfs. This *only* assumes the network is always up in the initramfs, even if no root volume is encrypted (currently it's the case, because rd.neednet=1)
- in case TPM2 is used, this also works since everything is local


Version-Release number of selected component (if applicable):

clevis*-11-2.el8.x86_64

How reproducible:

Always


Steps to Reproduce:
1. Bind a non-root LUKS device to TPM2
2. Reboot

Actual results:

No unlocking


Additional info:

In an ideal world, the clevis-luks-asspath.path unit should be enabled automatically, without using "systemctl enable ...", but I don't know exactly how to make this possible.