Skip to content

Commit 140ce37

Browse files
bmarzinsMikulas Patocka
authored andcommitted
dm init: Handle minors larger than 255
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>
1 parent c1a66a3 commit 140ce37

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/md/dm-init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ static char __init *dm_parse_device_entry(struct dm_device *dev, char *str)
212212
strscpy(dev->dmi.uuid, field[1], sizeof(dev->dmi.uuid));
213213
/* minor */
214214
if (strlen(field[2])) {
215-
if (kstrtoull(field[2], 0, &dev->dmi.dev))
215+
if (kstrtoull(field[2], 0, &dev->dmi.dev) ||
216+
dev->dmi.dev >= (1 << MINORBITS))
216217
return ERR_PTR(-EINVAL);
218+
dev->dmi.dev = huge_encode_dev((dev_t)dev->dmi.dev);
217219
dev->dmi.flags |= DM_PERSISTENT_DEV_FLAG;
218220
}
219221
/* flags */

0 commit comments

Comments
 (0)