Skip to content

(RHEL-144833) generator: order cryptsetup/verity/integrity after systemd-udevd - #165

Closed
siteshwar wants to merge 2 commits into
redhat-plumbers:mainfrom
siteshwar:RHEL-144833
Closed

(RHEL-144833) generator: order cryptsetup/verity/integrity after systemd-udevd#165
siteshwar wants to merge 2 commits into
redhat-plumbers:mainfrom
siteshwar:RHEL-144833

Conversation

@siteshwar

@siteshwar siteshwar commented Aug 12, 2026

Copy link
Copy Markdown

During soft-reboot teardown, systemd-cryptsetup@.service's ExecStop runs libcryptsetup's crypt_deactivate(), which issues DM_REMOVE with a udev cookie and blocks in dm_udev_wait() until 95-dm-notify.rules decrements the cookie semaphore via "dmsetup udevcomplete $env{DM_COOKIE}".

The generated cryptsetup unit had only After=systemd-udevd-kernel.socket, not After=systemd-udevd.service. The .socket has IgnoreOnIsolate=yes and is not stopped during soft-reboot, so it provides no ordering at all for the service teardown. Meanwhile systemd-udevd.service has Conflicts=soft-reboot.target (added in 0d1819e791) and stops as soon as soft-reboot.target starts, with no ordering relative to cryptsetup's ExecStop.

Once udevd's device monitor event source is disabled in manager_exit(), pending DM_REMOVE uevents are no longer processed and the cookie semaphore stays at 1 forever, blocking soft-reboot at "Stopping Cryptography Setup..." until JobTimeoutSec=30min on soft-reboot.target fires.

Add systemd-udevd.service to the After= ordering of the generated cryptsetup, veritysetup and integritysetup units. By systemd's job ordering rules (job_compare() in src/core/job.c), when two units are both being stopped and one has After= the other, the After= unit is stopped first. So with cryptsetup@*.service After=systemd-udevd.service, cryptsetup stops first (cookie acknowledged by the still-live udevd), then udevd stops.

Putting After=umount.target on systemd-udevd.service does not work: at soft-reboot, udevd's stop job runs concurrently with umount.target's start job, and JOB_STOP unconditionally precedes JOB_START in the transaction (see src/core/job.c:1742). The ordering has to be expressed between two stop jobs, which is what putting After=systemd-udevd.service on the dm consumers achieves.

Fixes: #40298
(cherry picked from commit 66a0bdad4f03f0c260ea2ba409f7b7c3884309fe)

Resolves: RHEL-144833

@github-actions github-actions Bot changed the title generator: order cryptsetup/verity/integrity after systemd-udevd (RHEL-144833) generator: order cryptsetup/verity/integrity after systemd-udevd Aug 12, 2026
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

Commit validation

Tracker - RHEL-144833

The following commits meet all requirements

commit upstream
c98ade7 - units: stop systemd-udevd before soft-reboot systemd/systemd@0d1819e
8274666 - generator: order cryptsetup/verity/integrity after systemd-udevd systemd/systemd@66a0bda

Tracker validation

Success

馃煝 Tracker RHEL-144833 has set desired product: rhel-10.4
馃煝 Tracker RHEL-144833 has set desired component: systemd
馃煝 Tracker RHEL-144833 has been approved
馃煝 Tracker RHEL-144833 has set severity


Pull Request validation

Failed

馃敶 Review - Missing review from a member (1 required)

Success

馃煝 CI - All checks have passed


Triggered by Workflow Run

yuwata and others added 2 commits August 12, 2026 13:11
Otherwise, queued uevents may be lost on soft-reboot.

Similar to f89985c, but for
systemd-udevd.

(cherry picked from commit 0d1819e791a97367c2c0cead738111cfcc1e7491)

Related: RHEL-144833
During soft-reboot teardown, systemd-cryptsetup@.service's ExecStop runs
libcryptsetup's crypt_deactivate(), which issues DM_REMOVE with a udev
cookie and blocks in dm_udev_wait() until 95-dm-notify.rules decrements
the cookie semaphore via "dmsetup udevcomplete $env{DM_COOKIE}".

The generated cryptsetup unit had only After=systemd-udevd-kernel.socket,
not After=systemd-udevd.service. The .socket has IgnoreOnIsolate=yes and
is not stopped during soft-reboot, so it provides no ordering at all for
the service teardown. Meanwhile systemd-udevd.service has
Conflicts=soft-reboot.target (added in 0d1819e791) and stops as soon as
soft-reboot.target starts, with no ordering relative to cryptsetup's
ExecStop.

Once udevd's device monitor event source is disabled in manager_exit(),
pending DM_REMOVE uevents are no longer processed and the cookie
semaphore stays at 1 forever, blocking soft-reboot at "Stopping
Cryptography Setup..." until JobTimeoutSec=30min on soft-reboot.target
fires.

Add systemd-udevd.service to the After= ordering of the generated
cryptsetup, veritysetup and integritysetup units. By systemd's job
ordering rules (job_compare() in src/core/job.c), when two units are
both being stopped and one has After= the other, the After= unit is
stopped first. So with cryptsetup@*.service After=systemd-udevd.service,
cryptsetup stops first (cookie acknowledged by the still-live udevd),
then udevd stops.

Putting After=umount.target on systemd-udevd.service does not work: at
soft-reboot, udevd's stop job runs concurrently with umount.target's
start job, and JOB_STOP unconditionally precedes JOB_START in the
transaction (see src/core/job.c:1742). The ordering has to be expressed
between two stop jobs, which is what putting After=systemd-udevd.service
on the dm consumers achieves.

Fixes: #40298
(cherry picked from commit 66a0bdad4f03f0c260ea2ba409f7b7c3884309fe)

Resolves: RHEL-144833
@siteshwar

Copy link
Copy Markdown
Author

I tried to reproduce this issue on rawhide and it is still reproducible. So the fixes in this pull request are either inaccurate or incomplete. I have opened systemd/systemd#43368 to follow up on upstream about it. I will close this pull request to avoid any confusion regarding the fixes.

@siteshwar siteshwar closed this Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants