Fix bug in DM iteration and standardise how to iterate through DM layers (#40426)

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. And while we're at it also make cgroups use the
same logic.

Fixes: #40419
This commit is contained in:
Yu Watanabe
2026-01-30 15:36:03 +09:00
committed by GitHub
8 changed files with 48 additions and 17 deletions
+1 -1
View File
@@ -9935,7 +9935,7 @@ static int acquire_root_devno(
return -ENOTBLK;
/* From dm-crypt to backing partition */
r = block_get_originating(devno, &devno);
r = block_get_originating(devno, &devno, /* recursive= */ false);
if (r == -ENOENT)
log_debug_errno(r, "Device '%s' has no dm-crypt/dm-verity device, no need to look for underlying block device.", p);
else if (r < 0)