]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
blockdev-util: Iterate through all DM layers 40426/head
authorChris Down <chris@chrisdown.name>
Thu, 22 Jan 2026 10:15:33 +0000 (18:15 +0800)
committerChris Down <chris@chrisdown.name>
Fri, 23 Jan 2026 13:27:12 +0000 (21:27 +0800)
get_block_device_harder_fd() currently only traverses one level of
device mapper stacking when looking for the underlying block device.
This causes issues with nested DM setups like dm-crypt on top of
dm-integrity, where we don't traverse enough to get the actual physical
device.

Fix this by iterating through all DM layers until we reach a device with
no underlying device.

Fixes: #40419
src/shared/blockdev-util.c

index b138455acc9e6dc9190d833d7963adb772e9f977..44feae5ab60c62524ab0c4de90f369d8c52e6b9c 100644 (file)
@@ -346,14 +346,14 @@ int get_block_device_harder_fd(int fd, dev_t *ret) {
         assert(fd >= 0);
         assert(ret);
 
-        /* Gets the backing block device for a file system, and handles LUKS encrypted file systems, looking for its
-         * immediate parent, if there is one. */
+        /* Gets the backing block device for a file system, and handles LUKS encrypted file systems, looking
+         * for its underlying physical device, if there is one. */
 
         r = get_block_device_fd(fd, ret);
         if (r <= 0)
                 return r;
 
-        r = block_get_originating(*ret, ret, /* recursive= */ false);
+        r = block_get_originating(*ret, ret, /* recursive= */ true);
         if (r < 0)
                 log_debug_errno(r, "Failed to chase block device, ignoring: %m");