]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: (dasd) guard against uint64 underflow in LDL size calculation
authorKarel Zak <kzak@redhat.com>
Tue, 19 May 2026 08:18:44 +0000 (10:18 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 19 May 2026 08:32:19 +0000 (10:32 +0200)
When an LDL volume label has ldl_version < 0xf2, the partition
size is derived from the device size. If the device is smaller
than the partition start offset (3 blocks), the subtraction
wraps around producing a bogus partition size.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/partitions/dasd.c

index d30163eceeafa42263e5a6ed25ed471249653f75..92044eb222c0129208510b2da4f4867e532b586a 100644 (file)
@@ -248,7 +248,13 @@ static int probe_dasd_pt_ldl(blkid_probe pr, blkid_partlist ls,
                }
                size_512 = (blocks - 3) * blocksize / 512;
        } else {
-               size_512 = blkid_probe_get_size(pr) / 512 - start_512;
+               uint64_t dev_512 = blkid_probe_get_size(pr) / 512;
+
+               if (dev_512 <= start_512) {
+                       DBG(LOWPROBE, ul_debug("DASD LDL: device too small"));
+                       return BLKID_PROBE_NONE;
+               }
+               size_512 = dev_512 - start_512;
        }
 
        DBG(LOWPROBE, ul_debug("DASD LDL: start=%"PRIu64" size=%"PRIu64" blocksize=%u",