Patch "dm init: Handle minors larger than 255" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    dm init: Handle minors larger than 255

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     dm-init-handle-minors-larger-than-255.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 72cdd9e411d98f53e0162abf9ad2191f7f5845a9
Author: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
Date:   Tue Jul 2 12:13:24 2024 +0200

    dm init: Handle minors larger than 255
    
    [ Upstream commit 140ce37fd78a629105377e17842465258a5459ef ]
    
    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@xxxxxxxxxx>
    Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/md/dm-init.c b/drivers/md/dm-init.c
index dc4381d68313..6e9e73a55874 100644
--- a/drivers/md/dm-init.c
+++ b/drivers/md/dm-init.c
@@ -213,8 +213,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 */




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux