Bug 1366575

Summary: Reboot from emergency.target hangs when rootfs is on LUKS
Product: [Fedora] Fedora Reporter: Michal Sekletar <msekleta>
Component: systemdAssignee: systemd-maint
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 26CC: johannbg, lnykryn, msekleta, muadda, ssahani, s, systemd-maint, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1370133 (view as bug list) Environment:
Last Closed: 2017-03-16 08:25:32 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:
Bug Depends On:    
Bug Blocks: 1370133    

Description Michal Sekletar 2016-08-12 11:21:12 UTC
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 Fedora End Of Life 2017-02-28 10:05:26 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle.
Changing version to '26'.

Comment 2 Michal Sekletar 2017-03-16 08:25:32 UTC
This was fixed while ago by,

https://github.com/systemd/systemd/pull/4039/commits/a2de10775194edec51b1e88d20a380724a3dc716

Above commit is included in systemd-v233 (F26 and rawhide).