]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dm init: Handle minors larger than 255
authorBenjamin Marzinski <bmarzins@redhat.com>
Tue, 2 Jul 2024 10:13:24 +0000 (12:13 +0200)
committerMikulas Patocka <mpatocka@redhat.com>
Tue, 2 Jul 2024 18:53:41 +0000 (20:53 +0200)
dm_parse_device_entry() simply copies the minor number into dmi.dev, but
the dev_t format splits the minor number between the lowest 8 bytes and
highest 12 bytes. If the minor number is larger than 255, part of it
will end up getting treated as the major number

Fix this by checking that the minor number is valid and then encoding it
as a dev_t.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-init.c

index 2a71bcdba92d149ecfc8c92c2b1152bc9a8bf443..b37bbe76250034d7198c65283d60747c306c0744 100644 (file)
@@ -212,8 +212,10 @@ static char __init *dm_parse_device_entry(struct dm_device *dev, char *str)
        strscpy(dev->dmi.uuid, field[1], sizeof(dev->dmi.uuid));
        /* minor */
        if (strlen(field[2])) {
-               if (kstrtoull(field[2], 0, &dev->dmi.dev))
+               if (kstrtoull(field[2], 0, &dev->dmi.dev) ||
+                   dev->dmi.dev >= (1 << MINORBITS))
                        return ERR_PTR(-EINVAL);
+               dev->dmi.dev = huge_encode_dev((dev_t)dev->dmi.dev);
                dev->dmi.flags |= DM_PERSISTENT_DEV_FLAG;
        }
        /* flags */