Bug 1370133

Summary: Reboot from emergency.target hangs when rootfs is on LUKS
Product: Red Hat Enterprise Linux 7 Reporter: Michal Sekletar <msekleta>
Component: systemdAssignee: systemd-maint
Status: CLOSED ERRATA QA Contact: Branislav Blaškovič <bblaskov>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.2CC: bblaskov, extras-qa, johannbg, lnykryn, msekleta, muadda, ovasik, ssahani, s, systemd-maint-list, systemd-maint, zbyszek
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: systemd-219-29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1366575 Environment:
Last Closed: 2016-11-04 00:56:06 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:
Bug Depends On: 1366575    
Bug Blocks:    

Description Michal Sekletar 2016-08-25 11:55:52 UTC
+++ This bug was initially created as a clone of Bug #1366575 +++

Description of problem:
When rootfs is on LUKS we need to deactivate LUKS device during shutdown. To do that we call systemd-cryptsetup detach on the particular device. systemd-cryptsetup will then call crypt_deactivate function from libcryptsetup. This function then deactivates device, but when libcryptsetup notices that udev daemon is still running it executes the code path that uses udev cookies (synchronization mechanism implemented by libdevicemapper based on udev). To figure out whether udev is running it uses udev_queue_get_udev_is_active function from libudev. However this function only checks for presence of udev control AF_UNIX socket. Because system is in emergency mode, udev is not running  anymore and corresponding socket unit was also already stopped. Note that systemd by default doesn't unlink AF_UNIX sockets from the filesystem when socket unit is stopped. udev_queue_get_udev_is_active then returns true because /run/udev/control AF_UNIX socket is still present, but udevd is actually not running. That will then cause hang in libcryptsetup. 

Version-Release number of selected component (if applicable):
systemd-231-3.fc26

How reproducible:
always

Steps to Reproduce:
1. install system with encrypted /
2. systemctl isolate emergency.target
3. sulogin
4. reboot

Actual results:
Reboot hangs

Expected results:
Reboot completes in a timely fashion

Additional info:
https://github.com/systemd/systemd/issues/2477

Comment 1 Branislav Blaškovič 2016-08-25 12:05:45 UTC
qa acking

Comment 3 Lukáš Nykrýn 2016-09-05 14:10:05 UTC
fix merged to upstream staging branch ->
https://github.com/lnykryn/systemd-rhel/commit/f77d58374ccd2e3d9c886e59020f1b32e97f2bdc
-> post

Comment 6 errata-xmlrpc 2016-11-04 00:56:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2216.html